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
AWSをGUIで操作するのは中学生までだよねー
Search
Shinichi Hama
October 03, 2016
Technology
11
4.1k
AWSをGUIで操作するのは中学生までだよねー
2016/10/03
KDLインフラ勉強会 AWS勉強会#2
Shinichi Hama
October 03, 2016
Tweet
Share
Other Decks in Technology
See All in Technology
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
130
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.7k
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
210
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
4
230
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
550
サイバーセキュリティと認知バイアス:対策の隙を埋める心理学的アプローチ
shumei_ito
0
390
強いチームと開発生産性
onk
PRO
35
11k
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
600
SSMRunbook作成の勘所_20241120
koichiotomo
3
160
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Producing Creativity
orderedlist
PRO
341
39k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
What's new in Ruby 2.0
geeforr
343
31k
Code Reviewing Like a Champion
maltzj
520
39k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Transcript
AWSΛGUIͰૢ࡞͢Δͷ தֶੜ·ͰͩΑͶʙʂ ਆށσδλϧɾϥϘ ᖛɹਅҰ ਆށσδλϧɾϥϘ Πϯϑϥษڧձ AWSษڧձ #2
ͯ͞ɾɾɾ ·ͣॳΊʹͰ͕͢ɺ
օ͞ΜɺAWSϦιʔεΛ ίʔυͰཧͰ͖ͯ·͔͢ʁ
͑ʁ·ͩϚωʔδϝϯτίϯ ιʔϧʂʁ
Ϛ ω ʛ δ ϝ ϯ τ ί ϯ ι
ʛ ϧ ⁉︎ G U I த
ܾͯ͠ɺࠓ·ͰͷൃදΛ disΓ͍ͨΘ͚Ͱ͍͟͝·ͤΜ (ʀ´Дʆ)
ͱ͍͏Θ͚Ͱɺࠓ AWSΛίʔυͰૢ࡞ɾཧ͢Δ
ͻ͍ͯࠓ CLI (Command Line Interface) ʹ͍͓͍ͭͯͨ͠͠Ͱ͢ɻ
୭Ͱ͔͢ʁ { ɹɹ“Myself”:{ ɹɹɹɹ“Name”: “Shinichi Hama (ᖛɹਅҰ)”, ɹɹɹɹ“BelongTo”: “Kobe Digital
Labo Inc. WEB Section (גࣜձࣾਆށσδλϧϥϘ ιϦϡʔγϣϯຊ෦ WEBηΫγϣϯ)”, ɹɹɹɹ“Role”: “Infrastructure Engineer (ΠϯϑϥΤϯδχΞ)”, ɹɹɹɹ“LikeAWSService”:[ ɹɹɹɹɹɹ{ ɹɹɹɹɹɹɹɹ“AWS Service”: “Amazon S3”, ɹɹɹɹɹɹɹɹ“AWS Service”: “AWS IAM” ɹɹɹɹɹɹ} ɹɹɹɹ], ɹɹɹɹ“Histrory”: [ ɹɹɹɹɹɹ{ ɹɹɹɹɹɹɹɹ"TheNumberOfYearsWorked": 3(৽ଔೖࣾࡾͰ͢ɻ), ɹɹɹɹɹɹɹɹ”RoutineWork”: "E-Commerce Site developments and SysOps work (ECαΠτͷ։ൃɺӡ༻อकΛͯ͠·͢)" ɹɹɹɹɹɹ} ɹɹɹɹ], ɹɹ} } [hama@Macbbok] ~ % aws-shell aws> kdl describe-presenter
ͬͱຊͰ͢ɻ
։ൃݱͷΠϯϑϥ୲ͷΈ ͦͦΠϯϑϥͰ͖Δਓ͕ؒগͳ͍ɻ
։ൃݱͷΠϯϑϥ୲ͷΈ ͍͍ͩͨಉ͡࡞ۀͷ܁Γฦ͠ ৽ָͯͦ͘͠͠͏ͳҊ݅ͱ͔֎͞ΕΔ orz • ͖Δɻ • ϛεΔɻ • ౖΒΕΔɻ
• ධՁ͕Լ͕Δɻ ͍͔ͯɺͦͦ͏·͘Ͱ͖ͯධՁ͞Εͳ͍… ΠϯϑϥՔಇͯͯͨ͠Γલɺࢭ·ΔͱධՁ͕͕͞Δɻ
ཧෆਚͩʂʂʂʂʢٽʣ
։ൃݱͷΠϯϑϥ୲ͷΈ • AWSΛͬͯͯҰॹɻGUIͰѻͬͯΔݶΓɺखॱͱ͍ ͏ྨΛ͠ʹ͘͘ɺޙͰ͖ͣɺͣͬͱਓґଘͷ··ɻ • ಉ͡࡞ۀʹ͔͚࣌ؒͨ͘ͳ͍ɻϛεΓͨ͘ͳ͍ɻ • Πϯϑϥ୲ͩͬͯɺશʹ٬؍Խ͠ɺཧղͯ͠Δ࡞ۀ ͘Β͍ࣗಈԽ͍ͨ͠ʂʂʂʂ
ࣗಈԽʹΑΔ ҆ఆԽɾܧଓԽΛࢦ͢ʂ
ίʔυͰAWSΛѻ͏͜ͱͰ શͯղܾʂʂʂ
ࠓ͢͜ͱɾ͞ͳ͍͜ͱ •͢͜ͱʢΞδΣϯμʣ 1.AWSͷྑ͍ͳʔͬͯࢥ͏ͱ͜Ζ 2.AWS-CLIʹ͍ͭͯ 3.Infrastructure as code 4.CLIҎ֎ʹ(CloudFormation,CatalogService) •͞ͳ͍͜ͱ •CloudFormationͷৄࡉͳ͍ํͱ͔ɺ
ࡉ͔͍αʔϏεͷઆ໌
AWSͷྑ͍͍ͳʔͬͯࢥ͏ͱ͜Ζ ৭ʑ͋Δ͚Ͳɺ ͣΓɺ “ɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹ ɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹ ɹɹɹɹɹɹɹ ” ͩͱࢥ͍·͢ɻ ϚωʔδϝϯτίϯιʔϧͰͰ͖Δ͜ͱͷ΄΅શͯͷૢ࡞͕API Ͱఏڙ͞Ε͓ͯΓɺCLIɺSDKʹΑΔ֤ݴޠͰAWSϦιʔεΛ
ѻ͏͜ͱ͕Ͱ͖Δ͜ͱ
AWS-CLI ͍·͠ΐ͏ʂ
CLI͕ͳ͍ͱ͖ʂ ͜Μͳͷͷखॱॻ͕͍Δͬͯͳͬͨʹ͏ʂʂ ͑ɺͪΖΜઃܭॻ͍Γ·͢Αʁ
CLI͕͋Δͱ͖ʂ [hama@Macbbok] ~ % aws ec2 run-instances --image-id ami-374db956 --count
1 --instance-type t2.micro --key-name hama_test_id_rsa --security-group-ids sg-××××××× --subnet-id subnet-××××××× --associate-public-ip- address | jq . { "OwnerId": "××××××××××", "ReservationId": "r-××××××××××××", "Groups": [], "Instances": [ { "Monitoring": { "State": "disabled" }, "PublicDnsName": "", "RootDeviceType": "ebs", "State": { "Code": 0, "Name": "pending" }, "EbsOptimized": false, "LaunchTime": "2016-10-02T17:16:34.000Z", "PrivateIpAddress": "10.0.4.101", "ProductCodes": [], "VpcId": "vpc-××××××××", "StateTransitionReason": "", "InstanceId": "i-×××××××××××××××××", "ImageId": "ami-374db956", "PrivateDnsName": "ip-10-0-4-101.ap-northeast-1.compute.internal", "KeyName": "hama_test_id_rsa", ɾ ɾ ɾ ʙҎԼলུʙ ͜Μ͚ͩͰ͢ɻ ͦͯ͠CLIJSONΛಡΈࠐΜͰ࣮ߦͰ͖ΔͷͰɺ ͦͷjsonΛ͓͚ͯ͠ɺͦΕ͕ઃܭॻʹͳΓ·͢ɻ จࣈ௨ΓɺίʔυͰཧͰ͖Δɻ
AWS-CLIΛ͓͏
AWS-CLIΛ͓͏ •for MAC(or for Linux) •PIPͷΠϯετʔϧ $ sudo easy_install pip
(MACͷ࣌) •aws-cliͷΠϯετʔϧ $ sudo pip install awscli •for Windows ϒϥβ͔Βμϯϩʔυͨ͠Β ↓Έ͍ͨͳΠϯετʔϥʔ͕μϯϩʔυ͞ΕΔͷͰ ɹ͋ͱྲྀΕʹΛ͍ͤͯͩ͘͞ʢgg͍ͬͯͩ͘͞ɻʣ
$ aws configure AWS access key ID [**ABCD]: AWS secret
access key [****************EFGH]: Default region name [ap-northeast-1]: Default output format [None]:
σϞ
aws-cliΛ͏্Ͱͷิɾҙ •CLIʹݶΒͣͰ͕͢ɺඞཁҎ্ʹIAMϢʔβʹݖݶΛ ༩͑ͳ͍Α͏ʹ͠·͠ΐ͏ɻ •ϩʔΧϧ͔Β࣮ߦ͢Δࡍɺaws-configureͰೝূใΛ อ࣋ͤ͟͞ΔΛಘ·ͤΜ͕ɺEC2ͷαʔό্͔ΒCLIͰ awsϦιʔεΛૢ࡞͢ΔࡍɺIAMϩʔϧΛEC2ʹ༩͢Δɻ • جຊ̍linerͰͷCLIͷར༻ආ͚·͠ΐ͏ɻΉ͠ΖjsonΛಡ·ͤΔ Α͏ͳCLIͷ͍ํΛ͍ͯͩ͘͠͞ɻ
aws-shellΛͬͯΈΑ͏ • aws-cliศར͚ͩͲɺͦͷ໘ɺଟػೳա͗ͯαϒίϚϯυ໊ Φϓγϣϯ໊ɺΦϓγϣϯͷ͍ํΛ֮͑Δͷ͕େมɻ • ͦΕͳΒGUIͰ͍͍͔ͳʔ • ͦΕ͡Ό͍ͭ·Ͱͨͬͯதֶੜͷ··Ͱ͢ʂ • ࿅श͠·͠ΐ͏ʂ
ͦΜͳ͋ͳͨʹɺaws-shellʂʂ
aws-shellΛͬͯΈΑ͏ •αδΣετʗΦʔτίϯϓϦʔτ •αϒίϚϯυ •Φϓγϣϯ •ΦϓγϣϯʹԠͨ͡ •AWSϦιʔε •ϑΝδʔݕࡧ •ϔϧϓදࣔ •γΣϧίϚϯυ •ϓϩϑΝΠϧαϙʔτ
•ཤྺཧ ҎԼͷػೳʹରԠ
aws-shellΛͬͯΈΑ͏ Πϯετʔϧ $ pip install aws-shell ͷΈʂ
σϞ̎
jqͷεεϝ • ࠷ऴతʹCLI୯ମͰ͏ͷͰͳ͘ɺCLIͷ݁ՌΛ͞Βʹͬͯɺॲཧ Λߦ͏Α͏ͳεΫϦϓτʹΑΔ࡞ۀͷࣗಈԽ͕ਐΉ͜ͱʹͳΔɻ • jqίϚϯυͱJSON͔Β؆୯ʹΛൈ͖ग़ͨ͠Γɺूܭͨ͠Γɺܗ͠ ͯදࣔͨ͠ΓͰ͖ΔJSON༻ͷgrepͱ͔awkΈ͍ͨͳίϚϯυɻ • awsίϚϯυͷϨεϙϯεΛjsonܗࣜʹ͓ͯ͘͠ͱɺ͜ͷjqͱ૬ੑ͕ඇৗ ʹΑ͘ɺجຊతʹηοτͰΘΕͯ·͢ɻ
jqͷεεϝ •୯७ͳ͍ํάά͍ͬͯͨͩ͘ͱͯ͠ɺҎԼͷΑ͏ͳ͍ํͰͬͨΓ͠·͢ɻ 1.Value͚ͩදࣔ $ aws ec2 describe-instances | jq '.Reservations[].Instances[].Tags[].Value'
"app.example.com" "db.example.com" "elasticsearch.example.com" "example.com" 2.ϓϥΠϕʔτIPΞυϨεͱTagʢName)Λλϒ۠ΓͰදࣔ $ aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | .PrivateIpAddress + "\t" + .Tags[].Value' 192.168.1.125 app.example.com 192.168.1.14 db.example.com 192.168.1.250 elasticsearch.example.com 192.168.1.230 example.com
CLIҎ֎ͷαʔϏε •CloudFormation •͕ࣗ࡞Γ͍ͨڥΛఆٛͨ͠ϑΝΠϧ(template)Λ࡞ͬͯɺͦ ͷఆٛॻΛಡΈࠐΜͰࣗಈͰڥΛ࡞ͬͯ͘ΕΔαʔϏεɻ •AWSͷϦιʔε୯ҐͰͳ͘ɺVPCͷωοτϫʔΫͱؚ͔Ί ͨશͯͷڥ୯ҐͰͷΠϯϑϥߏஙͷࣗಈԽΛߦ͏ɻ CLIͰͷཧʹ͑͞׳Ε͖ͯͨΒૣʑͱͬͪ͜ʹҠΓ·͠ΐ͏ɻ
cloudFormationΠϝʔδ
Infrastructure as code •AWSͱ͍͏ΫϥυαʔϏεΛϑϧʹ׆༻͢Δ͜ͱͰɺ Infrastructure as codeΛ࣮ݱ͢Δɻ •Πϯϑϥͦͷଞͷιʔείʔυͱִ͚ͯͳ͘ɺཧɾӡ༻Ͱ ͖Δ͕࣌དྷͨɻ •ΠϯϑϥΤϯδχΞͷઐੑԼ͕Δͱࢥ͏ɻ
•ϑϧελοΫͳΤϯδχΞΛࢦ͢ͷ͔ɺΫϥυαʔϏεΛ ᘳʹ͍͜ͳ͢ʰεʔύʔΠϯϑϥΤϯδχΞʱʹͳΔͷ͔ͷબ ͷ͍ۙͱײ͡Δɻ
·ͱΊ •AWS-CLIΛͱΓ͋͑ͣͬͯΈΔͱ͜Ζ͔Β࢝Ί·͠ΐ͏ɻ ɹ→͑Θ͔Δ͜ͱͷํ͕ଟ͍ ɹˠ͋ͱ৭ʑۀతʹศརɻ •infrastructure as codeʹΑΔࣗಈԽखஈͰ͋ͬͯɺతͰͳ͍ɻ →ࣗͨͪͷ͍ͬͯΔ͜ͱͷ҆ఆԽɾܧଓԽΛతͱͯ͠ ɹࣗಈԽͱ͍͏खஈͰɺߏԽ͞ΕͨۀͷҰ෦ΛࣗಈԽ͢Δɻ •
શͯͷਓ͕AWSΛCLIͰҙຯΒͣʹѻ͏ͷɺ۪ࡦɻ • ͰɺΠϯϑϥΛAWSΛઐతʹΖ͏ͱ͍ͯ͠Δզʑ͘Β͍ͤΊͯCLI Ͱѻ͑ΔΑ͏ʹͳ͓ͬͯ͘͜ͱ͕ɺॾʑ͍ΖΜͳ໘Ͱʹͨͪ·͢ɻ
ALL You Need Is Code !!