SlideShare a Scribd company logo
1 of 87
Download to read offline
re:G
ene
rate

AWS  マイスターシリーズ  
AWS  CloudFormation  
2013.11.27
アマゾン  データ  サービス  ジャパン株式会社
ソリューションアーキテクト  吉荒  祐⼀一

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
2013年年
CloudFormationのアップデート
!   2013/2/7

•  Amazon  S3  と  Amazon  RDSのタグ付けが可能に

!   2013/2/20

•  EBS-‐‑‒Optimized  EC2インスタンスのプロビジョニング
•  Auto  Scaling  Groupのローリングデプロイ
•  スタックアップデートのキャンセル

!   2013/8/12

•  並列列スタック処理理とネストされたスタックの更更新の追加

!   2013/9/17

•  追加のVPCサポートと新テンプレート

!   2013/10/14

•  フェデレーテッドユーザーおよび⼀一時的なセキュリティ認証情報が
利利⽤用可能に

2

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Agenda
! CloudFormationの概要
!   スタック
!   テンプレート
!   Cloud-‐‑‒init
! CloudFormation  helpers
! CloudFormer
!   その他Tips
!   まとめ
3

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
!  CloudFormationの概要

4

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  CloudFormation
!   EC2やELBなどを使ったAWSサービスのシステム構築を、
設定ファイル(テンプレート)を元に⾏行行えるサービス
!   テンプレートを⾃自由に作成できるため、⾃自分好みのシス
テム構成が可能
!   テンプレートは、AWSのサービスを操るための新しい⾔言
語

5

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  CloudFormationのイメージ
テンプレートに基づき
各サービスが起動

スタック

Elastic  Load  Balancing

テンプレート

S3

Cloud
Formation
SNS
EC2

EC2
Auto  Scaling

6

CloudWatch

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
利利⽤用シーンと利利点
!   ⼀一度度テンプレートを作成すれば、同じ構成を再現できる
•  開発環境の構築
•  Blogシステム、Webシステム、ゲームプラットフォームなど、
同じ仕組みでアプリやデータが異異なるようなもの

!   ベストプラクティスが盛り込まれたテンプレートが使⽤用
可能
•  システムアーキテクチャの再利利⽤用
•  WordPress,  Redmineなどが⼊入った、多くのサンプルテンプ
レートが提供済み

!   起動時にパラメータを渡せる

•  例例えばDBのエンドポイントをEC2に渡せる

7

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
利利⽤用料料⾦金金
! CloudFormationの利利⽤用⾃自体は無料料
!   テンプレートに従って構築された各AWSサービスに対し
て課⾦金金

8

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWSの構築・デプロイ⾃自動化サービスの
中での位置づけ
導⼊入の容易易さ

Elastic  Beanstalk

OpsWorks

CloudFormation

フレキシビリティ
9

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormationに適した場⾯面
!   幅広いリソースを使い環境構築する場合

•  エンタープライズアプリケーション
•  レガシーアプリケーション
•  他の⾃自動化サービスではサポートされないリソースを使⽤用

! ElasticBeanstalkと組み合わせて構築する場合

•  リソースのひとつとして、ElasticBeanstalkをサポート

10

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
!  スタック

11

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
スタック
!   リソース(EC2インスタンスやS3バケット、RDSインスタンスな
ど)の集合のこと
!   スタック単位でリソースの管理理が可能。スタック破棄を実⾏行行すると、
スタックにひもづくリソースを破棄することが可能
!   使⽤用するリソースおよびリソースの構築順は、テンプレートの依存
関係で決定
スタック

これらを⼀一度度に⽣生成・破棄可能
App
Serve
r

12

Web
Serve
r

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
スタック可能なリソースタイプ
!   Amazon  EC2  インスタンス
!   Amazon  EC2  セキュリティグループ
!   Amazon  Elastic  Block  Store(EBS)
ボリューム
!   Elastic  Load  Balancers
!   Amazon  EC2  Elastic  IP  アドレス
!   Auto  Scaling  グループ
!   Auto  Scaling  ポリシー
!   Amazon  RDS  
データベースインスタンス
!   Amazon  RDS  パラメータグループ
!   Amazon  RDS  セキュリティグループ
!   Amazon  DynamoDB
!   Amazon  SimpleDB  ドメイン
!   Amazon  SQS  キュー
!   Amazon  SNS  トピック
!   Amazon  SNS  サブスクリプション

13

!
!
!
!

 
 
 
 

! 
! 
! 
! 
! 
! 

AWS  Elastic  Beanstalk
Amazon  CloudWatch  アラーム
Amazon  Route  53  DNS  レコード
Amazon  CloudFront  
ディストリビューション
Amazon  S3  バケット
AWS  Identity  and  Access  
Management  ユーザー、グループ、
およびポリシー
Amazon  ElastiCache  
キャッシュクラスタ
Amazon  ElastiCache  
キャッシュセキュリティグループ
Amazon  ElastiCache  
キャッシュパラメータグループ
Amazon  Virtual  Private  Cloud  VPC、
サブネット、ゲートウェイ、ルートテー
ブル、およびネットワーク  ACL

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
スタック構築⽅方法
!   AWS  Management  Consoleから構築
!   コマンドラインツール
•  AWS  Command  Line  Tool

•  http://aws.amazon.com/cli/

!   各種SDK

Java  :  http://aws.amazon.com/jp/sdkforjava/
.NET  :  http://aws.amazon.com/jp/sdkfornet/
PHP    :  http://aws.amazon.com/jp/sdkforphp/
Ruby  :  
http://docs.aws.amazon.com/AWSSdkDocsRuby/latest/
DeveloperGuide/ruby-‐‑‒dg-‐‑‒setup.html
•  JavaScript  :  
http://aws.amazon.com/documentation/sdkforjavascript/
•  Python  :  http://docs.pythonboto.org/en/latest/
• 
• 
• 
• 

14

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
スタック構築⽅方法:もうひとつの視点
!   既存のテンプレートから構築
•  ローカルファイル
•  S3上のファイル

!   サンプルテンプレートから構築

•  http://aws.amazon.com/cloudformation/aws-‐‑‒
cloudformation-‐‑‒templates/

!   ゼロから新しいものを作る

!   テンプレートはテキストファイルとして作成、管理理、共
有可能
15

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  Management  Consoleから構築-‐‑‒1

16

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  Management  Consoleから構築-‐‑‒2

スタックの名称
・サンプルテンプレート
・ローカルファイルの
  テンプレート

いずれか

・テンプレートファイルURL
(同⼀一リージョンのS3上)

17

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  Management  Consoleから構築-‐‑‒3

各種パラメータの⼊入⼒力力
(後で説明)

18

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  Management  Consoleから構築-‐‑‒4

リソースにタグ付け

19

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  Management  Consoleから構築-‐‑‒5

20

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  Management  Consoleから構築-‐‑‒6

スタックのコスト⾒見見積もり

21

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  Management  Consoleから構築-‐‑‒7

スタック構築開始

22

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  Management  Consoleから構築-‐‑‒8

23

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  Management  Consoleから構築-‐‑‒9

スタック構築実⾏行行中

24

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  Management  Consoleから構築-‐‑‒10

スタック構築完了了
この時点ですべてのサービスが
起動している

25

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  Management  Consoleから構築-‐‑‒11

スタック構築失敗
ロールバック中

26

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
!  テンプレート

27

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
{
"AWSTemplateFormatVersion" : "2010-09-09",

テンプレート

"Description" : “Sample",
"Parameters" : {
"KeyName" : {
"Description" : “Sample key,
"Type" : "String"
}
},
"Mappings" : {
},

! CloudFormationの⼼心臓部
!   スタック構築の設計図
!   JSONフォーマットで記述

"Resources" : {
"Ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
"KeyName" : { "Ref" : "KeyName" },
"ImageId" : { "Fn::FindInMap" : [
"RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}
}
},
"InstanceSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable SSH access via port 22",
"SecurityGroupIngress" : [ {
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : "0.0.0.0/0"
}]
}
}
}

28

}
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
テンプレート解説
"AWSTemplateFormatVersion" : “2010-09-09",

テンプレートのバージョン
(最新は2010-‐‑‒09-‐‑‒09)

"Description" : "Valid JSON strings up to 4K",

テンプレートの詳細(説明⽂文)

{

"Parameters" : {
set of parameters
},
"Mappings" : {
set of mappings
},
“Conditions" : {
set of conditions
},
"Resources" : {
set of resources
},
"Outputs" : {
set of outputs
}
}

29

CloudFormation実⾏行行時に
後で変更更可能なパラメータを列列挙
(例例:DBユーザー名など)
Hashtableのようなもの
キーに応じて値を特定出来る
(例例:リージョンに応じたAMI番号など)
Parameters、他のCondition、Mappingから
条件判断し結果に応じてリソースを作成可能
EC2やRDSなど、スタックを構成する
リソースを定義
スタック構築後に取得したい値
(例例:アクセスURLなど)

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Parameters
{
"AWSTemplateFormatVersion" : “2010-09-09",
"Description" : "Valid JSON strings up to 4K",
"Parameters" : {
set of parameters
},
"Mappings" : {
set of mappings
},
“Conditions" : {
set of conditions
},
"Resources" : {
set of resources
},

CloudFormation実⾏行行時に
後で変更更可能なパラメータを列列挙
(例例:DBユーザー名など)

"Outputs" : {
set of outputs
}
}

30

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Parametersとは
!   スタック構築時に値の⼊入⼒力力が可能
!   データ型、デフォルト値、最⼩小最⼤大値など設定可能
"Parameters" : {
"Age":{
"Type":"Number",
“Default” : “30”,
“MinValue”: “20”,
“MaxValue”: “60”,
"Description":"input your age.“
},
"FirstName":{
"Type":"String",
"Description":"input your first name.“
},
}

31

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Parametersのプロパティ
!   利利⽤用出来るプロパティ
プロパティ
Type

データ型    “String”  “Number”    “CommaDelimitedList”

Default

デフォルト値

NoEcho

⼊入⼒力力時に*****となる(パスワードなどに使⽤用)

AllowedValues

⼊入⼒力力可能値の⼀一覧指定  (例例:[“true”,”false”]  )

AllowedPattern

正規表現で⼊入⼒力力可能パターンを指定(例例:[a-‐‑‒zA-‐‑‒Z]*)

MaxLength

最⼤大⽂文字数

MinLength

最⼩小⽂文字数

MaxValue

最⼤大値

MinValue

最⼩小値

Description

プロパティの詳細説明

ConstraintDescription

32

内容

⼊入⼒力力した値がAllowedPatternやMaxLengthなどの制約に
引っかかった時に表⽰示する説明
(どのような制約があるかの説明を記述)

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Parametersの参照
!   ⼊入⼒力力したパラメータ値は、テンプレート中で  “Ref”を使
⽤用して参照可能
!   ユーザー名、パスワード、ドメインなどの可変部分に便便
利利
ここにパラメータ⼊入⼒力力値が反映される
“Resources" : {
“MyServer":{
“Type":“AWS::EC2::Instance",
“Properties” : {
“KeyName”: { “Ref” : “Age”},
“Tags” : { “Ref” : “FirstName”}
}
}
}

33

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
! 
!
!
!

!
!

!

! 

Function

Ref
•  パラメータを参照する
Fn::Base64
•  ⽂文字列列をBase64エンコードする
Fn::FindInMap
•  Mapから値を取り出す
Fn::GetAtt
•  リソースから属性を取り出す
•  例例:"Fn::GetAtt"  :  [  "MyELB"  ,  "DNSName"]
Fn::GetAZs
•  指定リージョンのアベイラビリティゾーンを返す
Fn::Join
•  ⽂文字列列の連結
•  “Fn::Join”  :  [  “:”,  [  “a”,  “b”,  “c”  ]  ]      は    「a:b:c」を返す
•  “:”がセパレータ。不不要な場合は  ””  を定義
Fn::Select
•  Index値に従って、リストから値を返す
•  例例:{  “Fn::Select”  :  [  “1”,  [  “apples”,  “grapes”,  “oranges”,  “mangoes”  ]  ]  }      
“grapes”を返す
Condition  Functions
•  Fn::If,  Fn::Equals,  Fn::NotのようなFunctionにより、条件によるスタック作成を可能に

http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/
index.html?intrinsic-‐‑‒function-‐‑‒reference.html

34

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Pseudo  Parameter
!   実⾏行行リージョンやスタック名といったパラメータを取得する予約語
•  {  “Ref”  :  “AWS::Region”  }  のように値を取得可能
!   AWS::AccountId
!   AWS::NotificationARNs
•  notification  Amazon  Resource  Names  (ARNs)のリスト取得
!   AWS::NoValue
“Resources" : {
•  Fn::If  Functionにて使⽤用
“MyServer":{
“Type":“AWS::EC2::Instance",
!   AWS::Region
“Properties” : {
“KeyName”: { “Ref” : “AWS::StackName”},
!   AWS::StackId
“Tags” : { “Ref” : “AWS::Region”}
!   AWS::StackName
}
}

}

http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/
index.html?pseudo-‐‑‒parameter-‐‑‒reference.html

35

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Mappings
{
"AWSTemplateFormatVersion" : “2010-09-09",
"Description" : "Valid JSON strings up to 4K",
"Parameters" : {
set of parameters
},
"Mappings" : {
set of mappings
},
“Conditions" : {
set of conditions
},
"Resources" : {
set of resources
},

Hashtableのようなもの
キーに応じて値を特定出来る
(例例:リージョンに応じたAMI番号など)

"Outputs" : {
set of outputs
}
}

