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.3k
結局普通のエンジニアが今SageMaker使うと何ができるのかわかるLT
chao2suke
0
1.7k
機械学習の知識ゼロでも動かせるAIツールキットの世界
chao2suke
0
1.7k
「今」のAI技術と「3年後」のAI技術のご紹介
chao2suke
0
1.1k
Alexaに詳しい人は普段Alexaをどう扱っているか
chao2suke
0
900
奥深きAPLの世界
chao2suke
0
120
Alexaスキル & レジレスCafeにおけるStripe活用の取り組み
chao2suke
0
2k
Alexa x 機械学習でスキルをよりリッチにする方法
chao2suke
0
1.7k
#AAJUG vol.2 APL ハンズオン
chao2suke
0
2.8k
Other Decks in Technology
See All in Technology
Amazon S3標準/ S3 Tables/S3 Express One Zoneを使ったログ分析
shigeruoda
3
470
ハノーバーメッセ2025座談会.pdf
iotcomjpadmin
0
160
Prox Industries株式会社 会社紹介資料
proxindustries
0
270
Yamla: Rustでつくるリアルタイム性を追求した機械学習基盤 / Yamla: A Rust-Based Machine Learning Platform Pursuing Real-Time Capabilities
lycorptech_jp
PRO
2
110
Claude Code Actionを使ったコード品質改善の取り組み
potix2
PRO
6
2.2k
実践! AIエージェント導入記
1mono2prod
0
160
5min GuardDuty Extended Threat Detection EKS
takakuni
0
130
Navigation3でViewModelにデータを渡す方法
mikanichinose
0
220
初めてのAzure FunctionsをClaude Codeで作ってみた / My first Azure Functions using Claude Code
hideakiaoyagi
1
220
mrubyと micro-ROSが繋ぐロボットの世界
kishima
2
210
データプラットフォーム技術におけるメダリオンアーキテクチャという考え方/DataPlatformWithMedallionArchitecture
smdmts
5
630
製造業からパッケージ製品まで、あらゆる領域をカバー!生成AIを利用したテストシナリオ生成 / 20250627 Suguru Ishii
shift_evolve
PRO
1
140
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
54
13k
Unsuck your backbone
ammeep
671
58k
Rails Girls Zürich Keynote
gr2m
94
14k
Six Lessons from altMBA
skipperchong
28
3.8k
Designing for humans not robots
tammielis
253
25k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
GitHub's CSS Performance
jonrohan
1031
460k
GraphQLとの向き合い方2022年版
quramy
48
14k
Embracing the Ebb and Flow
colly
86
4.7k
Faster Mobile Websites
deanohume
307
31k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
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৭ʑͰ͖Δ • ؆୯ͳ༰Ͱ͋Εߏཧπʔϧͳ͠Ͱ ͍͚ͨΓ͢Δ • ࠷ॳʹखΛ͔͚ͯ͋͛Δͱޙʑ׆͖ͯ͘Δ ·ͱΊ