Packer 1.7.8
I have a shell script that contains a command that makes a list
AWS_REGIONS=$(aws ec2 --region=us-east-1 describe-regions | jq -r '.Regions[].RegionName' | awk '{ print "\""$0"\""}' | paste -sd "," - )
and its set as an env variable.
then packer is supposed to pick the list up and use it for ami_regions
in an amazon-ebs
block.
it does this in a variable like so
variable "aws_ami_regions" {
default = [ env("AWS_REGIONS") ]
}
this fails with a misleading error
* Error Copying AMI (ami-123456789) to region ("af-south-1","eu-north-1","ap-south-1","eu-west-3","eu-west-2","eu-west-1","ap-northeast-3","ap-northeast-2","ap-northeast-1","sa-east-1","ca-central-1","ap-southeast-1","ap-southeast-2","eu-central-1","us-east-1","us-east-2","us-west-1","us-west-2"): MissingEndpoint: 'Endpoint' configuration is required for this service
I have tried different ways of formatting the list and all fail.
if i take the list directly from the error and paste it into the variable, it works.
variable "aws_ami_regions" {
default = [ "af-south-1","eu-north-1","ap-south-1","eu-west-3","eu-west-2","eu-west-1","ap-northeast-3","ap-northeast-2","ap-northeast-1","sa-east-1","ca-central-1","ap-southeast-1","ap-southeast-2","eu-central-1","us-east-1","us-east-2","us-west-1","us-west-2" ]
}
i tried passing it through with:
packer build -var AWS_REGIONS="$AWS_REGIONS"