36

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Mappingsとは
!   キーとバリューのテーブル
!   例例えば、⼊入⼒力力値やリージョンによって値が変わるような
ものを決めるような使い⽅方
"Mappings" : {
"RegionTable" : {
"us-east-1" : {
"AMI" : "ami-8c1fece5“,
“Key” : “myKey-east”
},
"us-west-1" : {
"AMI" : "ami-3bc9997e“,
“Key” : “myKey-west”
},
"ap-northeast-1" : {
"AMI" : "ami-300ca731“,
“Key” : “myKey-japan”
}
}
},

37

マッピングを定義
(この例例の場合、”RegionTable”という
マッピングを定義)

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Mappingsの使い⽅方
!   “Fn:FindInMap”で値を取得
!   "Fn::FindInMap"  :  [  "MapName",  "Key",  "Value"]
! MapName,key,Valueには”Ref”が利利⽤用可能
"Mappings" : {
"RegionTable" : {
"us-east-1" : {
"AMI" : "ami-8c1fece5“,
“Key” : “myKey-east”
},
"us-west-1" : {
"AMI" : "ami-3bc9997e“,
“Key” : “myKey-west”
},
"ap-northeast-1" : {
"AMI" : "ami-300ca731“,
“Key” : “myKey-japan”
}
}
},

38

“Resources" : {
“MyServer":{
“Type":“AWS::EC2::Instance",
“Properties” : {
“ImageId”: {
“Fn::FindInTemplate”
“Fn:FindInMap” : [
“RegionTable” ,
{ “Ref” : “region” },
“AMI”]
},
}
}
この例例だと、⼊入⼒力力された
}

regionパラメータによって
利利⽤用するAMIのIDを決定できる

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Conditions
{
"AWSTemplateFormatVersion" : “2010-09-09",
"Description" : "Valid JSON strings up to 4K",
"Parameters" : {
set of parameters
},

Parameters、他のCondition、Mappingから
条件判断し結果に応じてリソースを作成可能

"Mappings" : {
set of mappings
},
“Conditions" : {
set of conditions
},
"Resources" : {
set of resources
},
"Outputs" : {
set of outputs
}
}

39

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Conditionsの使い⽅方
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Mappings" : {
"RegionMap" : {
<一部省略>	
}
},
"Parameters" : {
"EnvType" : {
EnvTypeパラメータが”prod”と等しければ
"Description" : "Environment type.",
“CreateProdResources”条件が成⽴立立
"Default" : "test",
"Type" : "String",
"AllowedValues" : ["prod", "test"],
"ConstraintDescription" : "must specify prod or test."
}
},
"Conditions" : {
"CreateProdResources" : {"Fn::Equals" : [{"Ref" : "EnvType"}, "prod"]}
},
"Resources" : {
"EC2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}
}
},
"MountPoint" : {
"Type" : "AWS::EC2::VolumeAttachment",
"Condition" : "CreateProdResources",
"Properties" : {
"InstanceId" : { "Ref" : "EC2Instance" },
© 2013 Amazon.com, Inc. and its affiliates. All rights
"VolumeId" : { "Ref" : "NewVolume" }, reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

40
"Parameters" : {
"EnvType" : {
"Description" : "Environment type.",
"Default" : "test",
"Type" : "String",
"AllowedValues" : ["prod", "test"],
"ConstraintDescription" : "must specify prod or test."
}
},
"Conditions" : {
"CreateProdResources" : {"Fn::Equals" : [{"Ref" : "EnvType"}, "prod"]}
},
"Resources" : {
EnvTypeパラメータが”prod”と等しければ
"EC2Instance" : {
"Type" : "AWS::EC2::Instance",
“CreateProdResources”条件が成⽴立立
"Properties" : {
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}
}
},
“CreateProdResources”条件が成⽴立立して
"MountPoint" : {
"Type" : "AWS::EC2::VolumeAttachment",
いる
"Condition" : "CreateProdResources",
場合にのみリソース⽣生成
"Properties" : {
"InstanceId" : { "Ref" : "EC2Instance" },
"VolumeId" : { "Ref" : "NewVolume" },
"Device" : "/dev/sdh"
}
},
“CreateProdResources”条件が成⽴立立して
"NewVolume" : {
いる
"Type" : "AWS::EC2::Volume",
"Condition" : "CreateProdResources",
場合にのみリソース⽣生成
"Properties" : {
"Size" : "100",
"AvailabilityZone" : { "Fn::GetAtt" : [ "EC2Instance", "AvailabilityZone" ]}
}
}
}
}

Conditionsの使い⽅方

41

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Resources
{
"AWSTemplateFormatVersion" : “2010-09-09",
"Description" : "Valid JSON strings up to 4K",
"Parameters" : {
set of parameters
},
"Mappings" : {
set of mappings
},
“Conditions" : {
set of conditions
},
"Resources" : {
set of resources
},

EC2やRDSなど、スタックを構成する
リソースを定義

"Outputs" : {
set of outputs
}
}

42

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Resourcesとは
!   EC2やELB,RDSなど、起動するサービスを設定
!   リソース毎に決められたパラメータを設定する
“Resources" : {
“MyWebServer" : {
“Type" : “AWS:EC2::Instance”
“Properties" : {
“KeyName" : "ami-8c1fece5“,
“ImageId” : “myKey-east”
},
"us-west-1" : {
"AMI" : "ami-3bc9997e“,
“Key” : “myKey-west”
},
"ap-northeast-1" : {
"AMI" : "ami-300ca731“,
“Key” : “myKey-japan”
}
}
},

43

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
EC2+SecurityGroupの例例

"Resources" : {
"Ec2Instance" : {
リソースタイプ
"Type" : "AWS::EC2::Instance",
"Properties" : {
"SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
"KeyName" : { "Ref" : "KeyName" },
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}
}
},
"InstanceSecurityGroup" : {
リソース毎のプロパティ
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable SSH access via port 22",
"SecurityGroupIngress" : [ {
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : "0.0.0.0/0"
}]
}
}
}

44

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
リソースタイプ

AWS::aws-‐‑‒product-‐‑‒name::data-‐‑‒type-‐‑‒name
! 
! 
! 
! 
! 
! 
! 
! 
! 
! 
! 
! 

AWS::AutoScaling::AutoScalingGroup
AWS::AutoScaling::LaunchConfiguration
AWS::AutoScaling::ScalingPolicy
AWS::AutoScaling::Trigger
AWS::CloudFormation::Authentication
AWS::CloudFormation::CustomResource
AWS::CloudFormation::Init
AWS::CloudFormation::Stack
AWS::CloudFormation::WaitCondition
AWS::CloudFormation::WaitConditionHandle
AWS::CloudFront::Distribution
AWS::CloudWatch::Alarm

! 
! 
! 
! 
! 
! 
! 
! 
! 
! 
! 
! 

AWS::EC2::VPNConnection
AWS::EC2::VPNConnectionRoute
AWS::EC2::VPNGateway
AWS::EC2::VPNGatewayRoutePropagation
AWS::ElastiCache::CacheCluster
AWS::ElastiCache::ParameterGroup
AWS::ElastiCache::SecurityGroup
AWS::ElastiCache::SecurityGroupIngress
AWS::ElastiCache::SubnetGroup
AWS::ElasticBeanstalk::Application
AWS::ElasticBeanstalk::Environment
AWS::ElasticLoadBalancing::LoadBalancer

! 
AWS::DynamoDB::Table
! 
AWS::IAM::AccessKey
! 
AWS::EC2::CustomerGateway
! 
AWS::IAM::Group
! 
AWS::EC2::DHCPOptions
! 
AWS::IAM::InstanceProfile
! 
AWS::EC2::EIP
! 
AWS::IAM::Policy
! 
AWS::EC2::EIPAssociation
! 
AWS::IAM::Role
! 
AWS::EC2::Instance
! 
AWS::IAM::User
! 
AWS::EC2::InternetGateway
! 
AWS::IAM::UserToGroupAddition
! 
AWS::EC2::NetworkAcl
! 
AWS::RDS::DBInstance
! 
AWS::EC2::NetworkAclEntry
! 
AWS::RDS::DBParameterGroup
! 
AWS::EC2::NetworkInterface
! 
AWS::RDS::DBSubnetGroup
! 
AWS::EC2::NetworkInterfaceAttachment
! 
AWS::RDS::DBSecurityGroup
! 
AWS::EC2::Route
! 
AWS::RDS::DBSecurityGroupIngress
! 
AWS::EC2::RouteTable
! 
AWS::Route53::RecordSet
! 
AWS::EC2::SecurityGroup
! 
AWS::Route53::RecordSetGroup
! 
AWS::EC2::SecurityGroupIngress
! 
AWS::S3::Bucket
! 
AWS::EC2::SecurityGroupEgress
! 
AWS::S3::BucketPolicy
! 
AWS::EC2::Subnet
! 
AWS::SDB::Domain
! 
AWS::EC2::SubnetNetworkAclAssociation
! 
AWS::SNS::TopicPolicy
! 
AWS::EC2::SubnetRouteTableAssociation
! 
AWS::SNS::Topic
http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/index.html?aws-‐‑‒template-‐‑‒resource-‐‑‒type-‐‑‒ref.html
! 
AWS::EC2::Volume
! 
AWS::SQS::Queue
! 
AWS::EC2::VolumeAttachment
! 
AWS::SQS::QueuePolicy
! 
AWS::EC2::VPC
! 
AWS::EC2::VPCDHCPOptionsAssociation

45

!  © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS::EC2::VPCGatewayAttachment
Attributes
!   リソースの振る舞いや関係を制御する
! DeletionPolicy
•  スタックを削除する際のリソースの処理理
•  Delete  (Default)  /  Retain  /  Snapshot

! DependsOn

•  指定したリソースが⽣生成された後に⽣生成
•  AWS::CloudFormation::WaitCondition、  
AWS::CloudFormation::WaitConditionHandleと併⽤用

!   Metadata
! UpdatePolicy

•  AWS::AutoScaling::AutoScalingGroupリソースのみ
•  Auto  ScalingのRolling  Updateでの挙動を制御
•  MaxBatchSize
•  MinInstancesInService
•  PauseTime

46

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Outputs
{
"AWSTemplateFormatVersion" : “2010-09-09",
"Description" : "Valid JSON strings up to 4K",
"Parameters" : {
set of parameters
},
"Mappings" : {
set of mappings
},
“Conditions" : {
set of conditions
},
"Resources" : {
set of resources
},
"Outputs" : {
set of outputs
}
}

47

スタック構築後に取得したい値
(例例:アクセスURLなど)

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Outputsとは
!   スタック構築後に取得・表⽰示したい情報の定義
!   例例えばアクセスURLや、DBの通信先情報、作ったIAM
ユーザー名など、あとで使⽤用するもの
!   マネジメントコンソールから確認できるので、スタック
に関する情報を出⼒力力すると便便利利(キーペア名、AZ、イ
ンスタンスIDなど)

48

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Outputの定義
出⼒力力したい名称を定義

"Outputs" : {
"InstanceId" : {
説明
"Description" : "InstanceId of the newly created EC2 instance",
"Value" : { "Ref" : "Ec2Instance" }
},
値
"AZ" : {
"Description" : "Availability Zone of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ] }
},
"ApplicationURL" : {
"Description" : "URL of running web application",
"Value" :
    { "Fn::Join":
     ["", [ "http://", { "Fn::GetAtt": [ "Ec2Instance" , "PublicIp"] } , "/index.html"] ] }
}
Functionを使って⽂文字列列を加⼯工
}

49

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Outputの定義
"Outputs" : {
"InstanceId" : {
"Description" : "InstanceId of the newly created EC2 instance",
"Value" : { "Ref" : "Ec2Instance" }
},
"AZ" : {
"Description" : "Availability Zone of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ] }
},
"ApplicationURL" : {
"Description" : "URL of running web application",
"Value" :
    { "Fn::Join":
     ["", [ "http://", { "Fn::GetAtt": [ "Ec2Instance" , "PublicIp"] } , "/index.html"] ] }
}
}

50

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
テンプレートのまとめ
! Parameters,Mappings,Resources,Outputsの4つのブ
ロックに定義を記述
!   可変項⽬目はパラメーター化したり、Mappingで定義
!   Functionsを使⽤用して、参照や⽂文字連結などの操作が可
能
!   Resourceのパラメータはリソースタイプにより異異なる。
ドキュメントを利利⽤用して定義
•  http://docs.amazonwebservices.com/
AWSCloudFormation/latest/UserGuide/index.html?aws-‐‑‒
template-‐‑‒resource-‐‑‒type-‐‑‒ref.html

51

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
テンプレートTips
!   リソース定義にEC2インスタンスが必須ではない

•  DB構築だけ、オートスケールだけ、アラーム設定だけでもOK

!   参照関係があると、依存関係があるとみなされる。相互
参照や循環参照はNG(エラーとなる)
!   参照関係がある部分は、参照の整合性が取れるよう起動
順をCloudFormationが決定
!   スタックを破棄すると、スタックにひもづくリソースは
破棄される
•  ただし”DeletionPolicy”を”Retain”にすると破棄されない
"Resources" : {
"myS3Bucket" : {
"Type" : "AWS::S3::Bucket",
"DeletionPolicy" : "Retain"
}
}

52

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
テンプレートTips
!   リソース数が多いと、何のリソースか分からなくなるの
で、Tagsプロパティを使⽤用する
"MyInstance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"SecurityGroups" : [ { "Ref" : "MySecurityGroup" } ],
"ImageId" : "ami-20b65349",
"Tags" : [
{ "Key" : “Name", "Value" : “MyInstance" }
]
}
}

