简体   繁体   中英

How to upgrade EC2 instance in CloudFormation WordPress sample template from T1/M1 to T2?

I'm looking at https://s3-us-west-2.amazonaws.com/cloudformation-samples-us-west-2/WordPress_Simple.template

As far as I can tell, this template is used for CloudFormation stack creation when selecting the WordPress Blog sample template option in the AWS console as in…

Console home > Cloud formation > Actions > Create stack > Source > Select a sample template > WordPress Blog

As far as I can tell, when I use this template to create a stack, the corresponding EC2 instance will be of type T1 or M1 .

How can I go about tweaking this template so that the EC2 that's created is of type t2.micro ?

The key insight is that this template was written before t2.micro 's even existed, which is why it doesn't handle the case. But there is nothing inherent about the code that prevents it.

So, looking at the code, you can see that there are 2 locations where t1.micro is used:

  1. As a valid option for a parameter
  2. In a mapping of architectures

To add t2.micro as a valid option, you can just add it to the list:

"AllowedValues" : [ "t1.micro", "t2.micro", ...],

To add t2.micro to the mapping, just add a new line for it:

"AWSInstanceType2Arch" : {
  "t1.micro"    : { "Arch" : "64" },
  "t2.micro"    : { "Arch" : "64" },
  "m1.small"    : { "Arch" : "64" },

If you want to get more accurate, I'd actually take a look at one of the current templates , which has a much more comprehensive list of all the instance types and the correct AWS Linux AMIs.

The reason that sample Cloudformation template doesn't include t2.* instances is because they are only valid within a VPC .

In order to get the instance to be a t2 you would have to launch it to a running VPC, or first create a VPC, subnet, gateway, routing either in the Cloudformation template or through the AWS Console / API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM