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
860
奥深き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
動画配信の フロントエンドを支える 4年間とこれから
nisshii0313
0
110
12 Days of OpenAIから読み解く、生成AI 2025年のトレンド
shunsukeono_am
0
1k
深層学習と3Dキャプチャ・3Dモデル生成(土木学会応用力学委員会 応用数理・AIセミナー)
pfn
PRO
0
410
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
3
1.6k
Unsafe.BitCast のすゝめ。
nenonaninu
0
160
#TRG24 / David Cuartielles / Post Open Source
tarugoconf
0
420
.NET 9 のパフォーマンス改善
nenonaninu
0
2.2k
20241220_S3 tablesの使い方を検証してみた
handy
4
870
.NET AspireでAzure Functionsやクラウドリソースを統合する
tsubakimoto_s
0
140
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
28
25k
20241218_マルチアカウント環境におけるIAM_Access_Analyzerによる権限管理.pdf
nrinetcom
PRO
3
150
エンジニアリングマネージャー視点での、自律的なスケーリングを実現するFASTという選択肢 / RSGT2025
yoshikiiida
4
2.9k
Featured
See All Featured
Scaling GitHub
holman
459
140k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
The World Runs on Bad Software
bkeepers
PRO
66
11k
GraphQLとの向き合い方2022年版
quramy
44
13k
Facilitating Awesome Meetings
lara
50
6.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Designing for Performance
lara
604
68k
Designing Experiences People Love
moore
139
23k
Visualization
eitanlees
146
15k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3.1k
Side Projects
sachag
452
42k
How to Ace a Technical Interview
jacobian
276
23k
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৭ʑͰ͖Δ • ؆୯ͳ༰Ͱ͋Εߏཧπʔϧͳ͠Ͱ ͍͚ͨΓ͢Δ • ࠷ॳʹखΛ͔͚ͯ͋͛Δͱޙʑ׆͖ͯ͘Δ ·ͱΊ