53

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
テンプレートTips
! CloudFormationで作られたリソースには、スタック名
などのタグが付与される

54

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
⼊入れ⼦子テンプレート
!   テンプレートからテンプレートの呼び出しが可能
!   リソースタイプに  “AWS::CloudFormation::Stack“を指定
! TemplateURLを指定すると、そのテンプレートを読み込み
"Resources" : {
 "WebServer" : {
"Type" : "AWS::CloudFormation::Stack",
"Properties" : {
"TemplateURL" : “https://s3.amazonaws.com/hoge.template" ]]},
"Parameters" : {
"KeyName" :
{ "Ref" : "KeyName" },
"InstanceType" : { "Ref" : "InstanceType"},
}
},

55

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS::CloudFormation::Stack
!   AWS::CloudFormation::Stack  を使⽤用してスタックを
上位のテンプレートのリソースとしてネストする
!   トップレベルのスタックとネストされたスタックを⼀一緒
に更更新可能
!   ネストされたスタックの更更新

•  トップレベルのスタックでUpdateStackコマンドを実⾏行行
•  Management  Consoleで、トップレベルのスタックを選択
し、"Update  Stack"をクリック
•  CloudFormationはトップレベルのテンプレートだけでなく、ネ
ストされたテンプレートに対する更更新を検出し、テンプレート
が変更更されたスタックのみを更更新

56

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
!  Cloud-‐‑‒init

57

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Cloud-‐‑‒init
!   Amazon  Linuxに⼊入っている、初期設定ツール
•  元々はUbuntuで作られたもの

!   EC2インスタンスの起動時に、「userdata」として設定
したスクリプトを呼び出す。
•  「#!」  で始まる⽂文字列列の場合のみ、スクリプトを実⾏行行

!   スクリプトを記述できるので、ロケール変更更、アプリイ
ンストール、ファイル書き換えなどが可能
!   RHEL
•  http://aws.amazon.com/articles/2519228458631605

!   Windows

•  EC2ConfigService

58

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Cloud-‐‑‒init
EC2インスタンス起動

User  Dataに定義
Cloud-‐‑‒initがuserdata
を読み込む

読み込んだスクリプト
を実⾏行行

59

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Cloud-‐‑‒initの特⻑⾧長と制限
!   特⻑⾧長
!   インスタンス起動時に、インスタンスの初期化が可能

•  AMIとユーザーデータは分離離できるので、AMIの作り込みが不不要
になる
•  Apacheインストール済みのAMIを⽤用意すると、OSやApacheの
バージョンが上がったときに再作成になる

!   制限
! userdataは⼀一度度定義すると、書き換えは不不可能

•  書き換えて再実⾏行行が出来ない(後述のスタック更更新に使えない)

!   設定できるデータ量量は、16KByteまで
60

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormationとの連携
!   EC2リソースのプロパティ「UserData」に内容を記載
"MyInstance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId" : "ami-dcfa4edd",
"KeyName"
: { "Ref" : "KeyName" },
"UserData"
: { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bashn",
"log='/tmp/init.log'n",
"apt-get update &>> $logn",
"apt-get install -y ruby &>> $logn",
"cd /tmpn",
"wget http://rubygems.org/rubygems.tgz &>> $logn",
"tar zxf rubygems.tgz &>> $logn",
"cd rubygemsn",
"ruby setup.rb --no-format-executable &>> $logn",
]]
}
}
}

61

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormationとの連携
! CloudFormationでUserDataを定義すると、定義中に
RefやFn::GetAttrを使⽤用することが可能
!   例例えばRDSのEndPointをUserDataに埋め込むといった
ことが出来る

62

"Resources" : {
"MyInstance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId" : "ami-dcfa4edd",
"UserData"
: { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bashn",
"cd /home/ec2-usern",
{ "Fn::Join" : ["", [
"echo ", {"Fn::GetAtt" : ["DBInstance", "Endpoint.Address"]} , "> db.confn"
]]}
]]}
} } },
"DBInstance" : {
"Type": "AWS::RDS::DBInstance",
}
}
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
! CloudFormation  helpers

63

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormation  helpers
!   EC2インスタンス初期化時のヘルパースクリプト群
!   利利⽤用⽅方法
• 
• 
• 

Amazon  Linux  AMI
Yumリポジトリ
その他下記より

•  https://s3.amazonaws.com/cloudformation-‐‑‒examples/aws-‐‑‒cfn-‐‑‒bootstrap-‐‑‒
latest.amzn1.noarch.rpm
•  https://s3.amazonaws.com/cloudformation-‐‑‒examples/aws-‐‑‒cfn-‐‑‒bootstrap-‐‑‒
latest.tar.gz
•  https://s3.amazonaws.com/cloudformation-‐‑‒examples/aws-‐‑‒cfn-‐‑‒bootstrap-‐‑‒latest.zip
•  https://s3.amazonaws.com/cloudformation-‐‑‒examples/aws-‐‑‒cfn-‐‑‒bootstrap-‐‑‒latest.msi
•  https://s3.amazonaws.com/cloudformation-‐‑‒examples/aws-‐‑‒cfn-‐‑‒bootstrap-‐‑‒
latest.src.rpm

!   /opt/aws/bin  に格納
• 
• 
• 
• 

cfn-‐‑‒init
cfn-‐‑‒get-‐‑‒metadata
cfn-‐‑‒signal
cfn-‐‑‒hup

!   Python製

64

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
cfn-‐‑‒init
!   パッケージやファイルのダウンロード、ファイルの⽣生成を⾏行行うスク
リプト
!   実⾏行行のための設定は、Metadata領領域に定義
•  AWS::CloudFormation::Init
•  Configsets、Commands、Files、Groups、Packages、Services、
Sources、Users

"Resources": {
"MyInstance": {
"Type": "AWS::EC2::Instance",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
source,package,files,services
"sources" : { : },
の順に実⾏行行される
"packages" : { : }
"files" : { : }
"services" : { : } }
}
},
"Properties": { : }
}
65 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
!   sources

cfn-‐‑‒initの設定

•  指定したURLからファイルをダウンロードして展開
•  Tar,zip,tar+gzip,tar+bz2
"sources" : {
"/etc/myapp" : "https://s3.amazonaws.com/mybucket/myapp.tar.gz"
}

!   packages

§  パッケージシステムを使⽤用してアプリをインストール
§  Apt,yum,rubygems,python,rpm

"packages" : {
最新版
"yum" : {
"httpd" : [],
"php" : [],
バージョン
},
指定
"rubygems" : {
"chef" : [ "0.10.2" ],
}
}
66 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
!   files

cfn-‐‑‒initの設定

•  指定パスへのファイルの⽣生成

"files" : {
ファイルパス
"/app/db.conf" : {
"content" : { "Fn::Join" : ["", [
"db.name=", {"Ref" : "DBName"}, "n",
ファイルの中⾝身
"db.user=", {"Ref" : "DBUser"}, "n",
を⽣生成
"db.pass=", {"Ref" : "DBPassword" },"n",
"db.host=", {"Fn::GetAtt" : ["DBInstance", "Endpoint.Address"]}, "n",
]] },
"mode" : "000644",
"owner" : "root",
"group" : "root"
}
S3などから取得
"/etc/myapp/myapp-init.pp" : {
"source" : "https://s3.amazonaws.com/myapp/myapp-init.pp",
"mode" : "100644",
"owner" : "root",
"group" : "wheel"
}
}
67 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
!   services

cfn-‐‑‒initの設定

•  サービスの起動・再起動の指定
•  現在sysvinitのみ

OS起動時に起動さ
"services" : {
せるかどうか
"sysvinit" : {
"nginx" : {
"enabled" : "true",
cfn-‐‑‒init終了了後に起動するかどうか
"ensureRunning" : "true",
"files" : ["/etc/nginx/nginx.conf"],
"sources" : ["/var/www/html"]
設定ファイルもしくは指定ディ
},
レクトリのファイルが変わって
"php-fastcgi" : {
いた場合にサービス再起動する
"enabled" : "true",
"ensureRunning" : "true",
"packages" : { "yum" : ["php", "spawn-fcgi"] }
}
Cfg-‐‑‒initでパッケージを⼊入れて
}
いたらサービス再起動

68

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
cfn-‐‑‒initの起動
! cfn-‐‑‒initはデフォルトでは動作しない
!   User-‐‑‒dataにcfn-‐‑‒initを起動するスクリプトを記述して、
cloud-‐‑‒init経由で起動
!   引数にスタック名、リソース名、リージョン、アクセス
キー、シークレットキーを指定
"Properties": {
"UserData"
: { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bashn",
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" }, " -r WebServer ",
"
--access-key ", { "Ref" : "HostKeys" },
"
--secret-key ", {"Fn::GetAtt": ["HostKeys", "SecretAccessKey"]},
"
--region ", { "Ref" : "AWS::Region" }, "n",
]]}}
}

69

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
初期化シーケンス
EC2インスタンス起動

Init.dに登録してある
cloud-‐‑‒initが実⾏行行される
User-‐‑‒data領領域から、
スクリプトを読み込み
スクリプト内で、
cfn-‐‑‒initを呼び出し

70

cfn-‐‑‒init内で、meta-‐‑‒dataの読み込み

Meta-‐‑‒dataの設定に従い、
Sources(ファイルダウンロード)
Packages(インストール)
Files(設定作成)
Services(サービス)
を実⾏行行

起動完了了
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Chef(solo)との連携例例
EC2インスタンス起動

https://s3.amazonaws.com/cloudformation-‐‑‒
templates-‐‑‒us-‐‑‒east-‐‑‒1/wordpress-‐‑‒via-‐‑‒chef-‐‑‒
solo.template      
が分かりやすい例例(ただし、rubygem使⽤用)

cfn-‐‑‒init内で、meta-‐‑‒dataの読み込み
Init.dに登録してある
cloud-‐‑‒initが実⾏行行される
User-‐‑‒data領領域から、
スクリプトを読み込み
スクリプト内で、
cfn-‐‑‒initを呼び出し
スクリプト内で、
Chefを実⾏行行

71

Meta-‐‑‒dataの設定に従い、
Sources(レシピファイルダウンロード)
Packages(Omnibusでchefインストール)
Files(レシピの⼀一部書き換え)
を実⾏行行

ダウンロードしたレシピを元に、
chefがサーバ構築

起動完了了
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
その他スクリプト

! cfn-‐‑‒get-‐‑‒metadata

•  Metadataを簡単に取得出来るスクリプト

! cfn-‐‑‒signal

•  リソース「WaitCondition」と共に使⽤用
•  cfn-‐‑‒signalを使⽤用して、スタックに対して初期化状態の通知をす
ることが出来る
•  アプリのインストールが失敗した場合にスタックを破棄したり
できる

! cfn-‐‑‒hup

•  スタックを更更新(StackUpdateAPIを使⽤用)した場合に、それ
を感知して指定のファイルを実⾏行行するフックスクリプト
https://s3.amazonaws.com/cloudformation-‐‑‒examples/
BoostrappingApplicationsWithAWSCloudFormation.pdf

72

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
! CloudFormer

73

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormer
!   既に構築済みのシステム構成から、テンプレートを作成
するツール
!   テンプレート作成のベースとなるテンプレートを構築す
るのに利利⽤用可能

テンプレート
CloudFormer
EC2

EC2

AutoScaling

74

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormerの使い⽅方
!   既存の⼿手順やツールで必要なリソースを構成
!   CloudFormerスタックを作成し起動

•  CloudFormer⾃自⾝身がCloudFormationのスタックです。お客様
のAWS環境でスタックを起動することでCloudFormerが起動さ
れます。t1.maicro  EC2インスタンス上で実⾏行行されます。

!   CloudFormerを使⽤用して既存のAWSリソースからテン
プレートを⽣生成、結果はS3バケットに保存
!   CloudFormerスタックをシャットダウン
!   スタックを起動するために作成されたテンプレートを利利
⽤用ください

75

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormerの特⻑⾧長
!   CloudFormerは全てのCloudFormationのリソースをサ
ポート
!   CloudFormerは⾃自動的に従属するリソースを選択
•  例例えば、EC2インスタンスを選択すると、EC2インスタンスが
必要とするセキュリティグループもリソースとして選択

!   どのリソースをテンプレートに含めるか完全に制御可能
!   必要であれば⾃自動的に選択されたリソースを上書きした
り、他のリソースを追加したり可能
!   テンプレートで⽤用いられる名前を指定可能
!   標準の名前は、既存のリソースの名前に基づく
!   リソースの利利⽤用可能なアトリビュートからOutputパラ
メータを追加可能
76

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormerスタックを作成し起動
!   以下のいずれかからスタックを作成
•  AWS  CloudFormation  コンソール

•  サンプルテンプレートから、”  CloudFormer  -‐‑‒  create  a  template  
from  your  existing  resources”を選択

•  CloudFormerツールのページ

•  http://aws.amazon.com/developertools/6460180344805680

•  AWS  CloudFormationテンプレートページ

•  http://aws.amazon.com/cloudformation/aws-‐‑‒
cloudformation-‐‑‒templates/

!   作成したスタックを起動

•  CloudFormerスタックのOutput、”URL”をクリック

77

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormer起動

78

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormer実⾏行行⽅方法
!   テンプレート化したいリージョンを選ぶと、ウィザード形
式でリソースの選択が可能
!   チェックボックスを⼊入れたリソースを元にテンプレートが完
成

79

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
!  その他Tips

