Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
陽の目を見ないCloudformationのマイナー機能に光を当てる
Search
chao2suke
July 22, 2016
Technology
0
320
陽の目を見ないCloudformationのマイナー機能に光を当てる
2016/07/22 Infrastructure as Code勉強会
chao2suke
July 22, 2016
Tweet
Share
More Decks by chao2suke
See All by chao2suke
天井カメラで捉えた人物をコンピュータビジョンで解析した3年間のトライアンドエラーとこれから
chao2suke
0
2.2k
結局普通のエンジニアが今SageMaker使うと何ができるのかわかるLT
chao2suke
0
1.6k
機械学習の知識ゼロでも動かせるAIツールキットの世界
chao2suke
0
1.6k
「今」のAI技術と「3年後」のAI技術のご紹介
chao2suke
0
1k
Alexaに詳しい人は普段Alexaをどう扱っているか
chao2suke
0
850
奥深きAPLの世界
chao2suke
0
120
Alexaスキル & レジレスCafeにおけるStripe活用の取り組み
chao2suke
0
1.9k
Alexa x 機械学習でスキルをよりリッチにする方法
chao2suke
0
1.6k
#AAJUG vol.2 APL ハンズオン
chao2suke
0
2.7k
Other Decks in Technology
See All in Technology
強いチームと開発生産性
onk
PRO
34
11k
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
7
810
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
240
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
6
620
Why does continuous profiling matter to developers? #appdevelopercon
salaboy
0
190
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
180
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
360
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
3
200
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
0
110
Featured
See All Featured
A Philosophy of Restraint
colly
203
16k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Designing the Hi-DPI Web
ddemaree
280
34k
Become a Pro
speakerdeck
PRO
25
5k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
It's Worth the Effort
3n
183
27k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Building an army of robots
kneath
302
43k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Building Adaptive Systems
keathley
38
2.3k
Transcript
ཅͷΛݟͳ͍ CLOUDFORMATION ͷϚΠφʔػೳʹޫΛͯΔ TSUYOSHI SEINO Classmethod. Inc,
ࣗݾհ w ਗ਼ɹ߶࢙ ͤʔͷʣ w "84$POTVMUJOH෦ॴଐʢҰԠޒףʣ w *P5ؔΛ୲ w ࢠҭͯத
ࡀ˂ w ͲΜͳʹ͕ࣾ"OTJCMFҰ৭ʹͳͬͯ$IFGͷࣄΛ৴ͯ͡Δ w ͏ͪͷͷલ͕ϙέεϙοτʹ ৽ೖࣾһ Ίͦࢠ (ใ݉ਓࣄʣ
CloudFormationͷΛ͠·͢
CloudFormation ɾ"84ͷ֤αʔϏεͷߏஙΛɺઃఆϑΝΠϧ ςϯϓϨʔτ Λݩʹߦ͑ΔαʔϏε ɾςϯϓϨʔτ+40/ܕࣜ ɾςϯϓϨʔτࣗ༝ʹ࡞Ͱ͖ΔͨΊɺࣗΈͷγεςϜߏங͕Մೳ ɾ"84͕ϝδϟʔʹͳΔʹ࿈ΕͯϓϩάϥϜΛॻ͘ਓΛத৺ʹϝδϟʔʹ
࣮݁ߏ৭ʑͰ͖Δ͕ϚΠφʔ
օ͞Μʹͬͯ΄͍͠
• cfn-init • cfn-hup • cfn-signal Agenda ͜ΕΛͰۦ͚ൈ͚·͢ɻ
• cfn-init • cfn-hup • cfn-signal Agenda
• ύοέʔδϑΝΠϧͷμϯϩʔυɺϑΝ ΠϧͷੜΛߦ͏εΫϦϓτ • EC2Ϧιʔεͷ”Metadata”ྖҬʹॻ͖ࠐΉ • ߏཧͷجຊ cfn-init
• Cloud-InitAmazonLinuxʹೖ͍ͬͯΔॳظઃఆπʔϧ • ݩʑUbuntuͰ࡞ΒΕͨͷ • AMIΛ࡞ͬͯ͠·͏ͱΞϓϦͷόʔδϣϯ͕ݻఆ͞Ε͍ͯʹ͍͘ɺΈ͍ͨͳ࣌ʹศ ར • Πϯελϯεͷ“ىಈ࣌”ʹ[userdata]ʹॻ͔Ε͍ͯΔεΫϦϓτΛݺͼग़͢(Init.dʹ ొ͞Ε͍ͯΔ)
• Cloud-Initมߋʹcloud.cfgͷमਖ਼͕ඞཁ=>CFnΛॻ͖͑ͯ࠶࣮ߦ͕Ͱ͖ͳ͍ • cfn-initσϑΥϧτͰΒͳ͍ • userdataʹىಈεΫϦϓτΛॻ͍ͯॳΊͯΔ cfn-initͱCloud-initͷҧ͍
cfn-initͱCloud-initͷҧ͍ Πϯελϯεىಈ cloud-init࣮ߦ userdata͔ΒεΫϦϓτΛಡΈࠐΈ εΫϦϓτͰcfn-initΛݺͼग़͢ ىಈྃ
cfn-init "UserData" : { "Fn::Base64" : { "Fn::Join" : ["",
[ "<script>\n", "cfn-init.exe -v -s ", { "Ref" : "AWS::StackId" }, " -r instance1 ", " --region ", { "Ref" : "AWS::Region" }, "\n", "</script>" ]]}},
cfn-init "Metadata" : { "AWS::CloudFormation::Init" : { "config" : {
"files" : { "c:\\cfn\\cfn-hup.conf" : { "content" : { "Fn::Join" : ["", [ "[main]\n", "stack=", { "Ref" : "AWS::StackId" }, "\n", "region=", { "Ref" : "AWS::Region" }, "\n" ]]} }, "c:\\cfn\\hooks.d\\cfn-auto-reloader.conf" : { …………. }, "commands" : { "1-run-timezone" : { "command" : { "Fn::Join" : [ "", [ "powershell.exe -Command \"tzutil /s 'Tokyo Standard Time_dstoff'\"" ]]}, "waitAfterCompletion" : "0" }, "2-rename-computername" : { "command" : { "Fn::Join" : [ "", [ "powershell.exe -Command \"Rename-Computer -NewName instance1 -restart\"" ]]}, "waitAfterCompletion" : "forever" },
cfn-init Sources(ϑΝΠϧμϯϩʔυʣ Packages(Πϯετʔϧ) Files(ϑΝΠϧੜɺઃఆ࡞ʣ Services(αʔϏεʣ Commands(ίϚϯυ࣮ߦ)
chef-zeroΛೖΕΔ߹ ϨγϐϑΝΠϧ μϯϩʔυ DIFGΠϯετʔϧ SVCZHFN ϨγϐͷҰ෦ॻ͖͑ DIFG࣮ߦ VTFSEBUB Sources(ϑΝΠϧμϯϩʔυʣ Packages(Πϯετʔϧ)
Files(ϑΝΠϧੜɺઃఆ࡞ʣ Services(αʔϏεʣ Commands(ίϚϯυ࣮ߦ)
• Commands”ΞϧϑΝϕοτॱʹॲཧ͢Δ cfn-initҙ
cfn-init "Metadata" : { "AWS::CloudFormation::Init" : { "config" : {
"files" : { "c:\\cfn\\cfn-hup.conf" : { "content" : { "Fn::Join" : ["", [ "[main]\n", "stack=", { "Ref" : "AWS::StackId" }, "\n", "region=", { "Ref" : "AWS::Region" }, "\n" ]]} }, "c:\\cfn\\hooks.d\\cfn-auto-reloader.conf" : { …………. }, "commands" : { "1-run-timezone" : { "command" : { "Fn::Join" : [ "", [ "powershell.exe -Command \"tzutil /s 'Tokyo Standard Time_dstoff'\"" ]]}, "waitAfterCompletion" : "0" }, "2-rename-computername" : { "command" : { "Fn::Join" : [ "", [ "powershell.exe -Command \"Rename-Computer -NewName instance1 -restart\"" ]]}, "waitAfterCompletion" : "forever" },
configSets "AWS::CloudFormation::Init" : { "configSets" : { "ascending" : [
"config1" , "config2" ], "descending" : [ "config2" , "config1" ] }, "config1" : { "commands" : { "test" : { "command" : "echo \"$CFNTEST\" > test.txt", "env" : { "CFNTEST" : "I come from config1." }, "cwd" : "~" } } }, "config2" : { "commands" : { "test" : { "command" : "echo \"$CFNTEST\" > test.txt", "env" : { "CFNTEST" : "I come from config2" }, "cwd" : "~" } } } }
• cfn-init • cfn-hup • cfn-signal Agenda
• ελοΫΛߋ৽ͨ͠(StackUpdateAPIΛͬͨʣ߹ʹɺͦ ΕΛײͯ͠ࢦఆͷϑΝΠϧΛ࣮ߦ͢ΔϑοΫεΫϦϓτ • cfn-hup.conf(ઃఆϑΝΠϧ)ͱhookϑΝΠϧ(܈)ʹͯߏ cfn-hup cfn-hup --config|-c config.dir \
--no-daemon \ --verbose|-v
cfn-hup "Metadata" : { "AWS::CloudFormation::Init" : { "config" : {
"files" : { "c:\\cfn\\cfn-hup.conf" : { "content" : { "Fn::Join" : ["", [ "[main]\n", "stack=", { "Ref" : "AWS::StackId" }, "\n", "region=", { "Ref" : "AWS::Region" }, "\n" ]]} }, "c:\\cfn\\hooks.d\\cfn-auto-reloader.conf" : { "content": { "Fn::Join" : ["", [ "[cfn-auto-reloader-hook]\n", "triggers=post.update\n", "path=Resources.instance1.Metadata.AWS::CloudFormation::Init \n", "action=cfn-init.exe -v -s ", { "Ref" : "AWS::StackId" }, " -r instance1", " --region ", { "Ref" : "AWS::Region" }, "\n" ]]} }, "commands" : { ……….
cfn-hup "Metadata" : { "AWS::CloudFormation::Init" : { "config" : {
"files" : { ………….. }, "commands" : { ……….. }, "services" : { "windows" : { "cfn-hup" : { "enabled" : "true", "ensureRunning" : "true", "files" : ["c:\\cfn\\cfn-hup.conf", "c:\\cfn\\hooks.d\\cfn-auto-reloader.conf"] } } }
• cfn-init • cfn-hup • cfn-signal Agenda
• ελοΫʹରͯ͠ॳظԽঢ়ଶͷޭ/ࣦഊΛ௨͢Δ • WaitConditionHandleͱ߹Θͤͯ͏ • userdataʹೖΕͯOKɻcfn-initͷcommandsʹೖΕͯOKɻ cfg-signal cfn-signal --success|-s signal.to.send
\ --reason|-r resource.status.reason \ --data|-d data \ --id|-i unique.id \ --exit-code|-e exit.code \ waitconditionhandle.url
cfn-hup "Metadata" : { "AWS::CloudFormation::Init" : { "config" : {
"files" : { ………….. }, "commands" : { ……….. "99-signal-success" : { "command" : { "Fn::Join" : ["", [ "cfn-signal.exe -e 0 \"", { "Fn::Base64" : { "Ref" : "InstanceWaitHandle" } },"\"" ]] }, "InstanceWaitCondition" : { "Type" : "AWS::CloudFormation::WaitCondition", "DependsOn" : "Instance1", "Properties" : { "Handle" : {"Ref" : "InstanceWaitHandle"}, "Timeout" : "1500" } }, "InstanceWaitHandle" : { "Type" : "AWS::CloudFormation::WaitConditionHandle" }
• ࣮CFn৭ʑͰ͖Δ • ؆୯ͳ༰Ͱ͋Εߏཧπʔϧͳ͠Ͱ ͍͚ͨΓ͢Δ • ࠷ॳʹखΛ͔͚ͯ͋͛Δͱޙʑ׆͖ͯ͘Δ ·ͱΊ