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
840
奥深きAPLの世界
chao2suke
0
120
Alexaスキル & レジレスCafeにおけるStripe活用の取り組み
chao2suke
0
1.9k
Alexa x 機械学習でスキルをよりリッチにする方法
chao2suke
0
1.5k
#AAJUG vol.2 APL ハンズオン
chao2suke
0
2.6k
Other Decks in Technology
See All in Technology
EitherT_with_Future
aoiroaoino
1
1.1k
React Aria で実現する次世代のアクセシビリティ
ryo_manba
4
1.2k
OR学会2024秋_短期収益と将来のオフ方策評価性能を考慮したクーポン割当方策混合比の決定
recruitengineers
PRO
4
410
Mocking in Rust Applications
taiki45
1
370
Optuna: a Black-Box Optimization Framework
pfn
PRO
1
110
四国のあのイベントの〇〇システムを45日間で構築した話 / cloudohenro2024_tachibana
biatunky
0
310
難しいから面白い!医薬品×在庫管理ドメインの複雑性と向き合い、プロダクトの成長を支えるための取り組み / Initiatives to Support Product Growth
kakehashi
2
190
プロダクトエンジニアを支えるための開発生産性向上施策
tsukakei
0
140
Developer Experienceを向上させる基盤づくりの取り組み事例集
coconala_engineer
0
110
Envoy External AuthZとgRPC Extensionを利用した「頑張らない」Microservices認証認可基盤
andoshin11
0
220
Privacy Sandbox on Android / DroidKaigi 2024
7pairs
1
160
デジタル化・DX推進あるある
y150saya
0
240
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
88
16k
BBQ
matthewcrist
83
9.1k
Become a Pro
speakerdeck
PRO
22
4.9k
Building a Scalable Design System with Sketch
lauravandoore
458
32k
Testing 201, or: Great Expectations
jmmastey
36
7k
Product Roadmaps are Hard
iamctodd
PRO
48
10k
The Cost Of JavaScript in 2023
addyosmani
41
5.2k
Practical Orchestrator
shlominoach
185
10k
The Illustrated Children's Guide to Kubernetes
chrisshort
47
48k
Into the Great Unknown - MozCon
thekraken
28
1.4k
Git: the NoSQL Database
bkeepers
PRO
425
64k
Art, The Web, and Tiny UX
lynnandtonic
294
20k
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৭ʑͰ͖Δ • ؆୯ͳ༰Ͱ͋Εߏཧπʔϧͳ͠Ͱ ͍͚ͨΓ͢Δ • ࠷ॳʹखΛ͔͚ͯ͋͛Δͱޙʑ׆͖ͯ͘Δ ·ͱΊ