80

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Baked  AMI    VS  CF-‐‑‒Init
!   AMIの作り込み  VS  Cloud-‐‑‒init+CloudFormation  
helpers
!   ⽤用途によって、AMI作り込み、cloud-‐‑‒init、helperを使
い分ける事が重要
利点

欠点

AMI作り込み

・構築が容易
・起動が速い
 (オートスケールに有効)

・ベースAMI/ミドルウェア
 更新時に再インストールが必要
・リージョン毎の構築が必要

ベースAMI+
Cloud-init+CFN
helpers

・ベースAMI/ミドルウェア更新時  
 に追従が可能
・DBのエンドポイントなどの
 定義が渡せる

・テンプレート構築が手間
・OS初期化に時間がかかる

81

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
IAM  Capability
! CloudFormationでIAMユーザーを作成する場合、ウィザー
ド途中でチェックボックスをonにする必要がある
•  cfn-‐‑‒create-‐‑‒stackおよびcfn-‐‑‒update-‐‑‒stackの場合は、  
    「-‐‑‒-‐‑‒capalilities  CAPABILITY_̲IAM」をコマンドに付与

82

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
!  まとめ

83

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormation利利⽤用のFAQ
!   テンプレートまたはスタック数に制限はありますか?

•  テンプレート数に制限はありません。アカウントに対して、ス
タックの最⼤大数は20に制限。

!   説明フィールドの⽂文字数に制限はありますか?

•  テンプレート、パラメータ、出⼒力力、およびリソースの説明⽤用の
フィールドは、4,096⽂文字に制限。

!   テンプレートのパラメータ、出⼒力力の数に制限はあります
か?
•  50のパラメータおよび10の出⼒力力。

84
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
まとめ
! CloudFormationを使⽤用すると、システム構成をテンプ
レート化できる
! AmazonLinuxにはOS初期化のための仕組みが⽤用意され
ている
!   cloud-‐‑‒initとcfnヘルパー、またchefなどを
CloudFormationと組み合わせると、アプリケーション
のセットアップも柔軟に可能
!   システム構築の発想を変えてみる
•  OSは素材
•  テンプレート化で、よりクラウドの特性を⽣生かしたシステム構
築が可能に!

85

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
CloudFormationで
真のクラウドマイスターを⽬目指せ!
App
Serve
r

86

Web
Serve
r

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
参考URL
!   Cloud  Formation  Samples

•  http://aws.amazon.com/jp/cloudformation/aws-‐‑‒
cloudformation-‐‑‒templates/

!   AWS  CloudFormation  のアーティクルとチュートリア
ル
•  http://aws.amazon.com/jp/cloudformation/aws-‐‑‒
cloudformation-‐‑‒articles-‐‑‒and-‐‑‒tutorials/
•  BootstrappingApplicationsWithAWSCloudFormation

•  https://s3.amazonaws.com/cloudformation-‐‑‒examples/
BoostrappingApplicationsWithAWSCloudFormation.pdf

•  Integrating  CloudFormation  with  Chef

•  https://s3.amazonaws.com/cloudformation-‐‑‒examples/
IntegratingAWSCloudFormationWithOpscodeChef.pdf

!   AWS  CloudFormation  よくある質問

•  http://aws.amazon.com/jp/cloudformation/faqs/

87

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

More Related Content

What's hot

20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model  20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model Amazon Web Services Japan
 
ビッグデータサービス群のおさらい & AWS Data Pipeline
ビッグデータサービス群のおさらい & AWS Data Pipelineビッグデータサービス群のおさらい & AWS Data Pipeline
ビッグデータサービス群のおさらい & AWS Data PipelineAmazon Web Services Japan
 
20190806 AWS Black Belt Online Seminar AWS Glue
20190806 AWS Black Belt Online Seminar AWS Glue20190806 AWS Black Belt Online Seminar AWS Glue
20190806 AWS Black Belt Online Seminar AWS GlueAmazon Web Services Japan
 
Amazon Pinpoint × グロースハック活用事例集
Amazon Pinpoint × グロースハック活用事例集Amazon Pinpoint × グロースハック活用事例集
Amazon Pinpoint × グロースハック活用事例集Amazon Web Services Japan
 
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)Amazon Web Services Japan
 
Aws auto scalingによるwebapサーバbatchサーバの構成例
Aws auto scalingによるwebapサーバbatchサーバの構成例Aws auto scalingによるwebapサーバbatchサーバの構成例
Aws auto scalingによるwebapサーバbatchサーバの構成例Takeshi Mikami
 
ぼくらのアカウント戦略〜マルチアカウントでのガバナンスと権限管理の全て〜
ぼくらのアカウント戦略〜マルチアカウントでのガバナンスと権限管理の全て〜ぼくらのアカウント戦略〜マルチアカウントでのガバナンスと権限管理の全て〜
ぼくらのアカウント戦略〜マルチアカウントでのガバナンスと権限管理の全て〜Mamoru Ohashi
 
20200617 AWS Black Belt Online Seminar Amazon Athena
20200617 AWS Black Belt Online Seminar Amazon Athena20200617 AWS Black Belt Online Seminar Amazon Athena
20200617 AWS Black Belt Online Seminar Amazon AthenaAmazon Web Services Japan
 
VPC Reachability Analyzer 使って人生が変わった話
VPC Reachability Analyzer 使って人生が変わった話VPC Reachability Analyzer 使って人生が変わった話
VPC Reachability Analyzer 使って人生が変わった話Noritaka Sekiyama
 
20190326 AWS Black Belt Online Seminar Amazon CloudWatch
20190326 AWS Black Belt Online Seminar Amazon CloudWatch20190326 AWS Black Belt Online Seminar Amazon CloudWatch
20190326 AWS Black Belt Online Seminar Amazon CloudWatchAmazon Web Services Japan
 
Amazon Aurora - Auroraの止まらない進化とその中身
Amazon Aurora - Auroraの止まらない進化とその中身Amazon Aurora - Auroraの止まらない進化とその中身
Amazon Aurora - Auroraの止まらない進化とその中身Amazon Web Services Japan
 
AWS Black Belt Online Seminar 2017 AWS Storage Gateway
AWS Black Belt Online Seminar 2017 AWS Storage GatewayAWS Black Belt Online Seminar 2017 AWS Storage Gateway
AWS Black Belt Online Seminar 2017 AWS Storage GatewayAmazon Web Services Japan
 
20191016 AWS Black Belt Online Seminar Amazon Route 53 Resolver
20191016 AWS Black Belt Online Seminar Amazon Route 53 Resolver20191016 AWS Black Belt Online Seminar Amazon Route 53 Resolver
20191016 AWS Black Belt Online Seminar Amazon Route 53 ResolverAmazon Web Services Japan
 
AWS Black Belt Online Seminar 2017 Amazon Pinpoint で始めるモバイルアプリのグロースハック
AWS Black Belt Online Seminar 2017 Amazon Pinpoint で始めるモバイルアプリのグロースハックAWS Black Belt Online Seminar 2017 Amazon Pinpoint で始めるモバイルアプリのグロースハック
AWS Black Belt Online Seminar 2017 Amazon Pinpoint で始めるモバイルアプリのグロースハックAmazon Web Services Japan
 
少しでもセキュリティを向上させたい! Mauticの運用方法
少しでもセキュリティを向上させたい! Mauticの運用方法少しでもセキュリティを向上させたい! Mauticの運用方法
少しでもセキュリティを向上させたい! Mauticの運用方法Jun Katayama
 
20190313 AWS Black Belt Online Seminar Amazon VPC Basic
20190313 AWS Black Belt Online Seminar Amazon VPC Basic20190313 AWS Black Belt Online Seminar Amazon VPC Basic
20190313 AWS Black Belt Online Seminar Amazon VPC BasicAmazon Web Services Japan
 
AWS Black Belt Tech シリーズ 2016 - Amazon SES
AWS Black Belt Tech シリーズ 2016 - Amazon SESAWS Black Belt Tech シリーズ 2016 - Amazon SES
AWS Black Belt Tech シリーズ 2016 - Amazon SESAmazon Web Services Japan
 
20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)
20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)
20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)Amazon Web Services Japan
 
EC2のストレージどう使う? -Instance Storageを理解して高速IOを上手に活用!-
EC2のストレージどう使う? -Instance Storageを理解して高速IOを上手に活用!-EC2のストレージどう使う? -Instance Storageを理解して高速IOを上手に活用!-
EC2のストレージどう使う? -Instance Storageを理解して高速IOを上手に活用!-Yuta Imai
 
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
20190220 AWS Black Belt Online Seminar Amazon S3 / GlacierAmazon Web Services Japan
 

What's hot (20)

20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model  20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
 
ビッグデータサービス群のおさらい & AWS Data Pipeline
ビッグデータサービス群のおさらい & AWS Data Pipelineビッグデータサービス群のおさらい & AWS Data Pipeline
ビッグデータサービス群のおさらい & AWS Data Pipeline
 
20190806 AWS Black Belt Online Seminar AWS Glue
20190806 AWS Black Belt Online Seminar AWS Glue20190806 AWS Black Belt Online Seminar AWS Glue
20190806 AWS Black Belt Online Seminar AWS Glue
 
Amazon Pinpoint × グロースハック活用事例集
Amazon Pinpoint × グロースハック活用事例集Amazon Pinpoint × グロースハック活用事例集
Amazon Pinpoint × グロースハック活用事例集
 
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
 
Aws auto scalingによるwebapサーバbatchサーバの構成例
Aws auto scalingによるwebapサーバbatchサーバの構成例Aws auto scalingによるwebapサーバbatchサーバの構成例
Aws auto scalingによるwebapサーバbatchサーバの構成例
 
ぼくらのアカウント戦略〜マルチアカウントでのガバナンスと権限管理の全て〜
ぼくらのアカウント戦略〜マルチアカウントでのガバナンスと権限管理の全て〜ぼくらのアカウント戦略〜マルチアカウントでのガバナンスと権限管理の全て〜
ぼくらのアカウント戦略〜マルチアカウントでのガバナンスと権限管理の全て〜
 
20200617 AWS Black Belt Online Seminar Amazon Athena
20200617 AWS Black Belt Online Seminar Amazon Athena20200617 AWS Black Belt Online Seminar Amazon Athena
20200617 AWS Black Belt Online Seminar Amazon Athena
 
VPC Reachability Analyzer 使って人生が変わった話
VPC Reachability Analyzer 使って人生が変わった話VPC Reachability Analyzer 使って人生が変わった話
VPC Reachability Analyzer 使って人生が変わった話
 
20190326 AWS Black Belt Online Seminar Amazon CloudWatch
20190326 AWS Black Belt Online Seminar Amazon CloudWatch20190326 AWS Black Belt Online Seminar Amazon CloudWatch
20190326 AWS Black Belt Online Seminar Amazon CloudWatch
 
Amazon Aurora - Auroraの止まらない進化とその中身
Amazon Aurora - Auroraの止まらない進化とその中身Amazon Aurora - Auroraの止まらない進化とその中身
Amazon Aurora - Auroraの止まらない進化とその中身
 
AWS Black Belt Online Seminar 2017 AWS Storage Gateway
AWS Black Belt Online Seminar 2017 AWS Storage GatewayAWS Black Belt Online Seminar 2017 AWS Storage Gateway
AWS Black Belt Online Seminar 2017 AWS Storage Gateway
 
20191016 AWS Black Belt Online Seminar Amazon Route 53 Resolver
20191016 AWS Black Belt Online Seminar Amazon Route 53 Resolver20191016 AWS Black Belt Online Seminar Amazon Route 53 Resolver
20191016 AWS Black Belt Online Seminar Amazon Route 53 Resolver
 
AWS Black Belt Online Seminar 2017 Amazon Pinpoint で始めるモバイルアプリのグロースハック
AWS Black Belt Online Seminar 2017 Amazon Pinpoint で始めるモバイルアプリのグロースハックAWS Black Belt Online Seminar 2017 Amazon Pinpoint で始めるモバイルアプリのグロースハック
AWS Black Belt Online Seminar 2017 Amazon Pinpoint で始めるモバイルアプリのグロースハック
 
少しでもセキュリティを向上させたい! Mauticの運用方法
少しでもセキュリティを向上させたい! Mauticの運用方法少しでもセキュリティを向上させたい! Mauticの運用方法
少しでもセキュリティを向上させたい! Mauticの運用方法
 
20190313 AWS Black Belt Online Seminar Amazon VPC Basic
20190313 AWS Black Belt Online Seminar Amazon VPC Basic20190313 AWS Black Belt Online Seminar Amazon VPC Basic
20190313 AWS Black Belt Online Seminar Amazon VPC Basic
 
AWS Black Belt Tech シリーズ 2016 - Amazon SES
AWS Black Belt Tech シリーズ 2016 - Amazon SESAWS Black Belt Tech シリーズ 2016 - Amazon SES
AWS Black Belt Tech シリーズ 2016 - Amazon SES
 
20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)
20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)
20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)
 
EC2のストレージどう使う? -Instance Storageを理解して高速IOを上手に活用!-
EC2のストレージどう使う? -Instance Storageを理解して高速IOを上手に活用!-EC2のストレージどう使う? -Instance Storageを理解して高速IOを上手に活用!-
EC2のストレージどう使う? -Instance Storageを理解して高速IOを上手に活用!-
 
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
 

Similar to [AWSマイスターシリーズ] AWS CloudFormation

Amazon EC2を使った実践SaaS運用事例
Amazon EC2を使った実践SaaS運用事例Amazon EC2を使った実践SaaS運用事例
Amazon EC2を使った実践SaaS運用事例Yuuki Namikawa
 
