æ¬èšäºã§ã¯ç§ãªãã® CloudFormation ãå°ãã§ã楜ã«ã¡ã³ãããããŠããŠã説æããŸãã
- AWS CloudFormation ã® (ç§ãªãã®) äœæã»ã¡ã³ãæé
- Templateãã¡ã€ã«ãã©ããã£ãŠæžãã
- ã¹ã¿ãã¯ã®äœæãæŽæ°æé
- ãã¹ãã»CIã»åäœç¢ºèªã®æµã
- AWS CloudFormation ã®çµã¿èŸŒã¿é¢æ°
- AWS CloudFormation Change Sets
- AWS CloudFormation Cross Stack Reference
- AWS ã®èª¬æ
- ããããã AWS ã觊ããã§ãïŒããšããæ¹ã«ã¯è²ã ãšèª¬æäžè¶³ãªç¹ããããšæããŸãããäºæ¿äžãã
- CloudFormation ãã«ããŒã¹ã¯ãªãã
cfn-init
ãšãcfn-signal
ãªã©- ç§ã«ã¯ãã¹ããã©ã¯ãã£ã¹ã説æã§ããèªä¿¡ããªãã®ã§çããŠããŸã1
- CloudFormation StackSets
- AWS CloudFormation ã«ã¹ã¿ã ãªãœãŒã¹
- CloudFormationãæäœããæš©é管ç
- äŸãã°ãCloudFormationã®æäœã¯ããŠãè¯ããã©ãEC2ãS3ãªã©ã«ã¯çŽæ¥è§Šã£ãŠã»ãããªãå Žåã®IAMèšå®æ¹æ³
- IAMèšèšã絡ããšæ¬èšäºã§ã¯æ±ããããªãã®ã§è§ŠããŸãã
- 代æ¿ããŒã«ãšã®æ¯èŒ
- Terraform ã
awscli
以å€ã®CLIããŒã«ã«ã¯è§ŠããŸãã
- Terraform ã
CloudFormation 㯠Template ãã¡ã€ã«ãæžããªããã°äœãå§ãŸããŸããã æžãã«ããã£ãŠã®ãªã¹ã¹ã¡ã説æããŸãããã
CloudFormationã®Templateãã¡ã€ã«ã¯Yamlã§æžãããšãåºæ¥ãŸãã2 æžããŸããããJsonã䜿ãã¡ãªããã¯ãããŠãããŸãããé
åã®æåŸã« ,
ãæžããŠããŸã£ãŠFormatãšã©ãŒã«ãªãæ¥ã
ãããããéžã¶å¿
èŠã¯ãªãã®ã§ãã
Yamlã¯Jsonãšéã£ãŠã³ã¡ã³ããæžããŸãã ããã°ã©ãã³ã°ãšåæ§ãTemplateãèŠãã ãã§ã¯åãããªãæ å ±ãè£å®ããŠããªããã®èšå®ãªã®ãããåããããã«ãããšåœ¹ã«ç«ã€ã§ãããã
Resources:
# ãŠãŒã¶ãŒãã¢ããããŒãããç»åã®ä¿åå
S3
S3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
# ãŠãŒã¶ãŒãã¢ããããŒãããç»åã¯å
¬éããã
# ãããå
¬éã»éå
¬éãå¶åŸ¡ã§ããããã«ãã
AccessControl: PublicRead
LifecycleConfiguration:
Rules:
# ä¿ææéã¯1æ¥
- Status: Enabled
ExpirationInDays: 1
Yamlã«ã¯ã¢ã³ã«ãŒã»ãšã€ãªã¢ã¹æ©èœãããã®ã§ãããCloudFormationã®TemplateãšããŠã¯äœ¿ããŸããã
äŸãã°æ¬¡ã®ããã« Subnet
ã®å®çŸ©ã§å
±ééšåïŒäŸãã° VpcIdã®éšåïŒã䜿ãåããããªYamlãæžããŠããCloudFormationã§ã¯äœ¿ããŸããã
次ã®ããã«ã¢ã³ã«ãŒã䜿ã£ãŠãã
Resources:
PublicSubnetAZ1: &PublicSubnet
Type: 'AWS::EC2::Subnet'
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 0, !GetAZs "" ]
CidrBlock: !Ref PublicSubnetAZ1Cidr
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: public-subnet-AZ1
PublicSubnetAZ2:
<<: * PublicSubnet
Properties:
AvailabilityZone: !Select [ 1, !GetAZs "" ]
CidrBlock: !Ref PublicSubnetAZ2Cidr
Tags:
- Key: Name
Value: public-subnet-AZ2
aws cloudformation validate-template å®è¡æã«ãšã©ãŒãšãªããŸãã
An error occurred (ValidationError) when calling the ValidateTemplate operation: Template error: YAML aliases are not allowed in CloudFormation templates
ã¢ã³ã«ãŒã»ãšã€ãªã¢ã¹ã䜿ãããå Žå㯠Ruby ãªã©ã§å€æããå¿ èŠããããŸãã
CloudFormationã®Templateãå¢ãããšã䌌ãéšåãå€ãåºãŠããããã«ãªããããããŸããã ãããã䌌ãŠãããã©éããã®ããªãè¯ãã®ã§ãããåãæ å ±ãæããã®ãã§ãããšãããã«ã¡ã³ããçºçããŠã¡ã³ãæ§ã«æ¬ ããŠããŸãã§ããããã©ã¡ããäžæ¹ãå€æŽããããäžæ¹ãå€æŽãå¿ããããšãããããã¡ãªãã¹ãçºçãããç¶æ ã§ãã
æéçãšããŠãå ±ééšåãå¥ãã¡ã€ã«ã«ããŠããŸãæ¹æ³ããããŸãã
# _ec2 ãš _vpc ã®å
±éå±€ã _common ã«ãŸãšãããšããã
$ ls -1
_common.template.yaml
_ec2.template.yaml
_vpc.template.yaml
# ãããªæãã§åäœããã
$ ruby -ryaml -ractive_support -e 'puts YAML.dump( YAML.load_file(ARGV[0]).deep_merge(YAML.load_file(ARGV[1])) )' _common.template.yaml _ec2.template.yaml > ec2.template.yaml
ãã®äŸã®å ŽåãRubyãçµç±ããããšã«ããå¯æ¬¡çå¹æãšããŠYamlã®ã¢ã³ã«ãŒã»ãšã€ãªã¢ã¹ã䜿ãããšãã§ããŸãã ãããäžæ¹ã§ãåŸè¿°ãã Yaml ã®ç瞮圢æ§æã¯äœ¿ããŸãããç瞮圢æ§æã¯Yamlã®ã¿ã°æ©èœ3ã䜿ã£ãŠããã®ã§ããããã®ã¿ã°ã¯AWSç¬èªã®ã¿ã°ãªã®ã§ãRubyã«èªã¿èŸŒãŸããæç¹ã§ç¡èŠãããç¡ããªã£ãŠããŸãã®ã§ãã
ããããã¯å人ã®è¶£å³ã®è©±ã«ãªããšæããŸãããç§ã¯ CloudFormation ãããã°ã©ããã«ã«ã¡ã³ãããã®ã¯ãããã£ãŠå¹çãæªããšèããŠããŸãã4 çç±ã¯ããŸãïŒã€ã«CloudFormationã觊ããšã³ãžãã¢ãããã°ã©ããŒãšã¯éããªãããšããã®ãã®ã§ãã ãããŠãããïŒã€ããCloudFormation Templateã¯èšèšå³ã§ããããã®èšèšå³ã¯ä»ã®èšèšå³ãšãªãã¹ãççµåã«ããŠãããæ¹ããå 容ã®ææ¡ã»ä¿®æ£ã容æã«ãªããšèããŠããããã§ããèšèšå³ã®çµã¿æ¹ããã€ãã®ãã¬ãŒãºãªã©ãéå»ãã䜿ããŸããã®ã¯è¯ãã§ãããããèšèšå³ãå€æŽãããå¥ã®èšèšå³ã«ã圱é¿ãåºãããšããã®ã¯é¿ããã¹ãã§ããããã°ã©ãã³ã°ãªãã°ãççµåã«ãã€ã€å ±éåãããããã¶ã€ã³ããããèãããšããã§ãããCloudFormationã§ãããŸã§ããã¡ãªãããæãããŠããã®ãæ©ãŸãããšããã§ããå ±éåããã«è¶ããããšã¯ãªããé 匵ã£ãŠããã»ã©ã§ããªãããšããã®ãç§ã®èãã§ãã
ãã®ãããTemplateãã¡ã€ã«ã¯å€å°åããããªèšè¿°ããã£ãŠãããã«ã¡ã³ãèŠæã§ç®¡çãã代ããã«ããŒã«ãé§äœ¿ããŠã¡ã³ãæŒãã«æ°ä»ãã工倫ãããæ¹ã«ã³ã¹ããå²ãããã«ããŠããŸãã
次ã®äŸã¯ãec2.template.yaml 㯠ci ç°å¢çšã®Parameterãèš±å¯ããŠããã確èªããç°¡åãªã¹ã¯ãªããã§ãã
$ ruby -ryaml -e 'raise "should be allowed ci environment" unless YAML.load_file(ARGV[0])["Parameters"]["Environment"]["AllowedValues"].include?("ci")' ec2.template.yaml
-e:1:in `<main>': should be allowed ci environment (RuntimeError)
ããããŠããã°ããµãŒãã¹ã®èŠæš¡ã倧ãããªã£ãŠCloudFormationã®å ±ééšåãè¥å€§åããã®ã§ããå æžãŸãšããããªã£ãæã«ãããã®ãã¹ããæµããŠç¢ºèªããªãã移è¡ããããšãå¯èœã«ãªããŸãã5
çµå±ãããã°ã©ã ã§ãã¹ãããŠããããªããããšããææãåãããããããŸããããYamlãã«ã¹ã¿ã ã§ããä»çµã¿ãèªåãã¡ã§äœãããšãšãYamlã®èšè¿°å 容ããã¹ãããã¹ã¯ãªãããæžãããšã§ã¯ãåŸè ã®æ¹ãæ·å± ãäœãåãå ¥ãããããšæãã®ã§ãã
ã¡ãªã¿ã«ãTemplateã®äžã§Stackãäœæããããšãã§ããŸãã6 Stackã®ãã¹ãã§ããäœæãããªãœãŒã¹ã®å ±éåãšããŠæ€èšã§ãããšæããŸãããç§ã¯Stackã®ç®¡çãé£ãããªããããªæ°ãããŠäœ¿ã£ãŠããŸãããç¹ã«ãè€æ°ã®èŠªStackãã䜿ãããTemplateãã¡ã€ã«ã®ç®¡çãè€éã«ãªãããã§ãã
AWS CloudFormation ã§ã¯ãããã€ãåºæã®ãã©ã¡ãŒã¿ãé¢æ°ãçšæãããŠããŸãã
æ©èœã®è©³çŽ°ã¯åŸè¿°ããŸãã Fn::If
ãšã Fn::Sub
ãšãã£ããã®ã§ãã
ããã㯠!If
ã !Sub
ãšèšè¿°ããããšãã§ãããããç瞮圢æ§æãšåŒã³ãŸããã©ã¡ãã䜿ã£ãŠãæå³ã¯åãã§ãããç瞮圢æ§æã®æ¹ãæåéãçãèšè¿°ãã§ããã®ã§ãç§ã¯å¥œãã§äœ¿çšããŠããŸãã
# ããããåãæå³
Fn::If: [ A, 1, 2 ]
!If [ A, 1, 2 ]
Fn::Sub: "myapp-${AWS::Region}"
!Sub "myapp-${AWS::Region}"
AWS CloudFormation Designer 㯠2015/10 ãã䜿ããããã«ãªã£ãæ©èœã§ããCloudFormation ã® Template ã®å 容ãç解ããããã«ãããã»ã©äŸ¿å©ãªæ©èœã¯ãããŸããããã²æŽ»çšããŸãããã å®éã«ãç§ã¯ãã®æ©èœãæçšããŠããŸããCloudFormation Designer ããªãªãŒã¹ããããŸã§ããã®TemplateãäœãAWSãªãœãŒã¹çŸ€ã®èšèšå³ãåºåã§ãããè¯ãã®ã«ããšäœåºŠæã£ãããšãã
CloudFormation ã§ã§ããããšã¯ãèšã£ãŠããŸãã°ãAWS ã®ãªãœãŒã¹ãäœãããšãšãäœã£ããªãœãŒã¹ãšãªãœãŒã¹ãé¢é£ä»ããããšã§ããç¹ã«ããªãœãŒã¹ãšãªãœãŒã¹ãé¢é£ä»ããŠãããšãTemplateãã¡ã€ã«ã¯è€éåããã©ã®ãªãœãŒã¹ãã©ãã«äŸåããŠããã®ãè¿œããããã®ã倧å€ã§ãã
ããã CloudFormation Designer ã䜿ãã° Template ãã¡ã€ã«å ã§å®çŸ©ãããªãœãŒã¹ã®é¢ä¿ãGUIã§ç¢ºèªã§ããããã«ãªããŸãã
AWS CloudFormation Designer ã¯æ¢åã®Templateãç解ããããã ãã§ãªããæ°ããTemplateãã¡ã€ã«ãäœæããæã«ã䜿ããŸããCloudFormationã«æ £ããŠããªãæ¹ã¯ããããªãããã¹ããšãã£ã¿ãŒãéãããAWS CloudFormation Designer ã䜿ã£ãŠTemplateãã¡ã€ã«ãäœã£ãã»ãã楜ãããããŸãããAWS CloudFormation Designer ã¯è£å®æ©èœãåããŠããã®ã§ããããªãã«å¿«é©ãªäœæ¥ãã§ããŸãã7
äžæ¹ã§ AWS CloudFormation Designer ã䜿ããšã Metadata
ãšããæ
å ±ã Template ãã¡ã€ã«ã«è¿œå ãããŠããŸããŸããããã¯ãDesigneräžã®ãªãœãŒã¹ã®è¡šç€ºäœçœ®ãä¿æããŠããŠãã¡ãã£ãšäœçœ®ãå€ããã ã㧠Metadata
ãå€åãããããããŒãžã§ã³ç®¡çããŒã«ã䜿ã£ãŠãããšå·®åãšããŠåºãŠããŠããŸããŸããããã®å·®åã¯äœã ã£ã...ãã Metadata ãããšããç¡é§ãªäœæ¥ã¯ããããããŸããã
ãã®ããç§ã¯ Templateã®æ§æç解ã®ããã« Designer ã䜿ããTemplateãã¡ã€ã«ã®äœæãä¿®æ£èªäœã¯ææ
£ããããŒã«ã§è¡ãããšããæ¹éã«ããŠããŸãã
CloudFormation ã§ã§ããããšã¯ãèšã£ãŠããŸãã°ãAWS ã®ãªãœãŒã¹ãäœãããšãšãäœã£ããªãœãŒã¹ãšãªãœãŒã¹ãé¢é£ä»ããããšã§ããç¹ã«ããªãœãŒã¹ãšãªãœãŒã¹ãé¢é£ä»ããŠãããšãTemplateãã¡ã€ã«ã¯è€éåããã©ã®ãªãœãŒã¹ãã©ãã«äŸåããŠããã®ãè¿œããããã®ã倧å€ã§ããããã CloudFormation Designer ã䜿ãã° Template ãã¡ã€ã«å ã§å®çŸ©ãããªãœãŒã¹ã®é¢ä¿ãGUIã§ç¢ºèªã§ããããã«ãªããŸãã
Yamlã®ç瞮圢æ§æã§ãè¿°ã¹ãããã«ã CloudFormationã«ã¯åºæã®ãã©ã¡ãŒã¿ãèšæ³ãååšããŸãããããã掻çšããããšã§ãããçšåºŠã¯ããã°ã©ããã«ãªåŠçãèšè¿°ããããšãã§ããŸãã詳ããã¯å ¬åŒããã¥ã¡ã³ããåç §é ããšããŠãç§ãã©ã®ããã«æŽ»çšããŠããã玹ä»ããŸãã
ãŸãã¯CloudFormationã®çµã¿èŸŒã¿é¢æ°ãšç䌌ãã©ã¡ãŒã¿ãç°¡åã«çŽ¹ä»ããŠããã®åŸç°¡åãªãµã³ãã«ãäŸç€ºããªãã説æããŸãã
çµã¿èŸŒã¿é¢æ°ã¯çŸæç¹ã§11çš®é¡ãããŸãã8 æ¡ä»¶é¢æ°ã«ã¯ããã«äœçš®é¡ãããã®ã§ãå®éã¯11çš®é¡ããå€ãã§ãã ãããã®é¢æ°ãããã°ã©ããŒã®èŠç¹ã§åé¡ããŠã¿ãŸãã
- æ¡ä»¶åå²
- æååæäœç³»
Fn::Base64
äžããããæååãBase64ããFn::Join
äžããããé åãåºåãæåã§é£çµãã
["a", "b"].join("-")
ã®ãããªæãFn::Split
äžããããæååãåºåãæåã§åå²ããŠé åã«ãã
"a-b".split("-")
ã®ãããªæãFn::Sub
Rubyã§èšããš"hoge-#{val}-fuga
ã®ãããªæååãå®çŸ©ããval
ã«ä»£å ¥ãããŠããå€ã§æååãäœãããšãã§ãã
- é
åæäœç³»
Fn::Join
äžããããé åãåºåãæåã§é£çµãã
["a", "b"].join("-")
ã®ãããªæãFn::Select
äžããããé åãããäžããããæ·»åã®å€ãååŸãã
arr[0]
ã®ãããªæãFn::Split
äžããããæååãåºåãæåã§åå²ããŠé åã«ãã
"a-b".split("-")
ã®ãããªæã
- AWS CloudFormation ç¹æã®ãã®
Fn::FindInMap
Mappings
ã§å®çŸ©ããå€ãåç §ããéã«äœ¿çšããFn::GetAtt
AWSãªãœãŒã¹ãæå®ããŠããªãœãŒã¹ããArnãªã©ã®å€ãååŸããFn::GetAZs
æå®ããRegionãæã€AvailabilityZoneã®é åãååŸããFn::ImportValue
Cross-stack referenceã«ããå¥Stackã§Exportããå€ãååŸããRef
Parameters
åã³Resources
ã§å®çŸ©ããå€ãååŸããéã«äœ¿çšãã
ç¹ã«Resources
ã§å®çŸ©ããå€ãæå®ããå Žåã¯ãã©ã®ãããªå€ãååŸãããã¯ãªãœãŒã¹ã«ãã£ãŠå€ãã
ã©ãã䟿å©ãªé¢æ°ã§ããç¹ã« Ref
ã¯äœ¿ããã«ããæ¹ãé£ããé¢æ°ã§ãããã
ãŸãã!Sub
ã¯æ¯èŒçæ°ããé¢æ°9ãªã®ã§å€ãèšäºã§ã¯èŠã€ãããªããããããŸãããããããããªã䟿å©ãªé¢æ°ã§ãããã²æŽ»çšããŸãããã
ç䌌ãã©ã¡ãŒã¿10 ã¯ãããšãããªãCloudFormationãæã€ã°ããŒãã«å€æ°ã®ãããªãã®ã§ããã©ã®CloudFormationã§ããç¹ã«äœã®åæºåãç¡ãã«åç
§ã§ãããã©ã¡ãŒã¿ã§ãã
çŸæç¹ã§ã¯æ¬¡ã®5çš®é¡ã䜿ããŸãã
AWS::AccountId
- AWSã¢ã«ãŠã³ãIdãååŸãã
AWS::NotificationARNs
- Stackã®éç¥ãåãåãArn
AWS::NoValue
Fn::If
ãšçµã¿åãããŠäœ¿ã- Productionã®æã¯ãã®ãã©ã¡ãŒã¿ã¯èšå®ããªãããšã§ãã
AWS::Region
- StackãäœæããRegionã®æåå
AWS::StackName
- ãã®åã®éãStackå
ãã¡ãã䟿å©ãªãã®ã°ããã§ããäŸãã° AWS::AccountId
ã AWS::Region
ãªã©ã¯ãIAM ã®ãªãœãŒã¹ãäœãéã«ã¯è¯ã䜿ãã§ãããã
çµã¿èŸŒã¿é¢æ°ã¯æ¬¡ã®ããã«äœ¿ããŸããYamlã®ç瞮圢æ§æã䜿ã£ãŠããŸãã
!Sub "${NamePrefix}-ec2"
ãã®é¢æ°ã¯ãNamePrefix
ãšãããã©ã¡ãŒã¿ã®å€ã代å
¥ããæååãçæããŸãã
次ã®Templateã¯ãEC2ãäœãã ãã®åçŽãªãã®ã§ãã
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
NamePrefix:
Type: String
Description: Name tag prefix
MinLength: 1
Default: myapp
InstanceType:
Type: String
Description: EC2 instance type
MinLength: 1
Default: t2.micro
Resources:
MyInstance:
Type: 'AWS::EC2::Instance'
Properties:
InstanceType: !Ref InstanceType
ImageId: ami-4af5022c
Tags:
- Key: Name
Value: !Sub "${NamePrefix}-ec2"
ããã©ã«ãã®ãã©ã¡ãŒã¿ã䜿çšããå Žåã !Sub "${NamePrefix}-ec2
㯠Parameters
ã§å®çŸ©ãã NamePrefix
ã®ããã©ã«ãå€ã䜿çšã㊠myapp-ec2
ãšæååãè¿ããŸãã
ãã®ãããªãã©ã¡ãŒã¿ã䜿ã£ãŠæååã«ããé㯠!Sub
ã䜿ããŸãããã !Sub
ã䜿ããããã«ãªãåã®å€ãããã¥ã¡ã³ããã¹ã©ã€ãã§ã¯ !Join
ã䜿ãæ¹æ³ã玹ä»ãããŠãããããããŸããããä»ãªã !Sub
ã§ãã
å°ãè足çãªå
容ã§ãã !Ref InstanceType
㯠Ref: InstanceType
ãšæžããŠãåé¡ãããŸãããããã !Ref
ãšããã°Yamlã®ã¿ã°æ©èœã䜿ã£ãŠããããããšãã£ã¿ãŒã«ãã£ãŠã¯ãã€ã©ã€ããä»ãããã«ãªããŸããRef:
ã ãšYamlã®ããŒãšããŠã®ãã€ã©ã€ããšãªããä»ã®ããŒã«åãããŠããŸããŸããã !Ref
ãªãAWSã®é¢æ°ã䜿ã£ãŠãããšããã«åããã®ã§ !Ref
ãããããããŸãã
äŸãã°ç§ã® vim ã§ã¯ããããªé¢šã«ãã€ã©ã€ããä»ããŸãã
ããŸã«ãç䌌ãã©ã¡ãŒã¿ãç¥ãã MY_APP_AWS_REGION
ãªã©ãšèªåã® Parameter ãçšæããŠããŸãã±ãŒã¹ãèŠãããŸããã !Ref AWS::Region
ãšããã°äžçºãªã®ã§äžèŠã§ããåæ§ã« AWSã¢ã«ãŠã³ãId 㯠AWS::AccountId
ãæã£ãŠããŸãããStackåã ã£ãŠ AWS::StackName
ã§ååŸã§ããŸãã
ããã« !Sub
ãšçµã¿åãããããšäŸ¿å©ã§ãã次ã®äŸã¯ãIAM Role ãäœæãããã®ã§ãã
AWSTemplateFormatVersion: '2010-09-09'
Resources:
OperationIamRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
- "ec2.amazonaws.com"
Action:
- "sts:AssumeRole"
ManagedPolicyArns:
- !Sub "arn:aws:iam::${AWS::AccountId}:policy/AmazonEC2FullAccess-201708310220-kiyo"
RoleName: !Sub "${AWS::StackName}-ops-iam-role"
!Sub "arn:aws:iam::${AWS::AccountId}:policy/AmazonEC2FullAccess-201708310220-yasuhiroki"
ã !Sub "${AWS::StackName}-ops-iam-role"
ã®ããã«ã !Sub
ãšçµã¿åãããããšã§ç°¡åã«æååãå®çŸ©ããããšãã§ããŠããŸãã!Sub
ã¯ç䌌ãã©ã¡ãŒã¿ãåç
§ã§ããã®ã§ãã
CloudFormation ã®ãã©ã¡ãŒã¿ã¯ã§ããã ã䜿ã人ã®ããšãèããŠèšå®ããŸãããã ä»ã®å€ã¯ Template ãäœã人ãã䜿ããŸãããããã©ã¡ãŒã¿ã¯Templateã䜿ã人ãæå®ããããã§ãã äžèŠªåãªãã©ã¡ãŒã¿ã§ã¯ããã®Parameterã¯äœãæå®ããã°è¯ããã§ããïŒããšè³ªåãããæãå¥ã®æãŠã«ã¯ããé¡ãããŸãããšæããããŠããŸããããããŸããã
ããã°ã©ããŒã®éã§ã¯ãåã¯æäœéã®ããã¥ã¡ã³ãããšããèªèããã£ãããªãã£ããããŸããããé¢æ°ã®åŒæ°ãšæ»ãå€ã®åãæ確ã«ãªã£ãŠããã°ããã®åã䜿ãã°è¯ãã®ã ãšããã«åãããŸãã åãããã«ããã©ã¡ãŒã¿ã®åãã§ããã ãæ³å®ããŠãããã®ã«æ²¿ãããå®çŸ©ããã°ãããã ãã§å©çšè ã«æ å ±ãäžããããšãã§ããŸãã
ã§ã¯ãã©ã®ããã«ããŠãã©ã¡ãŒã¿ã®åãå®çŸ©ããããããã€ãäŸãããã¯ã¢ããããŠèª¬æããŸãããã
AWSåºæã®ãã©ã¡ãŒã¿ãŒå11ã䜿ããå Žåã¯å¿
ã䜿ããŸããããéåžžã«æå¹ã§ãã
äŸãã° AWS::EC2::Instance::Id
ãšããåã䜿ããšãInstanceId ããæå®ã§ããªããã©ã¡ãŒã¿ãŒãå®çŸ©ã§ããŸãã匷åãªã®ã¯ãStackãäœãããšããŠããAWSã¢ã«ãŠã³ãäžã«ååšããŠããªãIdãæå®ãããšãå³åº§ã«ãšã©ãŒãšãªãç¹ã§ããå©çšè
ã¯ããã«ããããã®Idééã£ãŠãããšæ°ä»ãããšãã§ããŸãã
AWS åºæã®ãã©ã¡ãŒã¿ãŒåã䜿ããªãå Žåãåºæ¬çã«ã¯ãã® AllowedPattern
ã䜿ãããšã«ãªããŸãã
ãã©ã¡ãŒã¿ãŒãåãããæååãæ£èŠè¡šçŸã§å®çŸ©ããŸãã
CloudFormation ã®ããã¥ã¡ã³ãã«èŒã£ãŠããªãæ©èœãšã㊠Rules
ãšãããã®ããããŸãã1
Rulesã䜿ããšããã Environment
ã production
ã ã£ãã EC2 ã® InstanceType 㯠m4.large
ããæå®ã§ããªãããšããããã©ã¡ãŒã¿ãä»ã®ãã©ã¡ãŒã¿ã«ãã£ãŠåãããå€ã決ãŸã£ãŠããããšãè¡šçŸã§ããŸãã
Rules:
IfProduction:
RuleCondition: !Equals [ !Ref Environment, "production" ]
Assertions:
- Assert: !Equals [ !Ref InstanceType, "m4.large" ]
AssertDescription: "Production env should use m4.large"
ç§ã¯ãCloudFormationã¯åŠç¿ã³ã¹ããé«ãä»çµã¿ã ãšæããŸããç¬èªã®èšæ³ã»ä»çµã¿ãå€ããããããææ¡ããã«ã¯ããã¥ã¡ã³ããèªã¿ãªããè©ŠããããããŸããããããå®éã«Templateãã¡ã€ã«ãæžããŠãè©ŠããŠã倱æããStackãåé€ããŠããšããäœæ¥ãç¹°ãè¿ãã®ã¯æéã§ããã粟ç¥çã«ãèŸãäœæ¥ã§ãã ç¹ã«åçŽãªã±ã¢ã¬ã¹ãã¹ã¯ãStackãäœãåã«æ°ä»ããããã®ã§ãã
ãäœã§å€±æãããã ãããããã¿ã€ããã¹ã...ã
ãããªèç¡æãå³åãåã«ã次ã®ãããªããŒã«ã䜿ã£ãŠTemplateããã¹ãããŸãããã
aws-cli
ãã€ã³ã¹ããŒã«ããŠããã°äœ¿ããã³ãã³ãã§ãã
aws-cli
ã¯AWSå
¬åŒã®ããŒã«ã§ãã®ã§ã䜿ããªãæã¯ãããŸãããåŸè¿°ããStackã®ç®¡çã«ã䜿ããŸãã
䜿ãæ¹ã¯ç°¡åã§ãã
äŸãã°ããã«ãType
ã Typo
ã« typo ããTemplateãã¡ã€ã«ãçšæããŸããã
AWSTemplateFormatVersion: '2010-09-09'
Resources:
S3Bucket:
Typo: 'AWS::S3::Bucket'
Properties:
LifecycleConfiguration:
Rules:
- Status: Enabled
ExpirationInDays: 1
ãã® Template ã« CLI 㧠vaildation ãå®è¡ãããšãType
ãå¿
é ã ãïŒããšæã£ãŠãããŸãã
$ aws cloudformation validate-template --template-body file://./step5/invalid.template.yaml
An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: [/Resources/S3Bucket] Every Resources object must contain a Type member.
å®ã¯ãã® validation 㯠Stack ãäœæããæã«ãäºåã«èªåã§å®è¡ãããã®ã§ãããããå¥ã«æåã§å®è¡ããªããŠãè¯ããšæããããããŸããã ããããã³ãã³ããå®è¡ããŠããã«ãšã©ãŒãæããŠãããã®ãšãStackåããã©ã¡ãŒã¿ãå ¥åããŠããããå®è¡ã ããšããŠãããšã©ãŒãšãªãã®ãšã§ã¯ãåŸåŽæãå šãéãã§ãããã
ãã ãããã®ããŒã«ã«ã¯å€§ããªæ¬ ç¹ããããŸãã 次ã®Templateãã¡ã€ã«ã¯ãã¹ããããStackãäœæã§ããŸããã
AWSTemplateFormatVersion: '2010-09-09'
Resources:
S3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
LifecycleConfiguration:
Rule:
- Status: Enabled
ExpirationInDays: 1
ããã validaion ã¯æåããŠããŸããŸãã
$ aws cloudformation validate-template --template-body file://./step5/invalid.template.yaml
{
"Parameters": []
}
aws cloudformation validate-template
ã¯åäžè¶³ã§ CloudFormation Template ã® Format ãæ£ãããã©ããã®æ€èšŒã¯ããŠãããã®ã§ãããå¿
é ã§ã¯ãªããã©ã¡ãŒã¿ããã®å€ã¯ãã§ãã¯ããŠãããªãã®ã§ãã
äœããã¹ãªã®ãã¯æ¬¡ã®ç« ã§èª¬æããŸãããã
cfn-lint ãšãã䟿å©ãªããŒã«ããããŸãã
Node.jsã§åããŠããŸãã®ã§ npm install -g cfn-lint
ãªã©ãšããŠã€ã³ã¹ããŒã«ããŸãããã
ãã®ããŒã«ã䜿ã£ãŠãäžèšã§äŸç€ºãããã¹ãå«ãTemplateã®æ€èšŒãããŠã¿ãŸãã
$ cfn-lint validate step5/invalid.template.yaml
0 infos
0 warn
2 crit
Resource: Resources > S3Bucket > Properties > LifecycleConfiguration
Message: Required property Rules missing for type AWS::S3::Bucket.LifecycleConfiguration
Documentation: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig.html, http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html#cfn-s3-bucket-lifecycleconfig
Resource: Resources > S3Bucket > Properties > LifecycleConfiguration
Message: Rule is not a valid property of AWS::S3::Bucket.LifecycleConfiguration
Documentation: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig.html, http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html#cfn-s3-bucket-lifecycleconfig
Template invalid!
äœããã¡ãã»ãŒãžãåºãŠããŸããã
cfn-lint
㯠Rules
ãç¡ãã»Rule
ãªããŠããããã£ã¯ååšããªãããšææããŠããŸãã
å®ã¯ãå
çšã® Template ãã¡ã€ã«ãééã£ãŠããéšåã¯ãRules
ãšãã¹ããšããã Rule
ãšæžããŠããããšãªã®ã§ãã
ããã« cfn-lint
ã¯ããŸã㧠cfn-lint docs
ãšããã³ãã³ããçšæããŠããŸãã
äŸãã° cfn-lint docs AWS::S3::Bucket.LifecycleConfiguration
ãšå®è¡ãããšããã©ãŠã¶ã§S3 Bucket LifecycleConfiguration ã®CloudFormationã«é¢ããããã¥ã¡ã³ããéããŠãããŸãããã¡ãã¡æ€çŽ¢ããªããŠæžãã®ã§äŸ¿å©ã§ãã
ãã®èšäºãèªãããšæã£ãæ¹ã¯ãå°ãªããšã AWS CloudFormation ãšããä»çµã¿ã®ååšãç¥ã£ãŠããããšã§ãããã äžã«ã¯ãCloudFormationã®äœæã«è©Šè¡é¯èª€äžã®æ¹ããStackã®ç®¡çã§å°ã£ãŠããæ¹ãããã㯠CloudFormation ãæ¢ããããŠããŸããªããšããæ¹ãããããšã§ãããã AWS CloudFormationã¯å·šå€§ãªããŒã«ã§ããä»æ¥ææ¥ã§äœ¿ãæ¹ã身ã«ã€ããããšã¯é£ãããããã«ãã¹ã¿ãŒãããšããŠãããã³ãã¬ãŒããã¡ã€ã«ãèªãã ã ãã§ãªãœãŒã¹æ§æãå šãŠç解ã§ãããªã©ãšããæ¥ã¯æ°žé ã«èšªããªãã§ãããã ãããªã®ã«ããªã CloudFormation ãå¿ èŠãªã®ã§ããããã äžã€ã®çãã¯ãäžã®äžã«ããå¥ã®ããŒã«ãæã£ãŠããŸããAWS ElasticBeanstalk ã䜿ã£ãããšã¯ããã§ããããïŒ ããã㯠awsecscli ã䜿ã£ãŠ ECS ã¯ã©ã¹ã¿ãŒãäœã£ãããšã¯ããã§ããããïŒ Serverless ã³ãã³ãã觊ã£ãããšã¯ïŒ ãããã®ããŒã«ã¯å éšã§CloudFormationã掻çšããŠããŸããAWSã®ãªãœãŒã¹ãå¿ èŠãªã ãäœæãã»æŽæ°ãã»ç®¡çããŸãšããŠè¡ãã«ã¯ CloudFormation ã¯ãã£ãŠã€ãã§ãã
ã§ã¯ç§ãã¡ãç§ãã¡ã®ããã«CloudFormationãå©çšããå¿ èŠã¯ããã®ã§ããããã ç§ã®çãã¯ãå¿ èŠã ãã ãæã»ã©ã§ã¯ãªããã§ãã äŸãã° AWS Lambda ã®ç®¡çã®ããã« CloudFormation ã䜿çšããå¿ èŠã¯ãªãã§ããããServerlessãApexãªã©äŸ¿å©ãªããŒã«ãæã£ãŠããŸãããã¡ãã掻çšããã»ããå§åçã«ç®¡çãç°¡åã§ãã ããã VPC ã®æ§ç¯ãIAMèšèšãRDSã®èšå®ç®¡çãªã©ã¯ãCloudFormation ã䜿ã£ãæ¹ãè¯ãã§ããããã©ã®SubnetãšSubnetãæ¥ç¶ã§ããã®ããIAM Policyãã©ã®ãããªå 容ã«ãªã£ãŠããã®ããRDSã®èšå®ãäœã«ããŠããã®ãããšãã£ãæ å ±ãç¥ããããªã床ã«Webã³ã³ãœãŒã«ç»é¢ã§æ¢ããããããã£ãäžã€ã®CloudFormation Stackã確èªããã°æžãããšããæåã®æ¹ãå¹ççãªã®ã¯æããã§ãã
ããããããã°ã©ãã³ã°èšèªãéçºããŒã«ãããã§ããããã«ãCloudFormationã䜿ãã¿ã€ãã³ã°ããŸãé©æé©æãšãªãã®ã§ãã
Step1 ã§ã¯ CloudFormation Template ã®æžãæ¹ã«ã€ããŠè§ŠããŸããã ãããã㯠Template ã䜿ã£ãŠ CloudFormation Stack ãäœæã»æŽæ°ã»éçšããŠããããã® Tips ãšãªããŸãã
Stack ã®ç®¡çã¯ã次ã®ç¹ããæ°ãã€ããŠããã°é£ããã¯ãããŸããã
- ãã©ã¡ãŒã¿ãŒã®æå®ãã¹ã«æ³šæãã
- Stackã®äŸåé¢ä¿ã«æ³šæãã
- StackãæŽæ°ããæã®ãªãœãŒã¹çœ®ãæãã«æ³šæãã
CloudFormation Stack ã®äœæã»æŽæ°ã»åé€ãããæ¹æ³ã¯ããã€ãæ¹æ³ããããŸãã
- AWS Web ã³ã³ãœãŒã«ç»é¢ã§äœæ¥ãã
awscli
ã䜿ã£ãŠCLIã§äœæ¥ãã- å€éšãµãŒãã¹ãå©çšãã
ããã§ã¯ awscli
ã«çµã£ãŠè§£èª¬ããŸãã12
CloudFormationã觊ãå§ããé ã¯Webã³ã³ãœãŒã«ã§äœæ¥ãããŸãããã
ãã®æãã§ããã°è±èªè¡šèšã䜿ãããšãããããããŸããawscli
ã§äœ¿çšããã³ãã³ãããªãã·ã§ã³ã¯è±èªãªã®ã§ããã®è±èªãäœãæãã®ãå°ãã§ãç解ããããã§ãã13
ããã§Webã³ã³ãœãŒã«ã®äœ¿ãæ¹ã®è§£èª¬ã¯çç¥ããŸããWebã³ã³ãœãŒã«ã®UIã¯åºŠã å€ããã®ã§ããã£ããã£ç»åã«ããŸãæå³ã¯ãªããšæããŸãã 代ããã«ãã©ããã£ãæ©èœã觊ããææ¡ããŠããã°è¯ãããªã¹ãã¢ããããŠãããŸãã
- Stackã®äœæã»åé€
- CloudFormation Template ãã¡ã€ã«ã¯ Local PC äžãš S3 äžããéžæã§ããããš
- Template, Parameter ã®ä»ã«äœããèšå®ã§ãããã®ããããšããããš
- ã©ã¡ãããšãããšAWSã®æš©é管çè åãã®èšå®ã§ã
- â» æ¬èšäºã§ã¯ããŸã觊ããŸãã
- Stackã®æŽæ°
- Stack æŽæ°ã«ã¯ ChangeSet ãšããæŽæ°ååŸã®å·®åã管çããä»çµã¿ããããšããããš
CloudFormationã®æµããæŽããã次㯠CLI ã䜿ã£ãŠãããŸãããã
èšãããããªã§ãããWebã³ã³ãœãŒã«ã§ã®äœæ¥ã¯å埩äœæ¥ã«åããŠããŸãããããšãã£ãŠèªåã§ããã°ã©ã ãäœãã®ã¯è²»çšå¯Ÿå¹æãšããŠèŠåããªãå Žåãããã§ãããã14
ãã㧠awscli
ã§ãããã§ã«ãåç¥ãããããŸããã awscli
ã¯AWSã®åçš®ãµãŒãã¹çšAPIãã©ããããŠCLIããŒã«ã«ä»äžãããã®ã§ãAWSã®Webã³ã³ãœãŒã«ã§è¡ã£ãŠããããšã¯ãã»ãŒå
šãŠ awscli
ã§ä»£æ¿å¯èœã§ããããã awscli
ã§ã§ããããšãWebã³ã³ãœãŒã«ã§ã¯ã§ããªãããšããããã®ã§ãAWSãéçšãããªãå¿
é ãšèšã£ãŠãè¯ãããŒã«ã§ãããã
awscli
ã®ã€ã³ã¹ããŒã«æ¹æ³ã¯å²æããŸãã15
aws cloudformation help
ãå®è¡ãããšäœ¿çšã§ããã³ãã³ããåãããŸããå·çææç¹ã§ã¯ 44 ã®ã³ãã³ãã䜿ããããã§ãã
ãããªã44ã€å
šãŠã®ã³ãã³ããææ¡ããŠäœ¿ãããªãã®ã¯æéããããã®ã§ãç§ããã䜿çšããã³ãã³ãããªã¹ãã¢ããããŠãããŸãã
- create-stack
- stack ãäœæãã
- wait stack-create-complete
- stack ã®äœæãå®äºãããŸã§åŸ ã€
- create-change-set
- change-set ãäœæãã
- 詳ããã¯åŸè¿°ããŸã
- wait change-set-create-complete
- change-set ã®äœæãå®äºãããŸã§åŸ ã€
- execute-change-set
- change-set ãé©çšãã
- wait stack-update-complete
- change-set ã®é©çš = stack ã®æŽæ°ãå®äºãããŸã§åŸ ã€
- delete-stack
- stack ãåé€ãã
- wait stack-delete-complete
- stack ã®åé€ãå®äºãããŸã§åŸ ã€
awscli
ã«ã¯ãç§ã®ç¥ãéãå
šãŠã®ã³ãã³ã㧠--generate-cli-skeleton
ãšãããªãã·ã§ã³ã䜿ããŸãã
äŸãã° aws cloudformation create-stack --generate-cli-skeleton
ãå®è¡ãããšã次ã®ãããªåºåã«ãªããŸãã
# åºåãé·ãã®ã§çç¥ããŠããŸã
$ aws cloudformation create-stack --generate-cli-skeleton
{
"StackName": "",
"TemplateBody": "",
"TemplateURL": "",
"Parameters": [
{
"ParameterKey": "",
"ParameterValue": "",
"UsePreviousValue": true
}
],
"DisableRollback": true,
以äžç¥
ãããã®ããŒãããããã awscli
ã®ãªãã·ã§ã³ã®1ã€1ã€ã«çŽä»ããŠããŸãã
StackName
㯠--stack-name
ã« TemplateBody
㯠--template-body
ã«ããšãã£ãå
·åã§ãã
ãã㊠--generate-cli-skeleton
ãšå¯Ÿããªã --cli-input-json
ã䜿ããšããªãã·ã§ã³ãæå®ãã代ããã« json ã®å€ãèªã¿èŸŒãŸããããšãã§ããŸãã
äŸãã°æ¬¡ã®ãã㪠json ãã¡ã€ã«ãçšæããŠã
{
"StackName": "SampleStack",
"TemplateBody": "file://sample.template",
"Parameters": [{
"ParameterKey": "Param",
"ParameterValue": "foo"
}],
"Tags": [{
"Key": "Env",
"Value": "test"
}]
}
次ã®ãããªã³ãã³ããå®è¡ãããšã
$ aws cloudformation create-stack --cli-input-json sample.json
å¿
èŠãªãªãã·ã§ã³ãçç¥ã㊠stack ãäœæããããšãã§ããå¹ççã«äœæ¥ããããšãã§ããŸãã
ç¹ã«CloudFormationã§ã¯ Parameters
ã®å€ãå€ããŠæ§ç¯ããããšãå€ãã®ã§ããããã©ã¡ãŒã¿ããªãã·ã§ã³ã§1ã€ãã€æå®ããã®ã¯é¢åãªã®ã§ããã®ããã«ãã¡ã€ã«ã§ç®¡çããæ¹ãè¯ãã§ãããã
äœã£ã CloudFormation Stack ã¯æŽæ°ããããšãã§ããŸãã Stackäœææã«äœ¿ã£ã Template CloudFormation ã® Stack æŽæ°ã¯ Change Sets16 ãšããä»çµã¿ã䜿ããŸãã ãã¯ããChange Sets ã䜿ããã«Stackã®æŽæ°ãããããªããŠä»ã§ã¯èããããŸããã17
StackãæŽæ°ãããæãæãæ°ã«ãªãã®ã¯ãæŽæ°ããŠå€§äžå€«ãªã®ãããšããäžå®ã§ããã²ãã£ãšãããšãã¡ãã£ãšããå€æŽã®ã€ãããEC2ã®åæ§ç¯ãå®è¡ãããŠããŸãã¢ã©ãŒããé£ã¶ãæ³å®å€ã®ãªãœãŒã¹ãåé€ãããŠããŸã£ãŠããŒã¿ãé£ã¶ããšãã£ãçµéšãããããšããããããããããŸããã ããããäžå®ãææããã«ã¯ããã® Stack æŽæ° ã§äœãã©ããªãã®ããç¥ãå¿ èŠããããŸãã ãããŠããã®ããã®ä»çµã¿ã Change Sets ã§ãã
Change Sets ã®åºæ¬çãªäœ¿ãæ¹ã®æµãã¯æ¬¡ã®éãã§ãã
- Change Sets ãäœã
- äœã£ã Change Sets ã®äžèº«ã確èªãã
- Change Sets ãå®è¡ãã
- Change Sets ãåé€ãã
Webã³ã³ãœãŒã«äžã§è¡ãæ¹æ³ã¯ AWS å ¬åŒããã° ã§èª¬æãããŠããã®ã§ãã¡ããèŠãŠãã ããã ããã§ã¯ aws-cli ã§ã®æé ãèŠãŠã¿ãŸãããã
Change Sets ãäœãã³ãã³ãã¯æ¬¡ã®ãããªãã®ã§ãã
change_set_name="ChangeSetå" # ex) my-stack-20171111
template_file="Templateãã¡ã€ã«ãã¹"
input_json="Parameterãèšè¿°ããjsonãã¡ã€ã«ãã¹"
aws cloudformation create-change-set \
--change-set-name "${change_set_name}" \
--template-body "file://${template_file}" \
--cli-input-json "file://${input_json}" # input_json ã« stackåãæžããŠããã®ã§ --stack-name ãªãã·ã§ã³ã¯äžèŠ
ãã®ã³ãã³ããå®è¡ãããšããã«ã¬ã¹ãã³ã¹ãè¿ã£ãŠããŸãã
awscli ã䜿ã£ãããšã®ããæ¹ã¯ãåç¥ã ãšæããŸãããawcli ã§ã¯æäœãå®äºãããŸã§åŸ
ããªãã³ãã³ãã幟ã€ããããŸãã
create-change-set
ããã®ïŒã€ã§ãChangeSetsã®äœæãéå§ããããšãã¬ã¹ãã³ã¹ã§è¿ããŸãããäœæãå®äºããã®ãã©ããã¯åãããŸããã
ãã㧠wait
ã³ãã³ãã䜿ãããšã«ãªããŸãã
aws cloudformation wait change-set-create-complete \
--change-set-name "${change_set_name}" \
--stack-name "${stack_name}"
ãã ãããã®ãŸãŸã ãšãã Change Sets ã®äœæã«å€±æããæã«ããªã倱æããã®ãããåãããŸããã
ãã㧠wait
ã倱æããæã« Change Sets ã®è©³çŽ°ãååŸããããã«ããŸãããã
aws cloudformation wait change-set-create-complete \
--change-set-name "${change_set_name}" \
--stack-name "${stack_name}" || {
aws $(fn::aws_option) cloudformation describe-change-set \
--change-set-name "${change_set_name}" \
--stack-name "${stack_name}"
exit 1
}
Change Sets ã®äžèº«ã確èªããã³ãã³ãã¯æ¬¡ã®ãããªãã®ã§ãã
change_set_name="ChangeSetå" # ex) my-stack-20171111
input_json="Parameterãèšè¿°ããjsonãã¡ã€ã«ãã¹"
aws cloudformation describe-change-set \
--change-set-name "${change_set_name}" \
--cli-input-json "file://${input_json}" # input_json ã« stackåãæžããŠããã®ã§ --stack-name ãªãã·ã§ã³ã¯äžèŠ
Change Sets ãå®è¡ãããããªãã¡ Stack ãæŽæ°ããã³ãã³ãã¯æ¬¡ã®ãããªãã®ã§ãã
change_set_name="ChangeSetå" # ex) my-stack-20171111
input_json="Parameterãèšè¿°ããjsonãã¡ã€ã«ãã¹"
aws cloudformation execute-change-set \
--change-set-name "${change_set_name}" \
--cli-input-json "file://${input_json}" # input_json ã« stackåãæžããŠããã®ã§ --stack-name ãªãã·ã§ã³ã¯äžèŠ
Change Sets ãäœãæãšåæ§ã«ããã®ã³ãã³ããå®è¡ãããšããã«ã¬ã¹ãã³ã¹ãè¿ã£ãŠããŸãã
ããã§ã¯ Change Sets ãæåããã®ã倱æããã®ãåãããªãã®ã§ã wait
ã³ãã³ãã䜿ããŸãããã
aws cloudformation wait stack-update-complete --stack-name "${stack_name}"
æŽæ°ã倱æãããããªã倱æããã®ãç¥ãããã®ã§ãã³ãã³ããç¹ããŠæŽæ°æã®ã€ãã³ãã確èªããŸãããã
aws cloudformation wait stack-update-complete --stack-name "${stack_name}" || {
aws $(fn::aws_option) cloudformation describe-stack-events --stack-name "${stack_name}"
exit 1
}
äœãæŽæ°ããããã¯åãã£ãŠããã®ã§ããã«åæ ããããããšããæã«äœ¿ãããšãã§ããã³ãã³ãã¯2çš®é¡ãããŸãã
aws cloudformation deploy
- ChangeSetã®äœæã»å®è¡ããŸãšããŠè¡ã
aws cloudformation update-stack
- ChangeSetãäœæããStackãçŽæ¥æŽæ°ãã
ã©ã¡ãã䜿ãã¹ããããšãã話ã«ãªããŸãããç¹ã«çç±ãç¡ããã° aws cloudformation deploy
ã䜿ãæ¹ãè¯ãã§ãããã
change_set_name="ChangeSetå" # ex) my-stack-20171111
template_file="Templateãã¡ã€ã«ãã¹"
input_json="Parameterãèšè¿°ããjsonãã¡ã€ã«ãã¹"
aws cloudformation deploy \
--template-file "${template_file}" \ # file:// ã¯äžèŠã§ã
--cli-input-json "file://${input_json}" # input_json ã« stackåãæžããŠããã®ã§ --stack-name ãªãã·ã§ã³ã¯äžèŠ
update-stack
㯠Change Sets ã®ä»çµã¿ãçãŸããåããååšããã³ãã³ãã§ãã
deploy
ã®æ¹ãæ°ããããè¯ãããšããããã§ã¯ãããŸããããdeploy
㯠Change Sets ã®ä»çµã¿ã䜿ã£ãŠãããããChange Sets ã®äœæã«æåãããããšãããã§ãã¯ãå¿
ç¶çã«è¡ãããããšã«ãªããŸããããã«ããããã³ãã¬ãŒããã¡ã€ã«ã®ãã©ãŒããããšã©ãŒããã©ã¡ãŒã¿ã®äžæŽåãªã©ãStackãæŽæ°ããåã«æ°ä»ãããã¹ãå
ã«æ€åºããããšãã§ããŸãã update-stack
ã§ã¯ãå³åº§ã«Stackã®æŽæ°ãå§ãŸã£ãŠããŸããããäºçŽ°ãªãã¹ã§ã Stack Rollback ãå®è¡ãããå¯èœæ§ããããŸãã
ã§ã¯ãupdate-stack
ã¯ãã䜿ãããããšã®ãªãã³ãã³ããªã®ããšãããšãããã§ã¯ãããŸããã
Stack ã§ç®¡çãããŠãããªãœãŒã¹ã®æŽæ°ã¯ deploy
ã䜿ãæ¹ã奜ãŸããã§ãããStack èªäœã®èšå®ãäŸãã° Stack Policy ã Rollback Policy ãªã©ã¯ update-stack
ã䜿ãå¿
èŠããããŸãã
update-stack
ãåãæã£ãŠããå€ãã®åœ¹å²ã®ãã¡ãStackå
ã§ç®¡çãããªãœãŒã¹ã®è¿œå ã»æŽæ°ã»åé€ã¯ deploy
ã«å§è²ããããã®ãšããŠèãããšè¯ãã§ãããã
Stack ã®æäœãå®äºããã«ã¯æéãããããŸãããã®éã«ã³ãŒããŒã飲ãã§äžæ¯å ¥ããã®ããã¹ããªéžæã§ããããã£ããç«åç»ãèŠãŠããŸãããã£ãšãããŠãããã¡ã«Stackã®äœæãå®äºããŠããããªããŠããšãè¯ããããŸãã ãããªããªããããStack ã®æäœãå®äºãããããã«æ¬¡ã®äœæ¥ã«ç§»ããããã«ããŸãããã ãŸãããå®æçã«ãã©ãŠã¶ãF5ããŠç¢ºèªãªããŠããŠãŸããããïŒ
CloudFormation ã«ã¯ Notifications ãšããèšå®ããããŸãã ãã㯠AWS SNS ãšé£æºãããã®ã§ãWeb ã³ã³ãœãŒã«ã ãš SNS ã®äœæèªäœãããããããã ãã§è¡ãªããŸãã ããã©ã«ãã¯ã¡ãŒã«éä¿¡ã§ãããAWS SNS ãªã®ã§ã«ã¹ã¿ã ã¯è²ã ãšã§ããŸãã éæ¿ãªã®ã¯ãAWS SNS ãã AWS Lambda ãèµ·åã㊠Slack ã«éç¥ããããšãã£ããã®ã§ããããã
ç§ãæ®æ®µãã䟿å©ã«äœ¿ã£ãŠãã terminal-notifier
ãšããããŒã«ããããŸãã
å®è¡æéã®é·ãã³ãã³ããçµãã£ãããMac ã®éç¥ãšããŠç¥ãããŠãããŸããããã倧å€äŸ¿å©ã§ãCloudFormation ã® Stack æäœä»¥å€ã«ããã¡ãã£ãšéããã¹ããæµããæããã«ãã«æéãæããããã ãããã®éã«å¥ã®äœæ¥ãããããšããããšãæ°è»œã«ã§ããããã«ãªããŸããã
詳ãã㯠Macã§æéã®ãããã³ãã³ããçµãã£ãããèªåã§éç¥ããzshèšå® ããåèãã ããã
å€ãã®ãœãããŠãšã¢éçºãããã§ããããã«ãCloudFormation ããŸã CI/CD ãããããšãã§ããŸãã CloudFormation ã«ãããªãã®ãå¿ èŠãïŒ ãšæãæ¹ããããããããŸããããããã CloudFormation ã ãããã CI/CD ãå¹æçãªã®ã§ãã Step2.3 㧠ChangeSets ã®æ©èœã«ã€ããŠè§ŠããŸããããããã¯ãŸãã« CloudFormation 㧠CI/CD ãããã¡ãªããã®äžã€ã§ãã Templateãä¿®æ£ããã¬ãã¥ãŒãçµãŠããŒãžããããšå®éã«Templateãé©çšããStackãæå³éãäœæã»æŽæ°ãããããšã確èªããããããã£ãäœæ¥ãæ°è»œã«ã§ããç°å¢ããããšãã©ãã»ã©æ°ã楜ãªããšãã
CI/CD ãšã¯èšããŸããããå ·äœçã«äœãããã®ãã¯è¿°ã¹ãŠããŸããã§ããã ããã§ã¯ãŸããCloudFormation ã® CI/CD ãšããŠæ³å®ãããå 容ãæŽãåºããŠã¿ãŸãããã
- CI
- Templateãã¡ã€ã«ã«èª€ãããªããæ€èšŒãã
- Templateãã¡ã€ã«ã®èšè¿°æ¹æ³ã«äžèŠãªèšè¿°ããªããæ€èšŒãã
- Templateãã¡ã€ã«ã«ããŒã ã®æ¹éã«åããªãèšè¿°ããªããæ€èšŒãã
- CD
- Stackã®äœæãã§ãããæ€èšŒãã
- Stackã®æŽæ°ãã§ãããæ€èšŒãã
- Stackã®æŽæ°å 容ãæ³å®éããæ€èšŒãã
- å¿ èŠã«å¿ããŠãStackãšé¢é£ããå¥ã®ãã¹ããå®è¡ããåé¡ããªããæ€èšŒãã
ãã£ãšä»ã«ãèããããšãã§ãããããããŸããã æãã€ãéãã§ããããªäºãæŽãåºããŠãã©ããŸã§ããã°å¹æçãèããŸãããã
äŸãã°ç§ã®å Žåãè€æ°äººã§CloudFormation Templateã觊ãããšãèãããšãCI ã®éšåã¯éç¹çã«åãçµã¿ãããšããã§ãã
人åã§ã¯ã³ã¹ããæããã°ãããªã®ã§ãäœãããããŒã«ã䜿ããäœããããŠèªååããã®ã¯å¿
é ã§ãããã
aws cloudformation validate-template
ã¯ãã¡ãã cfn-lint
ã掻çšã§ããã§ãããã
äžæ¹ã§ãCD ã¯ããã»ã©ç®ããããç«ãŠãªããŠãè¯ããããããŸããã
äºåã«ChangeSetsãäœã£ãŠãæŽæ°å
容ã確èªããããŠããã°ãããšã¯ã¬ãã¥ãŒã§è¯ããšèŠãªããŠã©ãã©ãStackã«åæ ãããŠããŸããŸãã
awspec
ã䜿ã£ãŠ Stack äœæåŸã«AWSã®ãªãœãŒã¹ããã§ãã¯ãããã©ããã¯æ©ã¿ãŸããSecurityGroup ã BucketPolicy ãšãã£ããã»ãã¥ãªãã£çã«æ°ãã€ãããéšåã¯ãã¹ãããããšããã§ãããä»ã®å
容㯠CloudFormation Template èªäœããã£ããã¬ãã¥ãŒããŠããã°ååã ãšæããŸãã
å®éã«æ¥åã§äœ¿çšããŠãã CircleCIã® config.yml ãäžéšæç²ããŸãã
ãã£ãŠããããšã¯ aws cloudformation validate-template
ããŠããã ãã§ãã
version: 2
jobs:
build:
working_directory: ~/app
docker:
- image: circleci/python:3
steps:
- checkout
- restore_cache:
key: deps1-{{ .Branch }}
- run: |
python3 -m venv venv
. venv/bin/activate
pip install awscli
- save_cache:
key: deps1-{{ .Branch }}
paths:
- "venv"
- run: |
. venv/bin/activate
# æå®ãããã£ã¬ã¯ããªä»¥äžã®templateãã¡ã€ã«ãé 次 aws cloudformation validate-template ããã¹ã¯ãªãããå®è¡
bash ./cloudformation/tool/validation.sh -r ap-northeast-1 ./cloudformation/
Step1 ã§ã¯ CloudFormatin Template ã®æžãæ¹ãStep2 ã§ã¯ CloudFormation Stack ã®äœæã»æŽæ°ãšCI/CDã«ã€ããŠè§ŠããŸããã ãããŸã§ããã°ãCloudFormation ãèªç±ã«äœ¿ãããªããæ°è»œã«ã¡ã³ãã§ããç¶æ ãæŽã£ããšèšããã§ãããã 次ã¯ãã©ã®ãã㪠Template ãã¡ã€ã«ãæžãã°ããããTemplate ã®èšèšã«ã€ããŠãšãªããŸãããããäžçªé£ãããç¶æ³ã«ãã£ãŠæèŠãå€ããéšåã§ãããã§ãããã
Templateãã¡ã€ã«ã®èšèšã«ã€ããŠã®ãç§ã®èãã¯ãããã°ã©ããŒã®ææ³ããªãã¹ãæµçšããããåºæ¬ãšããŠããŸãã DRY ãšã ãã¹ãããããå®è£ ãããæ¹æ³ãšãããããã£ãææ³ã§ãã 以éãç§ãªãã®Templateã®èšèšã«ã€ããŠè¿°ã¹ãŠãããŸãã
ãŽãŒã«ããªããã°æèããããšããã§åºãªã沌ã«èœã¡ãã ããªã®ã§ãå ã«äœãããç®æšãç«ãŠãŸãããã ç§ã®å Žåã¯ãæäœã§ããããŸã§ã¯ããããšããããšããŠããã以äžã¯ããªããã®äžéãšäžéãå®ããããã«ããŠããŸãã äŸãã°æ¬¡ã®ãããªæãã§ãã
AWS::AccountId
ãšAWS::Region
ã䜿ã- Regionã¯ãšãããAccountIdã¯æ®æ®µèŠããŠãªãã®ã§ããããã䜿ããªããšç¡ç
develep
test
production
ãšç°å¢ãéã£ãŠãåãTemplateã䜿ããããš- ç°å¢ããšã«äœ¿ãTemplateãå€ãã -> æé ãå€ãã ->
production
ãžã®é©çšã¯å®è³ªã¶ã£ã€ãæ¬çª -> äºæ ã®ããš
- ç°å¢ããšã«äœ¿ãTemplateãå€ãã -> æé ãå€ãã ->
- Stackã®äŸåé¢ä¿ãäžçŽç·ã«ãªãããš
- Stackã®åŸªç°åç §ã®ãããªç¶æ ã«ãªããªãããš
- Multi-Region 察å¿
- èªåãã¡ã€ã³ã§äœ¿ã£ãŠããRegion以å€ã§ãåãããšãä¿èšŒããããšããªããã®æ
- ãµãŒãã¹ã®èŠæš¡çã«å¿ èŠãªãã°ããããå¿ èŠã§ãªããã°ããªã
- 䜿ããããªãRegionã䜿ããã»äœ¿ããªããææ¡ãç¶ããã®ã¯èŸãã®ã§
- èªåãã¡ã€ã³ã§äœ¿ã£ãŠããRegion以å€ã§ãåãããšãä¿èšŒããããšããªããã®æ
- ã¢ããªã±ãŒã·ã§ã³ãéã£ãŠãé©çšã§ããTemplateã«ããããš
- é 匵ã£ãçµæãè€éãªTemplateãã§ããããããªãåããŠããŸã£ãæ¹ãè¯ã
- å
±éããèšè¿°ãã©ãããŠããŸãšããããã°ãTemplateããã«ãããŠçæãããããªããã°ã©ããã«ãªä»çµã¿ãæŽãã
- ç¶æ¿ããå§è²ã®èããšäŒŒãŠãã
ããã°ã©ã èšèªãªãæ¡ä»¶åå²ã§å®è£
ããããªããããªãã®ããCloudFormationã§ããããããªãæããããŸãã
äŸãã°ãProductionç°å¢ã®æã¯ãã®ãªãœãŒã¹ãäœããããAuroraã®SnapshotIdentifier
ãæå®ãããŠãããMasterUsername
ãšMasterUserPassword
ãã¯ç¡èŠããããšãã£ãå
·äœã§ãã
ãããªæ㯠Conditions
ã AWS::NoValue
ã®åºçªã§ãã
Conditions
18 㯠CloudFormation ã®ããªãåæã®é 19 ãã䜿ãããšãã§ããæ©èœã§ãã
ããã°ã©ãã³ã°ã«äŸãããªããæ¡ä»¶åŒã®çµæãä¿æããå€æ°ãå®çŸ©ããŠãããããªãã®ã§ãã
Conditions:
IsProduction: !Equals [ !Ref Environment, "production" ]
ãšæžãã°ããã㯠IsProduction = (Environment == "")
ãšãã£ãåŠçãšãªããŸãã
éèŠãªã®ã¯æ¡ä»¶åŒã§äœ¿ãParameter (ä»åã®äŸã ãš Environment
) ãå®çŸ©ããŠããå¿
èŠãããç¹ã§ããã€ãŸãã Conditions
㯠Parameters
ã§å®çŸ©ãããã©ã¡ãŒã¿ã䜿çšããããšãåæãšãªããŸãã
å
çšäŸãããšãããConditions
ã¯å€æ°ãä¿æããã ããªã®ã§ãä»ã®ç®æã§äœ¿ããªããã°ç¡é§ã«ãªããŸãã
Conditions
ã§å®çŸ©ããå€æ°ã®äœ¿ãæ¹ã¯ 2çš®é¡ãããŸãã
Resources
ã®Conditions
ãã©ã¡ãŒã¿ã§äœ¿ã- æ¡ä»¶é¢æ°
!If
ã®ç¬¬äžåŒæ°ã§äœ¿ã
ããã¯ãæ¡ä»¶ã«ãã£ãŠãªãœãŒã¹ãäœãã»äœããªããå¶åŸ¡ãããæã«æŽ»çšããŸãã
äŸãã°ãproductionã®æã ãS3 Bucketãäœãå Žåã¯æ¬¡ã®ããã«ãS3Bucketã®Resourceã«Conditions
ã§IsProduction
ãæå®ããŸãã
Parameters:
Environment:
Type: String
AllowedValues:
- production
- develop
Conditions:
IsProduction: !Equals [ !Ref Environment, "production" ]
Resources:
S3Bucket:
Type: 'AWS::S3::Bucket'
Conditions: IsProduction # ã³ã³ïŒ
ãã¡ãã¯ããªãœãŒã¹ãäœãã®ã¯æ±ºãŸã£ãŠããã©ãããããã£ã®æç¡ã¯æ¡ä»¶ã«ãã£ãŠå€ãããå Žåã«æŽ»çšããŸãã äŸãã°ãproductionã®æã ãS3ã®LifeCycleãæå¹ã«ãããå Žåã¯ã次ã®ãããªäœ¿ãæ¹ã«ãªããŸãã
Parameters:
Environment:
Type: String
AllowedValues:
- production
- develop
Conditions:
IsProduction: !Equals [ !Ref Environment, "production" ]
Resources:
S3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
LifecycleConfiguration:
Rules:
- Status: !If [ IsProduction, Enabled, Disabled ] # ã³ã³ïŒ
ExpirationInDays: 1
!If
ãäžé
æŒç®åã£ãœãæå®ããããšæãã°åãããããã§ãããã
Conditions
ãš !If
ã ãã§ã¯ãAãšBã©ã¡ãã®å€ã«ãããããšããåŠçããæžããŸãããAãæå®ããããäœãæå®ããªãããšããåŠçãæžããªãã®ã§ãã
CloudFormationã§ã¯ãç¹å®ã®æ¡ä»¶ã®æã¯æå®ããŠã¯ãªããªããã©ã¡ãŒã¿ãããã€ãååšããŸããäŸãã° RDS
ã® MasterUsername
㯠SnapshotIdentifier
ãæå®ãããŠããã䜿ã£ãŠã¯ãªããªãããšããã¥ã¡ã³ãã«æžãããŠããŸãã null
ãæå®ããŠããã¡ã§ãæªå®çŸ©ãªç¶æ
ã«ããŠããå¿
èŠãããã®ã§ãã
ãã㧠AWS::NoValue
ãšããç䌌ãã©ã¡ãŒã¿ã䜿ããŸãã
ãã®ãã©ã¡ãŒã¿ãš !If
ãçµã¿åãããããšã§ã SnapshotIdentifier
ãæå®ãããŠããã MasterUesrname
ã¯å®çŸ©ããªãããšããããšãã§ããŸãã
Parameters:
RDSSnapshotIdentifier:
Type: String
RDSInstanceMasterUsername:
Type: String
Conditions:
# UseSnapshotIdentifier = (RDSSnapshotIdentifier != "")
UseSnapshotIdentifier: !Not [ !Equals [ !Ref RDSSnapshotIdentifier, "" ] ]
Resources:
RDSCluster:
Type: 'AWS::RDS::DBCluster'
Properties:
# ä»ã®ããã€ãã®ããããã£ã¯çç¥
SnapshotIdentifier: !If
- UseSnapshotIdentifier
- !Ref RDSSnapshotIdentifier # UseSnapshotIdentifier == true ã®æ㯠RDSSnapshotIdentifier ãã©ã¡ãŒã¿ã䜿çšãã
- !Ref AWS::NoValue # UseSnapshotIdentifier == false ã®æ㯠SnapshotIdentifier ããããã£èªäœãæªå®çŸ©ã«ãã
MasterUsername: !If
- UseSnapshotIdentifier
- !Ref AWS::NoValue # UseSnapshotIdentifier == true ã®æ㯠MasterUsername ããããã£èªäœãæªå®çŸ©ã«ãã
- !Ref RDSInstanceMasterUsername # UseSnapshotIdentifier == false ã®æ㯠RDSInstanceMasterUsername ãã©ã¡ãŒã¿ã䜿çšãã
AWS CloudFormation Cross Stack Reference ãšããä»çµã¿ããããŸãã ããã¯ãStackéã®äŸåé¢ä¿ãæ確ã«ã§ããä»çµã¿ã§ãStackã®æŽæ°ã»åé€ãå®å¿ããŠè¡ãããã«ããã²æŽ»çšããŸãããã
äŸãã°ã VPC Subnet
ãæ§ç¯ãã Stack ãš æ§ç¯ãã VPC Subnet
ãå©çšã㊠EC2
ãç«ãŠã Stack ããããšããŠãEC2
ãåããŠããã®ã« VPC Subnet
ãåé€ããããšå°ãããã§ããå®éã«ã¯ãåé€ããããšããã¿ã€ãã³ã°ã§ EC2ã§å©çšäžã ããæ¶ããªãã ãšãšã©ãŒã«ãªãã®ã§åé¡ã«ãªãããšã¯ãªãã§ããã Cross Stack Reference ã䜿ããš VPC Subnet
ãåé€ãåŸãå€æŽãå ããããšããæç¹ã§ ãã®VPC Subnetã«äŸåããŠããä»ã®StackãããããæŽæ°ã§ããªãã ãšæããŠãããã®ã§ãã
åé¡ã®æ©æçºèŠã»ã©å¹ççãªãã®ã¯ãããŸãããã
ãã ããèšãæããã°ãéçšäžåé¡ãªãããšãåãã£ãŠãããã©ã Cross Stack Reference ã®å¶çŽã®ãã㧠Stack ãæŽæ°ã§ããªãããšããç¶æ ã«é¥ããããã§ãã Stackã®äŸåé¢ä¿ãäžçŽç·ã«ãªãããš ãå®ã£ãŠããã°ãããããåé¡ã«ã¯ãªããªããšæããŸãããæŽæ°ãã§ããã«åé¡ãªããšããããšã¯ Template ã®åãæ¹ãäœãæ¹ã«åé¡ããããšãããµã€ã³ã§ãã
CloudFormationã¯ä»ã®ãµãŒãã¹ã«æ¯ã¹ããšå°å³ãªããŒã«ã§ãæ©èœã®è¿œå ããŸãå°å³ãªãã®ãå€ãããŒã«ã§ããããŸãã ãã®èšäºããŸãå°å³ãªæãã«ãªããŸãããã誰ãã®åœ¹ã«ç«ãŠãŠããã°å¹žãã§ãã
- AWSãã€ã¹ã¿ãŒã·ãªãŒãº AWS CloudFormation
- CloudFormationã®ä»çµã¿ã¯ãããèŠãã°ã ãããåãã
- AWS Black Belt Online Seminar 2016 AWS CloudFormation
- 2016/12ã«å ¬éãããè³æãäžçªæ°ããããŠããŠãè©°ãŸã£ãå ¬åŒã¹ã©ã€ãã
- AWS CloudFormation ã®ãã¹ããã©ã¯ãã£ã¹
- ã¹ã©ã€ãç AWS CloudFormation Best Practices
- CloudFormationãéçšããéã®ãã¹ããã©ã¯ãã£ã¹
- CloudFormationã®ãªãªãŒã¹å±¥æŽ
- AWSå ¬åŒãã³ãã¬ãŒããµã³ãã«é
Footnotes
-
ãã«ããŒã¹ã¯ãªããã¯ãªãã¹ã䜿ããªãæ¹ãè¯ããšèããŠããŸããæ°å¹Žåãªããšããããä»ãªã代æ¿æ段ãããã¯ãã§ãã â© â©2
-
2016/09ã§å ¬åŒã«YamlããµããŒããããããã«ãªããŸãã â©
-
å®éã«CloudFormationã®å ±éåãããããšãããã®ã§ãããã©ããŸã§ãå ±éåããããå ±éåã®ä»çµã¿ã»ä»æ§ã¯ã©ããªããå ±éåãããã°ã¬ãªã©ããªãã確èªããæ¹æ³ããããã®ããã¥ã¡ã³ãæŽåãªã©äœæ¥ãå€ããè²»çšå¯Ÿå¹æãé©åã§ã¯ãªããšæããŸããããã ãå ±éåã®ä»çµã¿èªäœã¯æ¢åã®ããŒã«ãçµã¿åãããã°ããã»ã©ã³ã¹ããæãããªããšæãã®ã§ããããç§ã®æèŠã¯å€ããå¯èœæ§ããããŸãã â©
-
移è¡ååŸã®Template㧠diff ãåãæ¹ã確å®ã§ãã â©
-
http://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/quickref-cloudformation.html â©
-
䜿ãæ¹ã¯ https://dev.classmethod.jp/cloud/aws/cfndesigner/ ãåèã«ãªããŸã â©
-
http://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html â©
-
2016/09ã«è¿œå ãããé¢æ°ã§ããåè) https://aws.amazon.com/jp/blogs/aws/aws-cloudformation-update-yaml-cross-stack-references-simplified-substitution/ â©
-
http://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html â©
-
http://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html ã®åŸåãåç § â©
-
å·çæã®
awscli
ã® version ã¯aws-cli/1.11.162
ã§ã â© -
äœè«ã§ãããç§ã¯Webã³ã³ãœãŒã«ãåžžã«è±èªã§äœ¿çšããŠããŸãã
awscli
ãããŒã¹ã«ããŠãããããæ¥æ¬èªã ãšããã£ãŠäœã®æ©èœãåãããªãããšãå€ãã®ã§ãã â© -
ã¡ãã£ãšããããŒã«ã®ã€ããã§ãç¶ç¶çãªã¡ã³ããšæ¡åŒµæ§ã...ãšèãããšããããªãã«å·¥æ°ãããããã®ã§ã â©
-
awscliã®ã€ã³ã¹ããŒã«æ¹æ³ã¯ http://docs.aws.amazon.com/ja_jp/cli/latest/userguide/installing.html ãåè â©
-
æ¥æ¬èªã§ã¯å€æŽã»ããããšè¡šçŸãããŠããŸã â©
-
ãã®ä»çµã¿ãå ¥ãåãŸã§ Stack ã®æŽæ°ã®åã«ã©ããã£ãŠç¢ºèªããŠãããããã¯ãèšæ¶ã«ãããŸãã â©
-
http://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html â©
-
ãªãªãŒã¹å±¥æŽã«ããã°ãå°ãªããšã2013幎11æã«ã¯ååšããŠããããã§ã â©