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

A closer look at CloudFormation templates

CloudFormation templates consist of a number of parts, but these are the four we're going to concentrate on:

  • Parameters
  • Resources
  • Outputs
  • Mappings

Here's a short YAML example:

AWSTemplateFormatVersion: '2010-09-09' 
Parameters:
EC2KeyName:
Type: String
Description: EC2 Key Pair to launch with
Mappings:
RegionMap:
us-east-1:
AMIID: ami-9be6f38c
ap-southeast-2:
AMIID: ami-28cff44b
Resources:
ExampleEC2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.nano
UserData:
Fn::Base64:
Fn::Sub': |
#!/bin/bash -ex
/opt/aws/bin/cfn-signal '${ExampleWaitHandle}'
ImageId:
Fn::FindInMap: [ RegionMap, Ref: 'AWS::Region', AMIID ]
KeyName:
Ref: EC2KeyName
ExampleWaitHandle:
Type: AWS::CloudFormation::WaitConditionHandle
Properties:
ExampleWaitCondition:
Type: AWS::CloudFormation::WaitCondition
DependsOn: ExampleEC2Instance
Properties:
Handle:
Ref: ExampleWaitHandle
Timeout: 600
Outputs:
ExampleOutput:
Value:
Fn::GetAtt: ExampleWaitCondition.Data
Description: The data signaled with the WaitCondition
主站蜘蛛池模板: 仙桃市| 安陆市| 苗栗市| 和田县| 广河县| 峨山| 随州市| 屏东市| 长顺县| 任丘市| 自贡市| 双辽市| 彭州市| 且末县| 茶陵县| 武宣县| 铁岭县| 乃东县| 博罗县| 贵阳市| 宁强县| 丘北县| 托里县| 沙坪坝区| 成都市| 石城县| 铜鼓县| 沂源县| 东源县| 醴陵市| 利辛县| 三门县| 泗水县| 安丘市| 舞钢市| 平定县| 玉树县| 昂仁县| 英德市| 西城区| 仁怀市|