[AWSマイスターシリーズ] Amazon Elastic Compute Cloud (EC2) Windows編
[AWSマイスターシリーズ] Amazon Elastic Compute Cloud (EC2) Windows編[AWSマイスターシリーズ] Amazon Elastic Compute Cloud (EC2) Windows編
[AWSマイスターシリーズ] Amazon Elastic Compute Cloud (EC2) Windows編Amazon Web Services Japan
 
AWSマイスターシリーズReloaded -AWS SDK for .NET-
AWSマイスターシリーズReloaded -AWS SDK for .NET-AWSマイスターシリーズReloaded -AWS SDK for .NET-
AWSマイスターシリーズReloaded -AWS SDK for .NET-Amazon Web Services Japan
 
AWS で Presto を徹底的に使いこなすワザ
AWS で Presto を徹底的に使いこなすワザAWS で Presto を徹底的に使いこなすワザ
AWS で Presto を徹底的に使いこなすワザNoritaka Sekiyama
 
20140924イグレックcioセミナーpublic
20140924イグレックcioセミナーpublic20140924イグレックcioセミナーpublic
20140924イグレックcioセミナーpublicjunkoy66
 
いまさら聞けない Amazon EC2
いまさら聞けない Amazon EC2いまさら聞けない Amazon EC2
いまさら聞けない Amazon EC2Yasuhiro Matsuo
 
AWS Black Belt Online Seminar 2017 EC2 Windows
AWS Black Belt Online Seminar 2017 EC2 WindowsAWS Black Belt Online Seminar 2017 EC2 Windows
AWS Black Belt Online Seminar 2017 EC2 WindowsAmazon Web Services Japan
 
Best Practices for Running PostgreSQL on AWS
Best Practices for Running PostgreSQL on AWSBest Practices for Running PostgreSQL on AWS
Best Practices for Running PostgreSQL on AWSAmazon Web Services Japan
 
[AWSマイスターシリーズ] AWS OpsWorks
[AWSマイスターシリーズ] AWS OpsWorks[AWSマイスターシリーズ] AWS OpsWorks
[AWSマイスターシリーズ] AWS OpsWorksAmazon Web Services Japan
 
[最新版は別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar AWS re:Inven...
[最新版は別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar AWS re:Inven...[最新版は別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar AWS re:Inven...
[最新版は別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar AWS re:Inven...Amazon Web Services Japan
 
[最新版(12/5 最新版) が別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar A...
[最新版(12/5 最新版) が別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar A...[最新版(12/5 最新版) が別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar A...
[最新版(12/5 最新版) が別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar A...Amazon Web Services Japan
 
【12/5 最新版】AWS Black Belt Online Seminar AWS re:Invent 2018 アップデート情報
【12/5 最新版】AWS Black Belt Online Seminar AWS re:Invent 2018 アップデート情報【12/5 最新版】AWS Black Belt Online Seminar AWS re:Invent 2018 アップデート情報
【12/5 最新版】AWS Black Belt Online Seminar AWS re:Invent 2018 アップデート情報Amazon Web Services Japan
 
[AWSマイスターシリーズ] AWS SDK for Java / .NET
[AWSマイスターシリーズ] AWS SDK for Java / .NET[AWSマイスターシリーズ] AWS SDK for Java / .NET
[AWSマイスターシリーズ] AWS SDK for Java / .NETAmazon Web Services Japan
 
AWS Black Belt Online Seminar 2017 Amazon EC2 Systems Manager
AWS Black Belt Online Seminar 2017 Amazon EC2 Systems ManagerAWS Black Belt Online Seminar 2017 Amazon EC2 Systems Manager
AWS Black Belt Online Seminar 2017 Amazon EC2 Systems ManagerAmazon Web Services Japan
 
AWS Black Belt Techシリーズ Amazon Elastic Compute Cloud (Amazon EC2)
AWS Black Belt Techシリーズ Amazon Elastic Compute Cloud (Amazon EC2)AWS Black Belt Techシリーズ Amazon Elastic Compute Cloud (Amazon EC2)
AWS Black Belt Techシリーズ Amazon Elastic Compute Cloud (Amazon EC2)Amazon Web Services Japan
 
AWSではじめるMLOps
AWSではじめるMLOpsAWSではじめるMLOps
AWSではじめるMLOpsMariOhbuchi
 
[AWSマイスターシリーズ] AWS Elastic Beanstalk -Python編-
[AWSマイスターシリーズ] AWS Elastic Beanstalk -Python編-[AWSマイスターシリーズ] AWS Elastic Beanstalk -Python編-
[AWSマイスターシリーズ] AWS Elastic Beanstalk -Python編-Amazon Web Services Japan
 
アマゾンクラウドの真価
アマゾンクラウドの真価アマゾンクラウドの真価
アマゾンクラウドの真価kaminashi
 
20151030 オープンデータとセキュリティon aws
20151030 オープンデータとセキュリティon aws20151030 オープンデータとセキュリティon aws
20151030 オープンデータとセキュリティon awstakaoka susumu
 

Similar to [AWSマイスターシリーズ] AWS CloudFormation (20)

Amazon EC2を使った実践SaaS運用事例
Amazon EC2を使った実践SaaS運用事例Amazon EC2を使った実践SaaS運用事例
Amazon EC2を使った実践SaaS運用事例
 
[AWSマイスターシリーズ] Amazon Elastic Compute Cloud (EC2) Windows編
[AWSマイスターシリーズ] Amazon Elastic Compute Cloud (EC2) Windows編[AWSマイスターシリーズ] Amazon Elastic Compute Cloud (EC2) Windows編
[AWSマイスターシリーズ] Amazon Elastic Compute Cloud (EC2) Windows編
 
AWSマイスターシリーズReloaded -AWS SDK for .NET-
AWSマイスターシリーズReloaded -AWS SDK for .NET-AWSマイスターシリーズReloaded -AWS SDK for .NET-
AWSマイスターシリーズReloaded -AWS SDK for .NET-
 
AWS で Presto を徹底的に使いこなすワザ
AWS で Presto を徹底的に使いこなすワザAWS で Presto を徹底的に使いこなすワザ
AWS で Presto を徹底的に使いこなすワザ
 
20140924イグレックcioセミナーpublic
20140924イグレックcioセミナーpublic20140924イグレックcioセミナーpublic
20140924イグレックcioセミナーpublic
 
いまさら聞けない Amazon EC2
いまさら聞けない Amazon EC2いまさら聞けない Amazon EC2
いまさら聞けない Amazon EC2
 
AWS Black Belt Online Seminar 2017 EC2 Windows
AWS Black Belt Online Seminar 2017 EC2 WindowsAWS Black Belt Online Seminar 2017 EC2 Windows
AWS Black Belt Online Seminar 2017 EC2 Windows
 
Best Practices for Running PostgreSQL on AWS
Best Practices for Running PostgreSQL on AWSBest Practices for Running PostgreSQL on AWS
Best Practices for Running PostgreSQL on AWS
 
[AWSマイスターシリーズ] AWS OpsWorks
[AWSマイスターシリーズ] AWS OpsWorks[AWSマイスターシリーズ] AWS OpsWorks
[AWSマイスターシリーズ] AWS OpsWorks
 
[最新版は別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar AWS re:Inven...
[最新版は別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar AWS re:Inven...[最新版は別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar AWS re:Inven...
[最新版は別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar AWS re:Inven...
 
[最新版(12/5 最新版) が別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar A...
[最新版(12/5 最新版) が別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar A...[最新版(12/5 最新版) が別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar A...
[最新版(12/5 最新版) が別にございます! Descriptionをご確認ください] AWS Black Belt Online Seminar A...
 
【12/5 最新版】AWS Black Belt Online Seminar AWS re:Invent 2018 アップデート情報
【12/5 最新版】AWS Black Belt Online Seminar AWS re:Invent 2018 アップデート情報【12/5 最新版】AWS Black Belt Online Seminar AWS re:Invent 2018 アップデート情報
【12/5 最新版】AWS Black Belt Online Seminar AWS re:Invent 2018 アップデート情報
 
AWS SDK for Android and iOS
AWS SDK for Android and iOSAWS SDK for Android and iOS
AWS SDK for Android and iOS
 
[AWSマイスターシリーズ] AWS SDK for Java / .NET
[AWSマイスターシリーズ] AWS SDK for Java / .NET[AWSマイスターシリーズ] AWS SDK for Java / .NET
[AWSマイスターシリーズ] AWS SDK for Java / .NET
 
AWS Black Belt Online Seminar 2017 Amazon EC2 Systems Manager
AWS Black Belt Online Seminar 2017 Amazon EC2 Systems ManagerAWS Black Belt Online Seminar 2017 Amazon EC2 Systems Manager
AWS Black Belt Online Seminar 2017 Amazon EC2 Systems Manager
 
AWS Black Belt Techシリーズ Amazon Elastic Compute Cloud (Amazon EC2)
AWS Black Belt Techシリーズ Amazon Elastic Compute Cloud (Amazon EC2)AWS Black Belt Techシリーズ Amazon Elastic Compute Cloud (Amazon EC2)
AWS Black Belt Techシリーズ Amazon Elastic Compute Cloud (Amazon EC2)
 
AWSではじめるMLOps
AWSではじめるMLOpsAWSではじめるMLOps
AWSではじめるMLOps
 
[AWSマイスターシリーズ] AWS Elastic Beanstalk -Python編-
[AWSマイスターシリーズ] AWS Elastic Beanstalk -Python編-[AWSマイスターシリーズ] AWS Elastic Beanstalk -Python編-
[AWSマイスターシリーズ] AWS Elastic Beanstalk -Python編-
 
アマゾンクラウドの真価
アマゾンクラウドの真価アマゾンクラウドの真価
アマゾンクラウドの真価
 
20151030 オープンデータとセキュリティon aws
20151030 オープンデータとセキュリティon aws20151030 オープンデータとセキュリティon aws
20151030 オープンデータとセキュリティon aws
 

More from Amazon Web Services Japan

202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)Amazon Web Services Japan
 
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFSAmazon Web Services Japan
 
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
202204 AWS Black Belt Online Seminar AWS IoT Device Defender202204 AWS Black Belt Online Seminar AWS IoT Device Defender
202204 AWS Black Belt Online Seminar AWS IoT Device DefenderAmazon Web Services Japan
 
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現Amazon Web Services Japan
 
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...Amazon Web Services Japan
 
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデートAmazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデートAmazon Web Services Japan
 
20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したことAmazon Web Services Japan
 
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用Amazon Web Services Japan
 
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdfAmazon Web Services Japan
 
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介Amazon Web Services Japan
 
Amazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDDAmazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDDAmazon Web Services Japan
 
マルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのことマルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのことAmazon Web Services Japan
 
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチAmazon Web Services Japan
 
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介Amazon Web Services Japan
 
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer ProfilesAmazon Web Services Japan
 
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するためにAmazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するためにAmazon Web Services Japan
 
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨Amazon Web Services Japan
 
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介Amazon Web Services Japan
 
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介Amazon Web Services Japan
 

More from Amazon Web Services Japan (20)

202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
 
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
 
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
202204 AWS Black Belt Online Seminar AWS IoT Device Defender202204 AWS Black Belt Online Seminar AWS IoT Device Defender
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
 
Infrastructure as Code (IaC) 談義 2022
Infrastructure as Code (IaC) 談義 2022Infrastructure as Code (IaC) 談義 2022
Infrastructure as Code (IaC) 談義 2022
 
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
 
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
 
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデートAmazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
 
20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと
 
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
 
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
 
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
 
Amazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDDAmazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDD
 
マルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのことマルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのこと
 
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
 
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
 
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
 
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するためにAmazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
 
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
 
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
 
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
 

Recently uploaded

Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルCRI Japan, Inc.
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイスCRI Japan, Inc.
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NTT DATA Technology & Innovation
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)Hiroshi Tomioka
 

Recently uploaded (7)

Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
 

[AWSマイスターシリーズ] AWS CloudFormation

  • 1. re:G ene rate AWS  マイスターシリーズ   AWS  CloudFormation   2013.11.27 アマゾン  データ  サービス  ジャパン株式会社 ソリューションアーキテクト  吉荒  祐⼀一 © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 2. 2013年年 CloudFormationのアップデート !   2013/2/7 •  Amazon  S3  と  Amazon  RDSのタグ付けが可能に !   2013/2/20 •  EBS-‐‑‒Optimized  EC2インスタンスのプロビジョニング •  Auto  Scaling  Groupのローリングデプロイ •  スタックアップデートのキャンセル !   2013/8/12 •  並列列スタック処理理とネストされたスタックの更更新の追加 !   2013/9/17 •  追加のVPCサポートと新テンプレート !   2013/10/14 •  フェデレーテッドユーザーおよび⼀一時的なセキュリティ認証情報が 利利⽤用可能に 2 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 3. Agenda ! CloudFormationの概要 !   スタック !   テンプレート !   Cloud-‐‑‒init ! CloudFormation  helpers ! CloudFormer !   その他Tips !   まとめ 3 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 4. !  CloudFormationの概要 4 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 5. AWS  CloudFormation !   EC2やELBなどを使ったAWSサービスのシステム構築を、 設定ファイル(テンプレート)を元に⾏行行えるサービス !   テンプレートを⾃自由に作成できるため、⾃自分好みのシス テム構成が可能 !   テンプレートは、AWSのサービスを操るための新しい⾔言 語 5 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 6. AWS  CloudFormationのイメージ テンプレートに基づき 各サービスが起動 スタック Elastic  Load  Balancing テンプレート S3 Cloud Formation SNS EC2 EC2 Auto  Scaling 6 CloudWatch © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 7. 利利⽤用シーンと利利点 !   ⼀一度度テンプレートを作成すれば、同じ構成を再現できる •  開発環境の構築 •  Blogシステム、Webシステム、ゲームプラットフォームなど、 同じ仕組みでアプリやデータが異異なるようなもの !   ベストプラクティスが盛り込まれたテンプレートが使⽤用 可能 •  システムアーキテクチャの再利利⽤用 •  WordPress,  Redmineなどが⼊入った、多くのサンプルテンプ レートが提供済み !   起動時にパラメータを渡せる •  例例えばDBのエンドポイントをEC2に渡せる 7 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 8. 利利⽤用料料⾦金金 ! CloudFormationの利利⽤用⾃自体は無料料 !   テンプレートに従って構築された各AWSサービスに対し て課⾦金金 8 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 9. AWSの構築・デプロイ⾃自動化サービスの 中での位置づけ 導⼊入の容易易さ Elastic  Beanstalk OpsWorks CloudFormation フレキシビリティ 9 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 10. CloudFormationに適した場⾯面 !   幅広いリソースを使い環境構築する場合 •  エンタープライズアプリケーション •  レガシーアプリケーション •  他の⾃自動化サービスではサポートされないリソースを使⽤用 ! ElasticBeanstalkと組み合わせて構築する場合 •  リソースのひとつとして、ElasticBeanstalkをサポート 10 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 11. !  スタック 11 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 12. スタック !   リソース(EC2インスタンスやS3バケット、RDSインスタンスな ど)の集合のこと !   スタック単位でリソースの管理理が可能。スタック破棄を実⾏行行すると、 スタックにひもづくリソースを破棄することが可能 !   使⽤用するリソースおよびリソースの構築順は、テンプレートの依存 関係で決定 スタック これらを⼀一度度に⽣生成・破棄可能 App Serve r 12 Web Serve r © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 13. スタック可能なリソースタイプ !   Amazon  EC2  インスタンス !   Amazon  EC2  セキュリティグループ !   Amazon  Elastic  Block  Store(EBS) ボリューム !   Elastic  Load  Balancers !   Amazon  EC2  Elastic  IP  アドレス !   Auto  Scaling  グループ !   Auto  Scaling  ポリシー !   Amazon  RDS   データベースインスタンス !   Amazon  RDS  パラメータグループ !   Amazon  RDS  セキュリティグループ !   Amazon  DynamoDB !   Amazon  SimpleDB  ドメイン !   Amazon  SQS  キュー !   Amazon  SNS  トピック !   Amazon  SNS  サブスクリプション 13 ! ! ! !         !  !  !  !  !  !  AWS  Elastic  Beanstalk Amazon  CloudWatch  アラーム Amazon  Route  53  DNS  レコード Amazon  CloudFront   ディストリビューション Amazon  S3  バケット AWS  Identity  and  Access   Management  ユーザー、グループ、 およびポリシー Amazon  ElastiCache   キャッシュクラスタ Amazon  ElastiCache   キャッシュセキュリティグループ Amazon  ElastiCache   キャッシュパラメータグループ Amazon  Virtual  Private  Cloud  VPC、 サブネット、ゲートウェイ、ルートテー ブル、およびネットワーク  ACL © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 14. スタック構築⽅方法 !   AWS  Management  Consoleから構築 !   コマンドラインツール •  AWS  Command  Line  Tool •  http://aws.amazon.com/cli/ !   各種SDK Java  :  http://aws.amazon.com/jp/sdkforjava/ .NET  :  http://aws.amazon.com/jp/sdkfornet/ PHP    :  http://aws.amazon.com/jp/sdkforphp/ Ruby  :   http://docs.aws.amazon.com/AWSSdkDocsRuby/latest/ DeveloperGuide/ruby-‐‑‒dg-‐‑‒setup.html •  JavaScript  :   http://aws.amazon.com/documentation/sdkforjavascript/ •  Python  :  http://docs.pythonboto.org/en/latest/ •  •  •  •  14 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 15. スタック構築⽅方法:もうひとつの視点 !   既存のテンプレートから構築 •  ローカルファイル •  S3上のファイル !   サンプルテンプレートから構築 •  http://aws.amazon.com/cloudformation/aws-‐‑‒ cloudformation-‐‑‒templates/ !   ゼロから新しいものを作る !   テンプレートはテキストファイルとして作成、管理理、共 有可能 15 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 16. AWS  Management  Consoleから構築-‐‑‒1 16 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 17. AWS  Management  Consoleから構築-‐‑‒2 スタックの名称 ・サンプルテンプレート ・ローカルファイルの   テンプレート いずれか ・テンプレートファイルURL (同⼀一リージョンのS3上) 17 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 18. AWS  Management  Consoleから構築-‐‑‒3 各種パラメータの⼊入⼒力力 (後で説明) 18 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 19. AWS  Management  Consoleから構築-‐‑‒4 リソースにタグ付け 19 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 20. AWS  Management  Consoleから構築-‐‑‒5 20 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 21. AWS  Management  Consoleから構築-‐‑‒6 スタックのコスト⾒見見積もり 21 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 22. AWS  Management  Consoleから構築-‐‑‒7 スタック構築開始 22 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 23. AWS  Management  Consoleから構築-‐‑‒8 23 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 24. AWS  Management  Consoleから構築-‐‑‒9 スタック構築実⾏行行中 24 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 25. AWS  Management  Consoleから構築-‐‑‒10 スタック構築完了了 この時点ですべてのサービスが 起動している 25 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 26. AWS  Management  Consoleから構築-‐‑‒11 スタック構築失敗 ロールバック中 26 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 27. !  テンプレート 27 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 28. { "AWSTemplateFormatVersion" : "2010-09-09", テンプレート "Description" : “Sample", "Parameters" : { "KeyName" : { "Description" : “Sample key, "Type" : "String" } }, "Mappings" : { }, ! CloudFormationの⼼心臓部 !   スタック構築の設計図 !   JSONフォーマットで記述 "Resources" : { "Ec2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ], "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]} } }, "InstanceSecurityGroup" : { "Type" : "AWS::EC2::SecurityGroup", "Properties" : { "GroupDescription" : "Enable SSH access via port 22", "SecurityGroupIngress" : [ { "IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" }] } } } 28 } © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 29. テンプレート解説 "AWSTemplateFormatVersion" : “2010-09-09", テンプレートのバージョン (最新は2010-‐‑‒09-‐‑‒09) "Description" : "Valid JSON strings up to 4K", テンプレートの詳細(説明⽂文) { "Parameters" : { set of parameters }, "Mappings" : { set of mappings }, “Conditions" : { set of conditions }, "Resources" : { set of resources }, "Outputs" : { set of outputs } } 29 CloudFormation実⾏行行時に 後で変更更可能なパラメータを列列挙 (例例:DBユーザー名など) Hashtableのようなもの キーに応じて値を特定出来る (例例:リージョンに応じたAMI番号など) Parameters、他のCondition、Mappingから 条件判断し結果に応じてリソースを作成可能 EC2やRDSなど、スタックを構成する リソースを定義 スタック構築後に取得したい値 (例例:アクセスURLなど) © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 30. Parameters { "AWSTemplateFormatVersion" : “2010-09-09", "Description" : "Valid JSON strings up to 4K", "Parameters" : { set of parameters }, "Mappings" : { set of mappings }, “Conditions" : { set of conditions }, "Resources" : { set of resources }, CloudFormation実⾏行行時に 後で変更更可能なパラメータを列列挙 (例例:DBユーザー名など) "Outputs" : { set of outputs } } 30 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 31. Parametersとは !   スタック構築時に値の⼊入⼒力力が可能 !   データ型、デフォルト値、最⼩小最⼤大値など設定可能 "Parameters" : { "Age":{ "Type":"Number", “Default” : “30”, “MinValue”: “20”, “MaxValue”: “60”, "Description":"input your age.“ }, "FirstName":{ "Type":"String", "Description":"input your first name.“ }, } 31 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 32. Parametersのプロパティ !   利利⽤用出来るプロパティ プロパティ Type データ型    “String”  “Number”    “CommaDelimitedList” Default デフォルト値 NoEcho ⼊入⼒力力時に*****となる(パスワードなどに使⽤用) AllowedValues ⼊入⼒力力可能値の⼀一覧指定  (例例:[“true”,”false”]  ) AllowedPattern 正規表現で⼊入⼒力力可能パターンを指定(例例:[a-‐‑‒zA-‐‑‒Z]*) MaxLength 最⼤大⽂文字数 MinLength 最⼩小⽂文字数 MaxValue 最⼤大値 MinValue 最⼩小値 Description プロパティの詳細説明 ConstraintDescription 32 内容 ⼊入⼒力力した値がAllowedPatternやMaxLengthなどの制約に 引っかかった時に表⽰示する説明 (どのような制約があるかの説明を記述) © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 33. Parametersの参照 !   ⼊入⼒力力したパラメータ値は、テンプレート中で  “Ref”を使 ⽤用して参照可能 !   ユーザー名、パスワード、ドメインなどの可変部分に便便 利利 ここにパラメータ⼊入⼒力力値が反映される “Resources" : { “MyServer":{ “Type":“AWS::EC2::Instance", “Properties” : { “KeyName”: { “Ref” : “Age”}, “Tags” : { “Ref” : “FirstName”} } } } 33 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 34. !  ! ! ! ! ! ! !  Function Ref •  パラメータを参照する Fn::Base64 •  ⽂文字列列をBase64エンコードする Fn::FindInMap •  Mapから値を取り出す Fn::GetAtt •  リソースから属性を取り出す •  例例:"Fn::GetAtt"  :  [  "MyELB"  ,  "DNSName"] Fn::GetAZs •  指定リージョンのアベイラビリティゾーンを返す Fn::Join •  ⽂文字列列の連結 •  “Fn::Join”  :  [  “:”,  [  “a”,  “b”,  “c”  ]  ]      は    「a:b:c」を返す •  “:”がセパレータ。不不要な場合は  ””  を定義 Fn::Select •  Index値に従って、リストから値を返す •  例例:{  “Fn::Select”  :  [  “1”,  [  “apples”,  “grapes”,  “oranges”,  “mangoes”  ]  ]  }       “grapes”を返す Condition  Functions •  Fn::If,  Fn::Equals,  Fn::NotのようなFunctionにより、条件によるスタック作成を可能に http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/ index.html?intrinsic-‐‑‒function-‐‑‒reference.html 34 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 35. Pseudo  Parameter !   実⾏行行リージョンやスタック名といったパラメータを取得する予約語 •  {  “Ref”  :  “AWS::Region”  }  のように値を取得可能 !   AWS::AccountId !   AWS::NotificationARNs •  notification  Amazon  Resource  Names  (ARNs)のリスト取得 !   AWS::NoValue “Resources" : { •  Fn::If  Functionにて使⽤用 “MyServer":{ “Type":“AWS::EC2::Instance", !   AWS::Region “Properties” : { “KeyName”: { “Ref” : “AWS::StackName”}, !   AWS::StackId “Tags” : { “Ref” : “AWS::Region”} !   AWS::StackName } } } http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/ index.html?pseudo-‐‑‒parameter-‐‑‒reference.html 35 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 36. Mappings { "AWSTemplateFormatVersion" : “2010-09-09", "Description" : "Valid JSON strings up to 4K", "Parameters" : { set of parameters }, "Mappings" : { set of mappings }, “Conditions" : { set of conditions }, "Resources" : { set of resources }, Hashtableのようなもの キーに応じて値を特定出来る (例例:リージョンに応じたAMI番号など) "Outputs" : { set of outputs } } 36 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 37. Mappingsとは !   キーとバリューのテーブル !   例例えば、⼊入⼒力力値やリージョンによって値が変わるような ものを決めるような使い⽅方 "Mappings" : { "RegionTable" : { "us-east-1" : { "AMI" : "ami-8c1fece5“, “Key” : “myKey-east” }, "us-west-1" : { "AMI" : "ami-3bc9997e“, “Key” : “myKey-west” }, "ap-northeast-1" : { "AMI" : "ami-300ca731“, “Key” : “myKey-japan” } } }, 37 マッピングを定義 (この例例の場合、”RegionTable”という マッピングを定義) © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 38. Mappingsの使い⽅方 !   “Fn:FindInMap”で値を取得 !   "Fn::FindInMap"  :  [  "MapName",  "Key",  "Value"] ! MapName,key,Valueには”Ref”が利利⽤用可能 "Mappings" : { "RegionTable" : { "us-east-1" : { "AMI" : "ami-8c1fece5“, “Key” : “myKey-east” }, "us-west-1" : { "AMI" : "ami-3bc9997e“, “Key” : “myKey-west” }, "ap-northeast-1" : { "AMI" : "ami-300ca731“, “Key” : “myKey-japan” } } }, 38 “Resources" : { “MyServer":{ “Type":“AWS::EC2::Instance", “Properties” : { “ImageId”: { “Fn::FindInTemplate” “Fn:FindInMap” : [ “RegionTable” , { “Ref” : “region” }, “AMI”] }, } } この例例だと、⼊入⼒力力された } regionパラメータによって 利利⽤用するAMIのIDを決定できる © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 39. Conditions { "AWSTemplateFormatVersion" : “2010-09-09", "Description" : "Valid JSON strings up to 4K", "Parameters" : { set of parameters }, Parameters、他のCondition、Mappingから 条件判断し結果に応じてリソースを作成可能 "Mappings" : { set of mappings }, “Conditions" : { set of conditions }, "Resources" : { set of resources }, "Outputs" : { set of outputs } } 39 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 40. Conditionsの使い⽅方 { "AWSTemplateFormatVersion" : "2010-09-09", "Mappings" : { "RegionMap" : { <一部省略> } }, "Parameters" : { "EnvType" : { EnvTypeパラメータが”prod”と等しければ "Description" : "Environment type.", “CreateProdResources”条件が成⽴立立 "Default" : "test", "Type" : "String", "AllowedValues" : ["prod", "test"], "ConstraintDescription" : "must specify prod or test." } }, "Conditions" : { "CreateProdResources" : {"Fn::Equals" : [{"Ref" : "EnvType"}, "prod"]} }, "Resources" : { "EC2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]} } }, "MountPoint" : { "Type" : "AWS::EC2::VolumeAttachment", "Condition" : "CreateProdResources", "Properties" : { "InstanceId" : { "Ref" : "EC2Instance" }, © 2013 Amazon.com, Inc. and its affiliates. All rights "VolumeId" : { "Ref" : "NewVolume" }, reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc. 40
  • 41. "Parameters" : { "EnvType" : { "Description" : "Environment type.", "Default" : "test", "Type" : "String", "AllowedValues" : ["prod", "test"], "ConstraintDescription" : "must specify prod or test." } }, "Conditions" : { "CreateProdResources" : {"Fn::Equals" : [{"Ref" : "EnvType"}, "prod"]} }, "Resources" : { EnvTypeパラメータが”prod”と等しければ "EC2Instance" : { "Type" : "AWS::EC2::Instance", “CreateProdResources”条件が成⽴立立 "Properties" : { "ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]} } }, “CreateProdResources”条件が成⽴立立して "MountPoint" : { "Type" : "AWS::EC2::VolumeAttachment", いる "Condition" : "CreateProdResources", 場合にのみリソース⽣生成 "Properties" : { "InstanceId" : { "Ref" : "EC2Instance" }, "VolumeId" : { "Ref" : "NewVolume" }, "Device" : "/dev/sdh" } }, “CreateProdResources”条件が成⽴立立して "NewVolume" : { いる "Type" : "AWS::EC2::Volume", "Condition" : "CreateProdResources", 場合にのみリソース⽣生成 "Properties" : { "Size" : "100", "AvailabilityZone" : { "Fn::GetAtt" : [ "EC2Instance", "AvailabilityZone" ]} } } } } Conditionsの使い⽅方 41 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 42. Resources { "AWSTemplateFormatVersion" : “2010-09-09", "Description" : "Valid JSON strings up to 4K", "Parameters" : { set of parameters }, "Mappings" : { set of mappings }, “Conditions" : { set of conditions }, "Resources" : { set of resources }, EC2やRDSなど、スタックを構成する リソースを定義 "Outputs" : { set of outputs } } 42 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 43. Resourcesとは !   EC2やELB,RDSなど、起動するサービスを設定 !   リソース毎に決められたパラメータを設定する “Resources" : { “MyWebServer" : { “Type" : “AWS:EC2::Instance” “Properties" : { “KeyName" : "ami-8c1fece5“, “ImageId” : “myKey-east” }, "us-west-1" : { "AMI" : "ami-3bc9997e“, “Key” : “myKey-west” }, "ap-northeast-1" : { "AMI" : "ami-300ca731“, “Key” : “myKey-japan” } } }, 43 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 44. EC2+SecurityGroupの例例 "Resources" : { "Ec2Instance" : { リソースタイプ "Type" : "AWS::EC2::Instance", "Properties" : { "SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ], "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]} } }, "InstanceSecurityGroup" : { リソース毎のプロパティ "Type" : "AWS::EC2::SecurityGroup", "Properties" : { "GroupDescription" : "Enable SSH access via port 22", "SecurityGroupIngress" : [ { "IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" }] } } } 44 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 45. リソースタイプ AWS::aws-‐‑‒product-‐‑‒name::data-‐‑‒type-‐‑‒name !  !  !  !  !  !  !  !  !  !  !  !  AWS::AutoScaling::AutoScalingGroup AWS::AutoScaling::LaunchConfiguration AWS::AutoScaling::ScalingPolicy AWS::AutoScaling::Trigger AWS::CloudFormation::Authentication AWS::CloudFormation::CustomResource AWS::CloudFormation::Init AWS::CloudFormation::Stack AWS::CloudFormation::WaitCondition AWS::CloudFormation::WaitConditionHandle AWS::CloudFront::Distribution AWS::CloudWatch::Alarm !  !  !  !  !  !  !  !  !  !  !  !  AWS::EC2::VPNConnection AWS::EC2::VPNConnectionRoute AWS::EC2::VPNGateway AWS::EC2::VPNGatewayRoutePropagation AWS::ElastiCache::CacheCluster AWS::ElastiCache::ParameterGroup AWS::ElastiCache::SecurityGroup AWS::ElastiCache::SecurityGroupIngress AWS::ElastiCache::SubnetGroup AWS::ElasticBeanstalk::Application AWS::ElasticBeanstalk::Environment AWS::ElasticLoadBalancing::LoadBalancer !  AWS::DynamoDB::Table !  AWS::IAM::AccessKey !  AWS::EC2::CustomerGateway !  AWS::IAM::Group !  AWS::EC2::DHCPOptions !  AWS::IAM::InstanceProfile !  AWS::EC2::EIP !  AWS::IAM::Policy !  AWS::EC2::EIPAssociation !  AWS::IAM::Role !  AWS::EC2::Instance !  AWS::IAM::User !  AWS::EC2::InternetGateway !  AWS::IAM::UserToGroupAddition !  AWS::EC2::NetworkAcl !  AWS::RDS::DBInstance !  AWS::EC2::NetworkAclEntry !  AWS::RDS::DBParameterGroup !  AWS::EC2::NetworkInterface !  AWS::RDS::DBSubnetGroup !  AWS::EC2::NetworkInterfaceAttachment !  AWS::RDS::DBSecurityGroup !  AWS::EC2::Route !  AWS::RDS::DBSecurityGroupIngress !  AWS::EC2::RouteTable !  AWS::Route53::RecordSet !  AWS::EC2::SecurityGroup !  AWS::Route53::RecordSetGroup !  AWS::EC2::SecurityGroupIngress !  AWS::S3::Bucket !  AWS::EC2::SecurityGroupEgress !  AWS::S3::BucketPolicy !  AWS::EC2::Subnet !  AWS::SDB::Domain !  AWS::EC2::SubnetNetworkAclAssociation !  AWS::SNS::TopicPolicy !  AWS::EC2::SubnetRouteTableAssociation !  AWS::SNS::Topic http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/index.html?aws-‐‑‒template-‐‑‒resource-‐‑‒type-‐‑‒ref.html !  AWS::EC2::Volume !  AWS::SQS::Queue !  AWS::EC2::VolumeAttachment !  AWS::SQS::QueuePolicy !  AWS::EC2::VPC !  AWS::EC2::VPCDHCPOptionsAssociation 45 !  © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc. AWS::EC2::VPCGatewayAttachment
  • 46. Attributes !   リソースの振る舞いや関係を制御する ! DeletionPolicy •  スタックを削除する際のリソースの処理理 •  Delete  (Default)  /  Retain  /  Snapshot ! DependsOn •  指定したリソースが⽣生成された後に⽣生成 •  AWS::CloudFormation::WaitCondition、   AWS::CloudFormation::WaitConditionHandleと併⽤用 !   Metadata ! UpdatePolicy •  AWS::AutoScaling::AutoScalingGroupリソースのみ •  Auto  ScalingのRolling  Updateでの挙動を制御 •  MaxBatchSize •  MinInstancesInService •  PauseTime 46 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 47. Outputs { "AWSTemplateFormatVersion" : “2010-09-09", "Description" : "Valid JSON strings up to 4K", "Parameters" : { set of parameters }, "Mappings" : { set of mappings }, “Conditions" : { set of conditions }, "Resources" : { set of resources }, "Outputs" : { set of outputs } } 47 スタック構築後に取得したい値 (例例:アクセスURLなど) © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 48. Outputsとは !   スタック構築後に取得・表⽰示したい情報の定義 !   例例えばアクセスURLや、DBの通信先情報、作ったIAM ユーザー名など、あとで使⽤用するもの !   マネジメントコンソールから確認できるので、スタック に関する情報を出⼒力力すると便便利利(キーペア名、AZ、イ ンスタンスIDなど) 48 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 49. Outputの定義 出⼒力力したい名称を定義 "Outputs" : { "InstanceId" : { 説明 "Description" : "InstanceId of the newly created EC2 instance", "Value" : { "Ref" : "Ec2Instance" } }, 値 "AZ" : { "Description" : "Availability Zone of the newly created EC2 instance", "Value" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ] } }, "ApplicationURL" : { "Description" : "URL of running web application", "Value" :     { "Fn::Join":      ["", [ "http://", { "Fn::GetAtt": [ "Ec2Instance" , "PublicIp"] } , "/index.html"] ] } } Functionを使って⽂文字列列を加⼯工 } 49 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 50. Outputの定義 "Outputs" : { "InstanceId" : { "Description" : "InstanceId of the newly created EC2 instance", "Value" : { "Ref" : "Ec2Instance" } }, "AZ" : { "Description" : "Availability Zone of the newly created EC2 instance", "Value" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ] } }, "ApplicationURL" : { "Description" : "URL of running web application", "Value" :     { "Fn::Join":      ["", [ "http://", { "Fn::GetAtt": [ "Ec2Instance" , "PublicIp"] } , "/index.html"] ] } } } 50 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 51. テンプレートのまとめ ! Parameters,Mappings,Resources,Outputsの4つのブ ロックに定義を記述 !   可変項⽬目はパラメーター化したり、Mappingで定義 !   Functionsを使⽤用して、参照や⽂文字連結などの操作が可 能 !   Resourceのパラメータはリソースタイプにより異異なる。 ドキュメントを利利⽤用して定義 •  http://docs.amazonwebservices.com/ AWSCloudFormation/latest/UserGuide/index.html?aws-‐‑‒ template-‐‑‒resource-‐‑‒type-‐‑‒ref.html 51 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 52. テンプレートTips !   リソース定義にEC2インスタンスが必須ではない •  DB構築だけ、オートスケールだけ、アラーム設定だけでもOK !   参照関係があると、依存関係があるとみなされる。相互 参照や循環参照はNG(エラーとなる) !   参照関係がある部分は、参照の整合性が取れるよう起動 順をCloudFormationが決定 !   スタックを破棄すると、スタックにひもづくリソースは 破棄される •  ただし”DeletionPolicy”を”Retain”にすると破棄されない "Resources" : { "myS3Bucket" : { "Type" : "AWS::S3::Bucket", "DeletionPolicy" : "Retain" } } 52 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 53. テンプレートTips !   リソース数が多いと、何のリソースか分からなくなるの で、Tagsプロパティを使⽤用する "MyInstance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "SecurityGroups" : [ { "Ref" : "MySecurityGroup" } ], "ImageId" : "ami-20b65349", "Tags" : [ { "Key" : “Name", "Value" : “MyInstance" } ] } } 53 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 54. テンプレートTips ! CloudFormationで作られたリソースには、スタック名 などのタグが付与される 54 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 55. ⼊入れ⼦子テンプレート !   テンプレートからテンプレートの呼び出しが可能 !   リソースタイプに  “AWS::CloudFormation::Stack“を指定 ! TemplateURLを指定すると、そのテンプレートを読み込み "Resources" : {  "WebServer" : { "Type" : "AWS::CloudFormation::Stack", "Properties" : { "TemplateURL" : “https://s3.amazonaws.com/hoge.template" ]]}, "Parameters" : { "KeyName" : { "Ref" : "KeyName" }, "InstanceType" : { "Ref" : "InstanceType"}, } }, 55 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 56. AWS::CloudFormation::Stack !   AWS::CloudFormation::Stack  を使⽤用してスタックを 上位のテンプレートのリソースとしてネストする !   トップレベルのスタックとネストされたスタックを⼀一緒 に更更新可能 !   ネストされたスタックの更更新 •  トップレベルのスタックでUpdateStackコマンドを実⾏行行 •  Management  Consoleで、トップレベルのスタックを選択 し、"Update  Stack"をクリック •  CloudFormationはトップレベルのテンプレートだけでなく、ネ ストされたテンプレートに対する更更新を検出し、テンプレート が変更更されたスタックのみを更更新 56 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 57. !  Cloud-‐‑‒init 57 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 58. Cloud-‐‑‒init !   Amazon  Linuxに⼊入っている、初期設定ツール •  元々はUbuntuで作られたもの !   EC2インスタンスの起動時に、「userdata」として設定 したスクリプトを呼び出す。 •  「#!」  で始まる⽂文字列列の場合のみ、スクリプトを実⾏行行 !   スクリプトを記述できるので、ロケール変更更、アプリイ ンストール、ファイル書き換えなどが可能 !   RHEL •  http://aws.amazon.com/articles/2519228458631605 !   Windows •  EC2ConfigService 58 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 59. Cloud-‐‑‒init EC2インスタンス起動 User  Dataに定義 Cloud-‐‑‒initがuserdata を読み込む 読み込んだスクリプト を実⾏行行 59 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 60. Cloud-‐‑‒initの特⻑⾧長と制限 !   特⻑⾧長 !   インスタンス起動時に、インスタンスの初期化が可能 •  AMIとユーザーデータは分離離できるので、AMIの作り込みが不不要 になる •  Apacheインストール済みのAMIを⽤用意すると、OSやApacheの バージョンが上がったときに再作成になる !   制限 ! userdataは⼀一度度定義すると、書き換えは不不可能 •  書き換えて再実⾏行行が出来ない(後述のスタック更更新に使えない) !   設定できるデータ量量は、16KByteまで 60 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 61. CloudFormationとの連携 !   EC2リソースのプロパティ「UserData」に内容を記載 "MyInstance": { "Type": "AWS::EC2::Instance", "Properties": { "ImageId" : "ami-dcfa4edd", "KeyName" : { "Ref" : "KeyName" }, "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bashn", "log='/tmp/init.log'n", "apt-get update &>> $logn", "apt-get install -y ruby &>> $logn", "cd /tmpn", "wget http://rubygems.org/rubygems.tgz &>> $logn", "tar zxf rubygems.tgz &>> $logn", "cd rubygemsn", "ruby setup.rb --no-format-executable &>> $logn", ]] } } } 61 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 62. CloudFormationとの連携 ! CloudFormationでUserDataを定義すると、定義中に RefやFn::GetAttrを使⽤用することが可能 !   例例えばRDSのEndPointをUserDataに埋め込むといった ことが出来る 62 "Resources" : { "MyInstance": { "Type": "AWS::EC2::Instance", "Properties": { "ImageId" : "ami-dcfa4edd", "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bashn", "cd /home/ec2-usern", { "Fn::Join" : ["", [ "echo ", {"Fn::GetAtt" : ["DBInstance", "Endpoint.Address"]} , "> db.confn" ]]} ]]} } } }, "DBInstance" : { "Type": "AWS::RDS::DBInstance", } } © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 63. ! CloudFormation  helpers 63 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 64. CloudFormation  helpers !   EC2インスタンス初期化時のヘルパースクリプト群 !   利利⽤用⽅方法 •  •  •  Amazon  Linux  AMI Yumリポジトリ その他下記より •  https://s3.amazonaws.com/cloudformation-‐‑‒examples/aws-‐‑‒cfn-‐‑‒bootstrap-‐‑‒ latest.amzn1.noarch.rpm •  https://s3.amazonaws.com/cloudformation-‐‑‒examples/aws-‐‑‒cfn-‐‑‒bootstrap-‐‑‒ latest.tar.gz •  https://s3.amazonaws.com/cloudformation-‐‑‒examples/aws-‐‑‒cfn-‐‑‒bootstrap-‐‑‒latest.zip •  https://s3.amazonaws.com/cloudformation-‐‑‒examples/aws-‐‑‒cfn-‐‑‒bootstrap-‐‑‒latest.msi •  https://s3.amazonaws.com/cloudformation-‐‑‒examples/aws-‐‑‒cfn-‐‑‒bootstrap-‐‑‒ latest.src.rpm !   /opt/aws/bin  に格納 •  •  •  •  cfn-‐‑‒init cfn-‐‑‒get-‐‑‒metadata cfn-‐‑‒signal cfn-‐‑‒hup !   Python製 64 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 65. cfn-‐‑‒init !   パッケージやファイルのダウンロード、ファイルの⽣生成を⾏行行うスク リプト !   実⾏行行のための設定は、Metadata領領域に定義 •  AWS::CloudFormation::Init •  Configsets、Commands、Files、Groups、Packages、Services、 Sources、Users "Resources": { "MyInstance": { "Type": "AWS::EC2::Instance", "Metadata" : { "AWS::CloudFormation::Init" : { "config" : { source,package,files,services "sources" : { : }, の順に実⾏行行される "packages" : { : } "files" : { : } "services" : { : } } } }, "Properties": { : } } 65 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 66. !   sources cfn-‐‑‒initの設定 •  指定したURLからファイルをダウンロードして展開 •  Tar,zip,tar+gzip,tar+bz2 "sources" : { "/etc/myapp" : "https://s3.amazonaws.com/mybucket/myapp.tar.gz" } !   packages §  パッケージシステムを使⽤用してアプリをインストール §  Apt,yum,rubygems,python,rpm "packages" : { 最新版 "yum" : { "httpd" : [], "php" : [], バージョン }, 指定 "rubygems" : { "chef" : [ "0.10.2" ], } } 66 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 67. !   files cfn-‐‑‒initの設定 •  指定パスへのファイルの⽣生成 "files" : { ファイルパス "/app/db.conf" : { "content" : { "Fn::Join" : ["", [ "db.name=", {"Ref" : "DBName"}, "n", ファイルの中⾝身 "db.user=", {"Ref" : "DBUser"}, "n", を⽣生成 "db.pass=", {"Ref" : "DBPassword" },"n", "db.host=", {"Fn::GetAtt" : ["DBInstance", "Endpoint.Address"]}, "n", ]] }, "mode" : "000644", "owner" : "root", "group" : "root" } S3などから取得 "/etc/myapp/myapp-init.pp" : { "source" : "https://s3.amazonaws.com/myapp/myapp-init.pp", "mode" : "100644", "owner" : "root", "group" : "wheel" } } 67 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 68. !   services cfn-‐‑‒initの設定 •  サービスの起動・再起動の指定 •  現在sysvinitのみ OS起動時に起動さ "services" : { せるかどうか "sysvinit" : { "nginx" : { "enabled" : "true", cfn-‐‑‒init終了了後に起動するかどうか "ensureRunning" : "true", "files" : ["/etc/nginx/nginx.conf"], "sources" : ["/var/www/html"] 設定ファイルもしくは指定ディ }, レクトリのファイルが変わって "php-fastcgi" : { いた場合にサービス再起動する "enabled" : "true", "ensureRunning" : "true", "packages" : { "yum" : ["php", "spawn-fcgi"] } } Cfg-‐‑‒initでパッケージを⼊入れて } いたらサービス再起動 68 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 69. cfn-‐‑‒initの起動 ! cfn-‐‑‒initはデフォルトでは動作しない !   User-‐‑‒dataにcfn-‐‑‒initを起動するスクリプトを記述して、 cloud-‐‑‒init経由で起動 !   引数にスタック名、リソース名、リージョン、アクセス キー、シークレットキーを指定 "Properties": { "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bashn", "/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" }, " -r WebServer ", " --access-key ", { "Ref" : "HostKeys" }, " --secret-key ", {"Fn::GetAtt": ["HostKeys", "SecretAccessKey"]}, " --region ", { "Ref" : "AWS::Region" }, "n", ]]}} } 69 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 71. Chef(solo)との連携例例 EC2インスタンス起動 https://s3.amazonaws.com/cloudformation-‐‑‒ templates-‐‑‒us-‐‑‒east-‐‑‒1/wordpress-‐‑‒via-‐‑‒chef-‐‑‒ solo.template       が分かりやすい例例(ただし、rubygem使⽤用) cfn-‐‑‒init内で、meta-‐‑‒dataの読み込み Init.dに登録してある cloud-‐‑‒initが実⾏行行される User-‐‑‒data領領域から、 スクリプトを読み込み スクリプト内で、 cfn-‐‑‒initを呼び出し スクリプト内で、 Chefを実⾏行行 71 Meta-‐‑‒dataの設定に従い、 Sources(レシピファイルダウンロード) Packages(Omnibusでchefインストール) Files(レシピの⼀一部書き換え) を実⾏行行 ダウンロードしたレシピを元に、 chefがサーバ構築 起動完了了 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 72. その他スクリプト ! cfn-‐‑‒get-‐‑‒metadata •  Metadataを簡単に取得出来るスクリプト ! cfn-‐‑‒signal •  リソース「WaitCondition」と共に使⽤用 •  cfn-‐‑‒signalを使⽤用して、スタックに対して初期化状態の通知をす ることが出来る •  アプリのインストールが失敗した場合にスタックを破棄したり できる ! cfn-‐‑‒hup •  スタックを更更新(StackUpdateAPIを使⽤用)した場合に、それ を感知して指定のファイルを実⾏行行するフックスクリプト https://s3.amazonaws.com/cloudformation-‐‑‒examples/ BoostrappingApplicationsWithAWSCloudFormation.pdf 72 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 73. ! CloudFormer 73 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 74. CloudFormer !   既に構築済みのシステム構成から、テンプレートを作成 するツール !   テンプレート作成のベースとなるテンプレートを構築す るのに利利⽤用可能 テンプレート CloudFormer EC2 EC2 AutoScaling 74 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 75. CloudFormerの使い⽅方 !   既存の⼿手順やツールで必要なリソースを構成 !   CloudFormerスタックを作成し起動 •  CloudFormer⾃自⾝身がCloudFormationのスタックです。お客様 のAWS環境でスタックを起動することでCloudFormerが起動さ れます。t1.maicro  EC2インスタンス上で実⾏行行されます。 !   CloudFormerを使⽤用して既存のAWSリソースからテン プレートを⽣生成、結果はS3バケットに保存 !   CloudFormerスタックをシャットダウン !   スタックを起動するために作成されたテンプレートを利利 ⽤用ください 75 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 76. CloudFormerの特⻑⾧長 !   CloudFormerは全てのCloudFormationのリソースをサ ポート !   CloudFormerは⾃自動的に従属するリソースを選択 •  例例えば、EC2インスタンスを選択すると、EC2インスタンスが 必要とするセキュリティグループもリソースとして選択 !   どのリソースをテンプレートに含めるか完全に制御可能 !   必要であれば⾃自動的に選択されたリソースを上書きした り、他のリソースを追加したり可能 !   テンプレートで⽤用いられる名前を指定可能 !   標準の名前は、既存のリソースの名前に基づく !   リソースの利利⽤用可能なアトリビュートからOutputパラ メータを追加可能 76 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 77. CloudFormerスタックを作成し起動 !   以下のいずれかからスタックを作成 •  AWS  CloudFormation  コンソール •  サンプルテンプレートから、”  CloudFormer  -‐‑‒  create  a  template   from  your  existing  resources”を選択 •  CloudFormerツールのページ •  http://aws.amazon.com/developertools/6460180344805680 •  AWS  CloudFormationテンプレートページ •  http://aws.amazon.com/cloudformation/aws-‐‑‒ cloudformation-‐‑‒templates/ !   作成したスタックを起動 •  CloudFormerスタックのOutput、”URL”をクリック 77 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 78. CloudFormer起動 78 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 79. CloudFormer実⾏行行⽅方法 !   テンプレート化したいリージョンを選ぶと、ウィザード形 式でリソースの選択が可能 !   チェックボックスを⼊入れたリソースを元にテンプレートが完 成 79 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 80. !  その他Tips 80 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 81. Baked  AMI    VS  CF-‐‑‒Init !   AMIの作り込み  VS  Cloud-‐‑‒init+CloudFormation   helpers !   ⽤用途によって、AMI作り込み、cloud-‐‑‒init、helperを使 い分ける事が重要 利点 欠点 AMI作り込み ・構築が容易 ・起動が速い  (オートスケールに有効) ・ベースAMI/ミドルウェア  更新時に再インストールが必要 ・リージョン毎の構築が必要 ベースAMI+ Cloud-init+CFN helpers ・ベースAMI/ミドルウェア更新時    に追従が可能 ・DBのエンドポイントなどの  定義が渡せる ・テンプレート構築が手間 ・OS初期化に時間がかかる 81 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 82. IAM  Capability ! CloudFormationでIAMユーザーを作成する場合、ウィザー ド途中でチェックボックスをonにする必要がある •  cfn-‐‑‒create-‐‑‒stackおよびcfn-‐‑‒update-‐‑‒stackの場合は、       「-‐‑‒-‐‑‒capalilities  CAPABILITY_̲IAM」をコマンドに付与 82 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 83. !  まとめ 83 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 84. CloudFormation利利⽤用のFAQ !   テンプレートまたはスタック数に制限はありますか? •  テンプレート数に制限はありません。アカウントに対して、ス タックの最⼤大数は20に制限。 !   説明フィールドの⽂文字数に制限はありますか? •  テンプレート、パラメータ、出⼒力力、およびリソースの説明⽤用の フィールドは、4,096⽂文字に制限。 !   テンプレートのパラメータ、出⼒力力の数に制限はあります か? •  50のパラメータおよび10の出⼒力力。 84 © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 85. まとめ ! CloudFormationを使⽤用すると、システム構成をテンプ レート化できる ! AmazonLinuxにはOS初期化のための仕組みが⽤用意され ている !   cloud-‐‑‒initとcfnヘルパー、またchefなどを CloudFormationと組み合わせると、アプリケーション のセットアップも柔軟に可能 !   システム構築の発想を変えてみる •  OSは素材 •  テンプレート化で、よりクラウドの特性を⽣生かしたシステム構 築が可能に! 85 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 86. CloudFormationで 真のクラウドマイスターを⽬目指せ! App Serve r 86 Web Serve r © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 87. 参考URL !   Cloud  Formation  Samples •  http://aws.amazon.com/jp/cloudformation/aws-‐‑‒ cloudformation-‐‑‒templates/ !   AWS  CloudFormation  のアーティクルとチュートリア ル •  http://aws.amazon.com/jp/cloudformation/aws-‐‑‒ cloudformation-‐‑‒articles-‐‑‒and-‐‑‒tutorials/ •  BootstrappingApplicationsWithAWSCloudFormation •  https://s3.amazonaws.com/cloudformation-‐‑‒examples/ BoostrappingApplicationsWithAWSCloudFormation.pdf •  Integrating  CloudFormation  with  Chef •  https://s3.amazonaws.com/cloudformation-‐‑‒examples/ IntegratingAWSCloudFormationWithOpscodeChef.pdf !   AWS  CloudFormation  よくある質問 •  http://aws.amazon.com/jp/cloudformation/faqs/ 87 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.