-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deployment resource and data sources for catalog_item and deploym…
…ent (#91) Signed-off-by: Deepak Mettem <[email protected]>
- Loading branch information
Showing
29 changed files
with
1,752 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# deployment examples | ||
|
||
This directory covers examples on how to create a deployment in different ways. | ||
|
||
## Getting Started | ||
|
||
Follow these examples for creating deployments: | ||
|
||
* [Deployment](blueprint/README.md) with a blueprint id | ||
* [Deployment](catalog_item/README.md) with a catalog item id | ||
* [Deployment](no_resources/README.md) with no resources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# deployment with a blueprint id example | ||
|
||
This is an example on how to crete a deployment in vRealize Automation(vRA) using an existing blueprint. | ||
|
||
## Getting Started | ||
|
||
There are variables which need to be added to terraform.tfvars. | ||
|
||
* `url` - The URL for the vRealize Automation (vRA) endpoint | ||
* `refresh_token` - The refresh token for the vRA account | ||
* `project_name` - Project Name | ||
* `blueprint_id` - Blueprint ID | ||
* `blueprint_version` - Blueprint Version | ||
* `deployment_name` - Deployment Name | ||
|
||
To facilitate adding these variables, a sample tfvars file can be copied first: | ||
```shell | ||
cp terraform.tfvars.sample terraform.tfvars | ||
``` | ||
|
||
Once the information is added to `terraform.tfvars`, the cloud account can be brought up via: | ||
|
||
```shell | ||
terraform init | ||
terraform apply | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
provider "vra" { | ||
url = var.url | ||
refresh_token = var.refresh_token | ||
} | ||
|
||
data "vra_project" "this" { | ||
name = var.project_name | ||
} | ||
|
||
resource "vra_deployment" "this" { | ||
name = var.deployment_name | ||
description = "terraform test deployment" | ||
|
||
blueprint_id = var.blueprint_id | ||
blueprint_version = var.blueprint_version | ||
project_id = data.vra_project.this.id | ||
|
||
inputs = { | ||
flavor = "small" | ||
image = "centos" | ||
} | ||
|
||
expand_resources = true | ||
expand_last_request = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
refresh_token = "" | ||
url = "" | ||
project_name = "" | ||
blueprint_id = "" | ||
blueprint_version = "" | ||
deployment_name = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
variable "url" { | ||
} | ||
|
||
variable "refresh_token" { | ||
} | ||
|
||
variable "project_name" { | ||
} | ||
|
||
variable "blueprint_id" { | ||
} | ||
|
||
variable "blueprint_version" { | ||
} | ||
|
||
variable "deployment_name" { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# deployment with a catalog item example | ||
|
||
This is an example on how to request/create a deployment in vRealize Automation(vRA) using an existing catalog item. | ||
|
||
## Getting Started | ||
|
||
There are variables which need to be added to terraform.tfvars. | ||
|
||
* `url` - The URL for the vRealize Automation (vRA) endpoint | ||
* `refresh_token` - The refresh token for the vRA account | ||
* `project_name` - Project Name | ||
* `catalog_item_name` - Catalog Item Name | ||
* `catalog_item_version` - Catalog Item Version | ||
* `deployment_name` - Deployment Name | ||
|
||
To facilitate adding these variables, a sample tfvars file can be copied first: | ||
```shell | ||
cp terraform.tfvars.sample terraform.tfvars | ||
``` | ||
|
||
Once the information is added to `terraform.tfvars`, the cloud account can be brought up via: | ||
|
||
```shell | ||
terraform init | ||
terraform apply | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
provider "vra" { | ||
url = var.url | ||
refresh_token = var.refresh_token | ||
insecure = var.insecure | ||
} | ||
|
||
data "vra_project" "this" { | ||
name = var.project_name | ||
} | ||
|
||
data "vra_catalog_item" "this" { | ||
name = var.catalog_item_name | ||
expand_versions = true | ||
} | ||
|
||
resource "vra_deployment" "this" { | ||
name = var.deployment_name | ||
description = "terraform test deployment" | ||
|
||
catalog_item_id = data.vra_catalog_item.this.id | ||
catalog_item_version = var.catalog_item_version | ||
project_id = data.vra_project.this.id | ||
|
||
inputs = { | ||
flavor = "small" | ||
image = "centos" | ||
} | ||
|
||
expand_resources = true | ||
expand_last_request = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
refresh_token = "" | ||
url = "" | ||
insecure = "" | ||
project_name = "" | ||
catalog_item_name = "" | ||
catalog_item_version = "" | ||
deployment_name = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
variable "url" { | ||
} | ||
|
||
variable "refresh_token" { | ||
} | ||
|
||
variable "insecure" { | ||
} | ||
|
||
variable "project_name" { | ||
} | ||
|
||
variable "catalog_item_name" { | ||
} | ||
|
||
variable "catalog_item_version" { | ||
} | ||
|
||
variable "deployment_name" { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# deployment with no resources example | ||
|
||
This is an example on how to crete a deployment in vRealize Automation(vRA) without any resources. | ||
|
||
## Getting Started | ||
|
||
There are variables which need to be added to terraform.tfvars. | ||
|
||
* `url` - The URL for the vRealize Automation (vRA) endpoint | ||
* `refresh_token` - The refresh token for the vRA account | ||
* `project_name` - Project Name | ||
* `deployment_name` - Deployment Name | ||
|
||
To facilitate adding these variables, a sample tfvars file can be copied first: | ||
```shell | ||
cp terraform.tfvars.sample terraform.tfvars | ||
``` | ||
|
||
Once the information is added to `terraform.tfvars`, the cloud account can be brought up via: | ||
|
||
```shell | ||
terraform init | ||
terraform apply | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
provider "vra" { | ||
url = var.url | ||
refresh_token = var.refresh_token | ||
insecure = var.insecure | ||
} | ||
|
||
data "vra_project" "this" { | ||
name = var.project_name | ||
} | ||
|
||
resource "vra_deployment" "this" { | ||
name = var.deployment_name | ||
description = "terraform test deployment" | ||
|
||
project_id = data.vra_project.this.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
refresh_token = "" | ||
url = "" | ||
insecure = "" | ||
project_name = "" | ||
deployment_name = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
variable "url" { | ||
} | ||
|
||
variable "refresh_token" { | ||
} | ||
|
||
variable "insecure" { | ||
} | ||
|
||
variable "project_name" { | ||
} | ||
|
||
variable "deployment_name" { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package vra | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
"github.com/vmware/vra-sdk-go/pkg/models" | ||
) | ||
|
||
// resourceReferenceSchema returns the schema to use for the catalog item type property | ||
func catalogItemVersionSchema() *schema.Schema { | ||
return &schema.Schema{ | ||
Type: schema.TypeSet, | ||
Computed: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"created_at": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"description": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func flattenCatalogItemVersions(catalogItemVersions []*models.CatalogItemVersion) []map[string]interface{} { | ||
if len(catalogItemVersions) == 0 { | ||
return make([]map[string]interface{}, 0) | ||
} | ||
|
||
versions := make([]map[string]interface{}, 0, len(catalogItemVersions)) | ||
|
||
for _, version := range catalogItemVersions { | ||
helper := make(map[string]interface{}) | ||
helper["created_at"] = version.CreatedAt.String() | ||
helper["description"] = version.Description | ||
helper["id"] = version.ID | ||
|
||
versions = append(versions, helper) | ||
} | ||
|
||
return versions | ||
} |
Oops, something went wrong.