Summary
When environment scaffolds are created, they point to the wrong region (if not us-east-1) which causes terraform init to fail as it's looking for the state bucket in the wrong place
Steps to repro
Create with original terraform.tvars region set to not us-east-1, attempt to build from env directory
Info
DEP---C02X31PEJGH7:helm agilman$ cat terraform.tfvars
# app/env to scaffold
app = "tides-helm"
environment = "dev"
internal = "false"
container_port = "8080"
replicas = "1"
health_check = "/"
region = "eu-west-1" // <---------------------------
aws_profile = "aws-intl-tides-nonprod:aws-intl-tides-nonprod-admin"
saml_role = "aws-intl-tides-nonprod-admin"
vpc = "vpc-5bedd83d"
private_subnets = "subnet-076a0c61,subnet-327bdb68,subnet-46ed9b0e"
public_subnets = "subnet-076a0c61,subnet-327bdb68,subnet-46ed9b0e"
tags = {
application = "tides-helm"
environment = "dev"
}
DEP---C02X31PEJGH7:helm agilman$ fargate-create
scaffolding tides-helm dev
Looking up AWS Account ID using profile: aws-intl-tides-nonprod:aws-intl-tides-nonprod-admin
downloading terraform template git@github.com:turnerlabs/terraform-ecs-fargate
installing terraform template
...
done
DEP---C02X31PEJGH7:helm agilman$ cat iac/env/dev/main.tf
terraform {
required_version = ">= 0.11.0"
backend "s3" {
region = "us-east-1" // <---------------------------
profile = "aws-intl-tides-nonprod:aws-intl-tides-nonprod-admin"
bucket = "tf-state-tides-helm"
key = "dev.terraform.tfstate"
}
}
# The AWS Profile to use
variable "aws_profile" {}
provider "aws" {
version = ">= 1.53.0"
region = "${var.region}"
profile = "${var.aws_profile}"
}
# output
# Command to view the status of the Fargate service
output "status" {
value = "fargate service info"
}
# Command to deploy a new task definition to the service using Docker Compose
output "deploy" {
value = "fargate service deploy -f docker-compose.yml"
}
# Command to scale up cpu and memory
output "scale_up" {
value = "fargate service update -h"
}
# Command to scale out the number of tasks (container replicas)
output "scale_out" {
value = "fargate service scale -h"
}
# Command to set the AWS_PROFILE
output "aws_profile" {
value = "${var.aws_profile}"
}
Summary When environment scaffolds are created, they point to the wrong region (if not us-east-1) which causes
terraform init
to fail as it's looking for the state bucket in the wrong placeSteps to repro Create with original terraform.tvars region set to not us-east-1, attempt to build from env directory
Info