Running an initial apply runs successfully. Running apply afterwards tries to replace the just created VPC, which causes terraform to hang if there are resources (like instances) using the VPC.
vpc-test$ make apply
# Perform an initial init with the workspace seeded
if [ ! -f .terraform/terraform.tfstate ]; then \
/usr/bin/terraform init -input=false; \
fi
# Always ensure we're in the correct workspace.
/usr/bin/terraform workspace select -or-create develop
# Run init again even if Terraform has already been init but only check for
# child module changes (so iteration is faster while developing)
/usr/bin/terraform init -input=false -backend=false
Initializing provider plugins...
- Reusing previous version of vultr/vultr from the dependency lock file
- Using previously-installed vultr/vultr v2.17.0
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
/usr/bin/terraform apply -var-file=global.tfvars -var-file=develop.tfvars
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
+ create
Terraform will perform the following actions:
# vultr_vpc2.test will be created
+ resource "vultr_vpc2" "test" {
+ date_created = (known after apply)
+ description = "terraform test"
+ id = (known after apply)
+ region = "nrt"
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions in workspace "develop"?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
vultr_vpc2.test: Creating...
vultr_vpc2.test: Creation complete after 1s [id=5fd997d8-9cc2-4e41-8405-a543b113f97a]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
vpc-test$ make apply
# Perform an initial init with the workspace seeded
if [ ! -f .terraform/terraform.tfstate ]; then \
/usr/bin/terraform init -input=false; \
fi
# Always ensure we're in the correct workspace.
/usr/bin/terraform workspace select -or-create develop
# Run init again even if Terraform has already been init but only check for
# child module changes (so iteration is faster while developing)
/usr/bin/terraform init -input=false -backend=false
Initializing provider plugins...
- Reusing previous version of vultr/vultr from the dependency lock file
- Using previously-installed vultr/vultr v2.17.0
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
/usr/bin/terraform apply -var-file=global.tfvars -var-file=develop.tfvars
vultr_vpc2.test: Refreshing state... [id=5fd997d8-9cc2-4e41-8405-a543b113f97a]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
# vultr_vpc2.test must be replaced
-/+ resource "vultr_vpc2" "test" {
~ date_created = "2023-10-30T08:17:58+00:00" -> (known after apply)
~ id = "5fd997d8-9cc2-4e41-8405-a543b113f97a" -> (known after apply)
- ip_block = "10.25.96.0" -> null # forces replacement
- prefix_length = 20 -> null # forces replacement
# (2 unchanged attributes hidden)
}
Plan: 1 to add, 0 to change, 1 to destroy.
Do you want to perform these actions in workspace "develop"?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: no
Apply cancelled.
make: *** [Makefile:75: apply] Error 1
Expected behavior
With no changes, a second execution of terraform should not try to replace the vultr_vpc2 resource.
Describe the bug
vultr_vpc2
resource is not idempotent whenip_block
andprefix_length
are not specified in the configuration.To Reproduce
Using the following terraform file:
Running an initial apply runs successfully. Running apply afterwards tries to replace the just created VPC, which causes terraform to hang if there are resources (like instances) using the VPC.
Expected behavior
With no changes, a second execution of terraform should not try to replace the
vultr_vpc2
resource.Environment: