deployment-automation icon indicating copy to clipboard operation
deployment-automation copied to clipboard

Use AWS region from AWS config by default

Open vuldin opened this issue 3 years ago • 3 comments

Read from ~/.aws/config to get user's default region rather than hard-coding aws_region to us-west-2.

vuldin avatar Oct 17 '22 14:10 vuldin

This will require making AMI IDs dynamic based on region.

vuldin avatar Oct 17 '22 15:10 vuldin

This is an example of a dynamic AMI data object:

data "aws_ami" "ubuntu" {
  most_recent = true

  filter {
    name   = "name"
    values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
  }

  filter {
    name   = "virtualization-type"
    values = ["hvm"]
  }

  owners = ["099720109477"] # Canonical
}

More details here: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#example-usage

vuldin avatar Oct 17 '22 16:10 vuldin

Many users do not use ~/.aws/config, and others do not want their infrastructure built in their default region. For instance my default region in ~/.aws/config is us-east-2, but I only build in us-west-2 as that is where most people in the org are.

IMO if a user wants to have a default region they should use the canonical AWS_DEFAULT_REGION

gene-redpanda avatar Jun 06 '23 19:06 gene-redpanda