Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudFormer-generated template failing when running in other region

I have a CloudFormer instance set up in one of my regions. I generate a template for one of my instance (including VPC, security groups, ...) I then try to create a stack in another region by making sure i'm switching the availability zones to the new regions (us-east-1a -> us-west-1a, etc), but I run into the following error when it's trying to create the EC2 instance: The image id '[ami-xxxxxxxx]' does not exist.

Do I need to manually copy the images to the other region first? Is there a way to do this with the cloudformer-generated template? How would the template figure out where this AMI is coming from?

Thank you,

like image 380
Loic Duros Avatar asked Dec 14 '25 03:12

Loic Duros


1 Answers

You must copy the AMI to each region you want to use it. This functionality is available in the AWS Console. Select the AMI and the option to copy it to another region is presented. See the AWS provided instructions.

There is no way to have a template discover that there is no AMI in a region and then copy the ami to the desired region.

To specify which AMIs go with which regions, you should specify a mapping (from AWS Cloudformation example template):

"Mappings" : {
"AWSInstanceType2Arch" : {
  "m1.small"   : { "Arch" : "64" },
  "m1.medium"  : { "Arch" : "64" },
  "m1.large"   : { "Arch" : "64" },
  "m1.xlarge"  : { "Arch" : "64" },
  "m2.xlarge"  : { "Arch" : "64" },
  "m2.2xlarge" : { "Arch" : "64" },
  "m2.4xlarge" : { "Arch" : "64" },
  "c1.medium"  : { "Arch" : "64" },
  "c1.xlarge"  : { "Arch" : "64" }
},
"AWSRegionArch2AMI" : {
  "us-east-1"      : {"64" : "ami-7614ac1e"},
  "us-west-1"      : {"64" : "ami-2f43566a"},
  "us-west-2"      : {"64" : "ami-e5f7bbd5"},
  "eu-west-1"      : {"64" : "ami-32228e45"},
  "ap-southeast-1" : {"64" : "ami-c6634294"},
  "ap-southeast-2" : {"64" : "ami-995c31a3"},
  "ap-northeast-1" : {"64" : "ami-73d0e672"},
  "sa-east-1"      : {"64" : "ami-77a1156a"}
}

},

The mappings section is usually found right after the Parameters section.

Then you reference your ami as follows:

"ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
                  { "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
like image 65
Edwin Avatar answered Dec 16 '25 02:12

Edwin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!