Use AWS region from AWS config by default
Read from ~/.aws/config to get user's default region rather than hard-coding aws_region to us-west-2.
This will require making AMI IDs dynamic based on region.
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
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