Closed codylcarlson closed 3 years ago
To close the loop:
Issue identified as a problem between updated code and older releases of vRA (pre 8.5). This is not an issue in vRA 8.5+ Workaround is to download the 0.3.9 release, place it in your terraform.d/plugins directory and then specify it in your tf file (shown below). Then init and try again.
terraform { required_providers { vra = { source = "terraform-providers/vra" version = "0.3.9" } } }
(Updated to simplify)
Description:
I have several scripts that used to work for creating Cloud Accounts and associated Zones. They do not work any longer because they are all unable to locate the regions associated with the Cloud Accounts after the CA's have been created.
Troubleshooting:
I have tried several different vRA targets (8.3/8.4), upgraded to vRA provider 4.0 plugin, updated to Terraform 1.0.9, and even tried a new windows PC. I have also tried using the supplied example files for zone creation (populated with correct values in the tfvars) and it also fails at the same point. I receive the same error for GCP, vSphere, and AWS Region collection (all of which worked at some time in the past).
Error:
**vra_cloud_account_aws.this: Refreshing state... [id=e4ab2649-c001-49e7-b3d3-0324e1919172] Error: region us-east-2 not found
with data.vra_region.aws, on main.tf line 30, in data "vra_region" "aws": 30: data "vra_region" "aws" {**
Versions:
vRA 8.4 Terraform v1.0.9 on windows_amd64
Main.tf example
provider vra { url = var.vra_url refresh_token = var.vra_refresh_token insecure = true }
data "vra_data_collector" "dc" { count = var.datacollector != "" ? 1 : 0 name = var.datacollector }
resource "vra_cloud_account_aws" "this" { name = "Cody's Personal AWS Account" description = "Created using the vRA Provider for Terraform" access_key = var.access_key secret_key = var.secret_key regions = "us-east-2" }
data "vra_region" "aws" { cloud_account_id = vra_cloud_account_aws.this.id region = var.region }
resource "vra_zone" "aws" { name = "Cody's Private AWS Zone" description = "Created using the vRA Provider for Terraform" region_id = data.vra_region.aws.id }
Terraform.tfvars (for related variable):
I get the same error even if I hard code "us-east-2" in the data section for vra_region.aws) region = "us-east-2"
Terraform.tfstate file (after Cloud Account is created):
Below you can see that the region is correctly listing as us-east- { "mode": "managed", "type": "vra_cloud_account_aws", "name": "this", "provider": "provider[\"registry.terraform.io/terraform-providers/vra\"]", "instances": [ { "schema_version": 0, "attributes": { "access_key": "AKIAI3SJCJPWR4YRKJ6Q", "created_at": "2021-10-14", "description": "Created using the vRA Provider for Terraform", "id": "e4ab2649-c001-49e7-b3d3-0324e1919172", "links": [ { "href": "", "hrefs": [ "/iaas/api/regions/94501348-edcb-48e4-b8cf-93520b63d20c" ], "rel": "regions" }, { "href": "/iaas/api/cloud-accounts/e4ab2649-c001-49e7-b3d3-0324e1919172", "hrefs": [], "rel": "self" } ], "name": "Cody's Personal AWS Account", "org_id": "e347735c-a887-41da-97c7-14c173f64a1e", "owner": "", "region_ids": [ "94501348-edcb-48e4-b8cf-93520b63d20c" ], "regions": [ "us-east-2" ], "secret_key": "Kj6VaOe394nYub3l8JrTQ5QUgOyTdwwc1XyTJX42", "tags": [], "updated_at": "2021-10-14" }, "sensitive_attributes": [], "private": "bnVsbA==" } ] }