Overview
While trying to create a VPC, subnet and firewall rules using terraform, the operation fails on subnet and firewall creation, but the VPC network gets created successfully. The following error is observed:
│ Error: Failed to create VPC Subnet
│
│ with crusoe_vpc_subnet.test_vpc_subnet,
│ on main.tf line 22, in resource "crusoe_vpc_subnet" "test_vpc_subnet":
│ 22: resource "crusoe_vpc_subnet" "test_vpc_subnet" {
│
│ There was an error starting a create VPC Subnet operation (453cd9af-c2c5-4e71-a815-bddf560cc2b2): an internal server error occurred
Prerequisites
- Terraform
Cause
Currently, it isn't possible for the Crusoe terraform provider to create subnets and firewall rules concurrently because both resources try to acquire a lease on the same VPC resource.
Solution
- Step 1: Modify terraform to add a
depends_on
property to the subnet and firewall rule resource
resource "crusoe_vpc_network" "test_vpc_network" {
name = "my-new-network"
cidr = "10.0.0.0/8"
}
resource "crusoe_vpc_subnet" "test_vpc_subnet" {
name = "test-new-subnet"
cidr = "10.0.0.0/16"
location = "us-northcentral1-a"
network = crusoe_vpc_network.test_vpc_network.id
depends_on = [crusoe_vpc_network.test_vpc_subnet]
}
resource "crusoe_vpc_firewall_rule" "open_fw_rule" {
network = crusoe_vpc_network.test_vpc_network.id
name = "example-terraform-rule"
action = "allow"
direction = "ingress"
protocols = "tcp"
source = "0.0.0.0/0"
source_ports = "1-65535"
destination = crusoe_vpc_network.test_vpc_network.cidr
destination_ports = "1-65535"
depends_on = [crusoe_vpc_subnet.test_vpc_subnet]
}
- Step 2: Re-run terraform apply
Comments
0 comments
Article is closed for comments.