官术网_书友最值得收藏!

  • AWS Administration Cookbook
  • Lucas Chan Rowan Udell
  • 434字
  • 2021-07-09 18:18:27

Parameters

CloudFormation parameters are the input values you define when creating or updating your stack, similar to how you provide parameters to any command-line tools you might use. They allow you to customize your stack without making changes to your template. Common examples of what parameters might be used for are as follows:

  • EC2 AMI ID: You may wish to redeploy your stack with a new AMI that has the latest security patches installed.
  • Subnet IDs: You could have a list of subnets that an auto scaling group should deploy servers in. These subnet IDs will be different between your dev, test, and production environments.
  • Endpoint targets and credentials: These include things such as API hostnames, usernames, and passwords.

You'll find that there are a number of parameter types. In brief, they are:

  • String
  • Number
  • List
  • CommaDelimitedList

In addition to these, AWS provides some AWS-specific parameter types. These can be particularly handy when you are executing your template via the CloudFormation web console. For example, a parameter type of AWS::EC2::AvailabilityZone::Name will cause the web console to display a drop-down list of valid Availability Zones for this parameter. In the ap-southeast-2 region, the list would look like this:

  • ap-southeast-2a
  • ap-southeast-2b
  • ap-southeast-2c

The list of AWS-specific parameter types is steadily growing and is large enough that we can't list them here. We'll use many of them throughout this book, however, and they can easily be found in the AWS CloudFormation documentation.

When creating or updating a stack, you will need to provide values for all the parameters you've defined in your template. Where it makes sense, you can define default values for a parameter. For example, you might have a parameter called debug that tells your application to run in debug mode. You typically don't want this mode enabled by default, so you can set the default value for this parameter to false, disabled, or something else your application understands. Of course, this value can be overridden when creating or updating your stack.

You can and should provide a short, meaningful description for each parameter. These are displayed in the web console next to each parameter field. When used properly, they provide hints and context to whoever is trying to run your CloudFormation template.

At this point, we need to introduce the inbuilt Ref function. When you need to reference a parameter value, you use this function to do so:

KeyName:
Ref: EC2KeyName

While Ref isn't the only inbuilt function you'll need to know, it's almost certainly going to be the one you'll use the most. We'll talk more about inbuilt functions later in this chapter.

主站蜘蛛池模板: 辛集市| 宁陵县| 苗栗市| 肥乡县| 讷河市| 理塘县| 康马县| 郧西县| 宁津县| 兴隆县| 托克托县| 房山区| 繁峙县| 西城区| 塔河县| 壶关县| 呼图壁县| 饶阳县| 临漳县| 舞钢市| 湟中县| 靖安县| 都江堰市| 淮安市| 冕宁县| 延庆县| 古交市| 富阳市| 镇坪县| 蛟河市| 晋江市| 涟源市| 资中县| 会泽县| 梓潼县| 辰溪县| 靖州| 望都县| 乌鲁木齐市| 望都县| 西吉县|