Closed sudhaku closed 5 years ago
If I create new InternetGateway resources, the same code works just fine.
resource "oci_core_internet_gateway" "InternetGateway1" {
count = "${var.environment == "unstable" ? 0 : 1}"
compartment_id = "${var.compartment_id}"
vcn_id = "${var.vcn_id}"
display_name = "internet-gateway1"
}
resource "oci_core_route_table" "RouteTable" {
count = "${var.environment == "unstable" ? 0 : 1}"
compartment_id = "${var.compartment_id}"
vcn_id = "${var.vcn_id}"
display_name = "route-table"
route_rules {
destination = "0.0.0.0/0"
network_entity_id = "${oci_core_internet_gateway.InternetGateway1[0].id}"
}
}
So it seems like new syntax is not working for existing state. I faced same issue with resources like load_balancer and load_balancer_backendset.
Hi @sudhaku,
Thanks for filing the issue. The alpha4 release is now quite out of date. If you're testing providers, it's recommended to use the latest master branch.
The error you show has been updated for this situation, and looks more like:
Error: Missing resource instance key
on main.tf line 12, in resource "null_resource" "b":
12: network_entity_id = oci_core_nat_gateway.InternetGateway.id
Because oci_core_nat_gateway.InternetGateway has "count" set, its attributes must be accessed on
specific instances.
For example, to correlate with indices of a referring resource, use:
oci_core_nat_gateway.InternetGateway[count.index]
And this issue of referencing a disabled resource is not reproducible on master. If you still have an problem with the current version, feel free to update this and we can re-open the issue.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Terraform Version
Terraform Configuration Files
I get this error on terraform plan:
Tried changing the template like below:
Now see this error on terraform plan:
How can I fix this issue?