Closed ichung08 closed 6 months ago
So this is a limitation of the API and the cloud providers. Creating multiple clusters in the same cloud provider at close to the same time may run into errors, especially on AWS. One workaround is to do something like this where you delay the create
API call by adding a time_sleep
resource like so:
terraform {
required_providers {
astro = {
source = "astronomer/astro"
version = "0.1.0-alpha"
}
time = {
source = "hashicorp/time"
version = "0.11.1"
}
}
}
provider "astro" {
organization_id = "XXX"
}
resource "astro_cluster" "team_1_cluster" {
type = "DEDICATED"
name = "team-1-gcp-cluster-test"
region = "us-east4"
cloud_provider = "GCP"
db_instance_type = "Small General Purpose"
vpc_subnet_range = "172.20.0.0/20"
pod_subnet_range = "172.21.0.0/19"
service_peering_range = "172.23.0.0/20"
service_subnet_range = "172.22.0.0/22"
workspace_ids = []
timeouts = {
create = "3h"
update = "2h"
delete = "30m"
}
}
resource "time_sleep" "wait_3_minutes" {
create_duration = "3m"
}
resource "astro_cluster" "team_2_cluster" {
type = "DEDICATED"
name = "team-2-gcp-cluster-test"
region = "us-east4"
cloud_provider = "GCP"
db_instance_type = "Small General Purpose"
vpc_subnet_range = "172.20.0.0/20"
pod_subnet_range = "172.21.0.0/19"
service_peering_range = "172.23.0.0/20"
service_subnet_range = "172.22.0.0/22"
workspace_ids = []
timeouts = {
create = "3h"
update = "2h"
delete = "30m"
}
depends_on = [time_sleep.wait_3_minutes]
}
Here, we will wait a few minutes before creating the second cluster. After it is done being created, you should be able to safely remove the resource "time_sleep"
from your terraform file and use the file as normal again
Describe the bug
Unable to create multiple clusters in the same
main.tf
file when runningterraform apply
. Only the first cluster in themain.tf
file is created, and the other clusters fail immediately.Error Message:
What Terraform Provider Version and Terraform Version did you experience this bug? Latest
What Operating System is the above Terraform Provider installed on? macOS
🪜 Steps To Reproduce
Run
terraform apply
with the following inmain.tf
:📸 Screenshots