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
890
奥深きAPLの世界
chao2suke
0
120
Alexaスキル & レジレスCafeにおけるStripe活用の取り組み
chao2suke
0
2k
Alexa x 機械学習でスキルをよりリッチにする方法
chao2suke
0
1.6k
#AAJUG vol.2 APL ハンズオン
chao2suke
0
2.8k
Other Decks in Technology
See All in Technology
LINE 購物幕後推手
line_developers_tw
PRO
0
560
newmo の創業を支える Software Architecture と Platform Engineering
110y
5
530
分解し、導き、託す ログラスにおける“技術でリードする” 実践の記録
hryushm
0
260
クラウドネイティブ環境の脅威モデリング
kyohmizu
2
420
AIエージェントのオブザーバビリティについて
yunosukey
0
190
Ninno LT
kawaguti
PRO
1
120
Simplify! 10 ways to reduce complexity in software development
ufried
2
260
Новые мапы в Go. Вова Марунин, Clatch, МТС
lamodatech
0
2.1k
AI-in-the-Enterprise|OpenAIが公開した「AI導入7つの教訓」——ChatGPTで変わる企業の未来とは?
customercloud
PRO
0
170
genspark_presentation.pdf
haruki_uiru
1
260
Cursorを全エンジニアに配布 その先に見据えるAI駆動開発の未来 / 2025-05-13-forkwell-ai-study-1-cursor-at-loglass
itohiro73
2
590
時間がないなら、つくればいい 〜数十人規模のチームが自律性を発揮するために試しているいくつかのこと〜
kakehashi
PRO
23
5.6k
Featured
See All Featured
Statistics for Hackers
jakevdp
799
220k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
13
840
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
Documentation Writing (for coders)
carmenintech
71
4.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
700
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Writing Fast Ruby
sferik
628
61k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
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৭ʑͰ͖Δ • ؆୯ͳ༰Ͱ͋Εߏཧπʔϧͳ͠Ͱ ͍͚ͨΓ͢Δ • ࠷ॳʹखΛ͔͚ͯ͋͛Δͱޙʑ׆͖ͯ͘Δ ·ͱΊ