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の研修環境構築のためにAWS CDKとAmplify Console使った話 / jaw...
Search
kasacchiful
September 12, 2020
Programming
2
1.5k
AWSの研修環境構築のためにAWS CDKとAmplify Console使った話 / jaws sonic 2020
JAWS SONIC 2020 & MIDNIGHT JAWS 2020 で、発表した資料です。
kasacchiful
September 12, 2020
Tweet
Share
More Decks by kasacchiful
See All by kasacchiful
dbt coreとFargateでデータ変換 / 20240928-jawsug-toyama-hokuriku-shinkansen
kasacchiful
1
57
What we keep in mind when migrating from Serverless Framework to AWS CDK and AWS SAM
kasacchiful
1
280
AWSでIcebergを使ってデータウェアハウスを構築してみる / 20240810-jawsug-akita
kasacchiful
0
32
サーバーレスパターンを元にAWS CDKでデータ基盤を構築する / 20240731_classmethod_odyssey_online_build_a_data_infrastructures_using_aws_cdk_based_on_serverless_patterns
kasacchiful
0
420
AWS IoT 1-clickがサービス終了するので、SORACOMに移行した話 / 20240518-jawsug-niigata-iotlt-niigata
kasacchiful
0
230
AWS Application Composerで始める、 サーバーレスなデータ基盤構築 / 20240406-jawsug-hokuriku-shinkansen
kasacchiful
1
540
AWSの各種サービス紹介と活用方法 − AI・ML活用デモを交えて − / 20231208aws-aiml-seminar
kasacchiful
0
510
Amazon Rekognition デモ / 20231208-aws_seminar-01-rekognition-demo
kasacchiful
0
520
Amazon Lookout for Vision デモ / 20231208-aws_seminar-02-lookout-vision-demo
kasacchiful
0
510
Other Decks in Programming
See All in Programming
Beyond ORM
77web
2
330
CSC305 Lecture 25
javiergs
PRO
0
130
return文におけるstd::moveについて
onihusube
1
950
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
fs2-io を試してたらバグを見つけて直した話
chencmd
0
220
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
460
Go の GC の不得意な部分を克服したい
taiyow
2
770
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
1
120
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
310
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Building Adaptive Systems
keathley
38
2.3k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
A better future with KSS
kneath
238
17k
Speed Design
sergeychernyshev
25
670
Side Projects
sachag
452
42k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Optimising Largest Contentful Paint
csswizardry
33
3k
Writing Fast Ruby
sferik
628
61k
Automating Front-end Workflow
addyosmani
1366
200k
Become a Pro
speakerdeck
PRO
26
5k
Transcript
AWSͷݚमڥߏஙͷͨΊʹ AWS CDKͱAmplify Console ͬͨ Hiroshi Kasahara (JAWS-UG Niigata) JAWS
SONIC 2020 & MIDNIGHT JAWS 2020 2020/09/12 Sat. 21:00
• ৽ׁࢢࡏॅ • ݩSIerۈͷΤϯδχΞ • ͖ͳݴޠ: • ίϛϡχςΟ: • JAWS-UG
৽ׁ • JaSST Niigata ࣮ߦҕһձ • ASTER ਖ਼ձһ • etc. Hiroshi Kasahara @kasacchiful @kasacchiful 2
JAWS-UG Niigata • 201811݄ʹ্ཱͪ͛ • ৽ׁݝʹ3ͭ͋Δࢧ෦ͷ1ͭ • ৽ׁͱ͍͑ɺञ • ࠙ձ͕ʮʹ͍͕ͨञͷਞʯͷ࣌
• ΦϑϥΠϯ։࠵ͷࡍʹɺ͓͍͍͓͠ञ ͱ͓৯ࣄΛᅂΈʹɺͥͻ৽ׁ͓ӽ͘͠ ͍ͩ͞ 3
͢͜ͱ • ࣾͷݚमڥΛߏங͢ΔͨΊʹɺAWS CDKͱAWS Amplify ConsoleΛ͍·ͨ͠ • AWS CDKͱAWS Amplify
Consoleͷબఆཧ༝ • AWS CDKͱAWS Amplify Consoleͷݸਓత༻ײ 4
͞ͳ͍͜ͱ • AWS CDKͷৄࡉ • AWS Amplify Consoleͷৄࡉ • ࣮ࡍॻ͍ͨίʔυͷઆ໌
5
ͬͨ͜ͱ • ݚमͰ༻͢ΔIAMϢʔβVPCͳͲͷॳظઃఆ • AWS CDKͰఆٛ • ݚमͰ༻͢ΔϋϯζΦϯࢿྉ • docsifyΛ༻ͯ͠هड़͠ɺAmplify
ConsoleͰՔಇ 6
എܠ • ࠓɺࣾͷAWSݚमΛ͞Ε·ͨ͠ • ΄ͱΜͲͷࣾһAWS৮ͬͨ͜ͱ͕ͳ͍ • ʮAWSͱԿ͔ʯΛͬͨޙʹʮϋϯζΦϯʯ͕ඞཁͩͳ • ʮϋϯζΦϯʯͲ͏ͬͯΖ͏͔ͳʁ 7
ϋϯζΦϯͷ༰ • 2019ʹʮJAWS-UG৽ׁʯͱ ʮJAWS-UG৽ׁݝʯͰ࣮ࢪͨ͠ɺ EC2ͱS3ͷϋϯζΦϯΛݩʹߏɻ • ಄30આ໌ͷޙɺ2࣌ؒͰ WordPressαΠτߏங·ͰҰ௨ΓͰ͖ ΔΑ͏ʹɻ •
ૣ͘ऴΘͬͨਓ͚ʹΦϓγϣϯϋϯ ζΦϯΛ༻ҙɻ 1. Amazon EC2 • ΠϯελϯεىಈɺΠϯελϯελΠϓมߋɺ Πϯελϯεআ 2. Amazon S3 • όέοτ࡞ɺΦϒδΣΫτอଘɺόέοτ আɺެ։ઃఆɺ੩తWebαΠτϗεςΟϯά 3. WordPressαΠτߏங • Marketplace AMIΛ༻ͯ͠Πϯελϯεىಈɺ ը૾ϑΝΠϧΛS3ʹอଘͯ͠৴ 4. Φϓγϣϯ • WordPressͷMySQLσʔλΛRDSʹҠߦ • ALBͰෛՙࢄ • ΦʔτεέʔϦϯάઃఆ 8
ϋϯζΦϯڥ • ࢀՃऀຖͷAWSΞΧϯτແ͍ɻ • ϋϯζΦϯ༻ͷAWSΞΧϯτ1ͭʹ ରͯ͠ɺࢀՃऀͷIAMϢʔβVPC ͳͲΛ༻ҙɻ • AWSϚωδϝϯτίϯιʔϧͰૢ࡞ •
EC2ͷϩάΠϯSystems Manager ͷηογϣϯϚωδϟʔͰ࣮ࢪ 9
ϋϯζΦϯڥ 10 WordPressͷEC2ΠϯελϯεΛىಈͤ͞ ͯɺը૾ϑΝΠϧΛS3ʹอଘɾ৴Ͱ͖Δ ·ͰΛඪʹϋϯζΦϯ࣮ࢪ ΦϓγϣϯϋϯζΦϯ·Ͱ࣮ࢪ͢Δͱɺ͜͜ ·ͰͰ͖Δ
ϋϯζΦϯ࣮ࢪ͢Δʹ͋ͨͬͯͷ՝ (1) 1. ࣾͷωοτϫʔΫڥͰɺEC2ʹϩάΠϯͰ͖ͳ͍ • ձࣾϦϞʔτϫʔΫͰͳ͘ɺΈͳ͞ΜΦϑΟεϫʔΫ • Ϛωδϝϯτίϯιʔϧ৮ΕΔ͕ɺSSH/RDP͚ͩͰͳ͘SSMηογϣ ϯϚωδϟʔϒϩοΫ͞ΕΔ 2.
͍ձٞࣨͰɺͨ͘͞ΜͷਓΛೖΕͨ͘ͳ͍ • ࣮ࡍͷϋϯζΦϯࢀՃऀߜΓ͍ͨ • Ͱɺͨ͘͞ΜͷਓʹࢀՃͯ͠΄͍͠δϨϯϚ 11
ϋϯζΦϯ࣮ࢪ͢Δʹ͋ͨͬͯͷ՝ (2) 3. ϋϯζΦϯͷॳظઃఆɺࢀՃਓʹԠͯ͡ਝʹ࡞Γ͍ͨ • 3࣌ؒͷஸͳͷͰɺ࣌ؒΛ֬อ͔ͯ͠ΒࢀՃਃࠐʹͳΔͣ • ͭ·Γɺ։࠵લʹ૿͑ΔՄೳੑେ 4. ։࠵ޙʹ෮श͢ΔͨΊͷڥΛ༩͍͑ͯ͋͛ͨ
• श͏ΑΓ׳ΕΖ • ܁Γฦ͠AWSΛ৮ͬͨํ͕ʹ͘ • ͰࣾωοτϫʔΫ͔ΒAWS৮Δͷ͍͠ 12
՝ͷରԠ (1) 1. ࣾͷωοτϫʔΫڥͰɺEC2ʹϩάΠϯͰ͖ͳ͍ • ձʹϋϯζΦϯઐ༻ΞΫηεϙΠϯτ͕͋ΔͷͰɺҰ࣌తʹ༗ޮԽ͢ Δ 2. ͍ձٞࣨͰɺͨ͘͞ΜͷਓΛೖΕͨ͘ͳ͍ •
ΦϯϥΠϯͰࢹௌͰ͖ΔΑ͏ʹ͢Δ (ฐࣾͰɺMicrosoft Teams) • ϋϯζΦϯ࣌ؒଳͰɺࢲͷϋϯζΦϯ༰ͷϥΠϒߏஙΛ৴ • ձࢀՃऀ͚ͷϋϯζΦϯαϙʔτɺผͷਓʹ͓ͤͨ͠ 13
՝ͷରԠ (2) 3. ϋϯζΦϯͷॳظઃఆɺࢀՃਓʹԠͯ͡ਝʹ࡞Γ͍ͨ • AWS CDKͰઃఆͰ͖ΔΑ͏ʹͨ͠ (ࣾNW͔ΒCDKίϚϯυͰΞΫηεͰ͖ͨ) 4. ։࠵ޙʹ෮श͢ΔͨΊͷڥΛ༩͍͑ͯ͋͛ͨ
• ϋϯζΦϯࢿྉΛAWS Amplify ConsoleͰެ։͠ɺࣗͰ෮शͰ͖ΔΑ͏ʹͨ͠ • ॳظઃఆCDKͰग़ྗͨ͠CloudFormationςϯϓϨʔτͰઃఆͰ͖ΔΑ͏ʹͨ͠ • ࢲͷϋϯζΦϯϥΠϒߏங৴ಈըɺը͢ΔͱࣗಈతʹMicrosoft Streamsʹ อଘ͞ΕΔͷͰɺࣗͰϥΠϒߏஙಈըΛݟͳ͕ΒߏஙͰ͖ΔΑ͏ʹͨ͠ 14
AWS CDK 15
AWS CDK • AWSͷϦιʔεΛϓϩάϥϛϯάݴޠͰఆٛͯ͠ϓϩϏδϣχϯά • CloudFormationͷϥούʔ 16
ͳͥAWS CDKΛͬͨͷ͔ʁ ಉ͡ઃఆΛ܁Γฦ͠࡞Γ͍ͨ • CloudFormationΛॻ͘ͷ(ݸਓతʹ)πϥΠ • CDKͰϧʔϓͤ͞ΕOKͩ͠ɺ(ݸਓతʹ)ײతʹ͔͚Δ ීஈ͍׳Ε͍ͯΔϓϩάϥϛϯάݴޠͷίʔυͰॻ͚Δ/ಡΊΔ҆৺ײ • CloudFormationͷYAML/JSONϑΝΠϧΑΓɺCDKͷPythonίʔυͷํ͕ɺ(ݸਓతʹ)ಡΈ
͍͢ CloudFormationςϯϓϨʔτग़ྗͰ͖Δ • ࣗݾֶश࣌ʹɺݸਓͷAWSΞΧϯτͰॳظઃఆΛ࠶ݱͰ͖Δ 17 ͜ΕͰࢀՃਓɺ ҰؾʹVPCͳͲͷॳظઃఆ͕Ͱ͖Δʂ
αʔϏεͷ੍ݶʹؾΛ͚ͭΔ AWSͷ֤छαʔϏεͷ੍ݶΛ֬ೝ͓ͯ͘͜͠ͱɻ ࠓճ্ݶ؇ͷਃΛͨ͠ͷ • 1Ϧʔδϣϯ͋ͨΓͷVPCͷ • 1Ϧʔδϣϯ͋ͨΓͷΠϯλʔωοτήʔτΣΠͷ 18
αʔϏεΫΥʔλ ʮࢲͷαʔϏεΫΥʔλʯ͔Βɺ্ݶ؇ͷਃͰ͖·͢ɻ • ʮطଘͰಈ͍͍ͯΔͷͷʯΛؚΊΔ͜ͱΛΕ͕ͪͳͷͰɺؾΛ͚͓ͭͯ͜͏ • ྫ: σϑΥϧτVPC • VPCͷΛʮ10ʯ࡞Γ͍͔ͨΒʮ10ʯͰਃ͢ΔͱɺσϑΥϧτVPCΛؚΊ ͯͳ͍ͷͰɺVPC1ͭ࡞Εͳ͍
ਃͨ͠ཌ͘Β͍ʹɺ্ݶ؇͕ө͞Ε·ͨ͠ɻ 19
CDKͰઃఆͨ͠ͷ ࢀՃऀ͋ͨΓ • VPC: 1ͭ • ΠϯλʔωοτήʔτΣΠ: 1ͭ (VPCʹΞλον) •
αϒωοτ: 4ͭ • publicαϒωοτɺIGWͷϧʔςΟϯά Ճ • ηΩϡϦςΟάϧʔϓ: 2ͭ (web ͱ db) • IAMϢʔβ • ڞ௨ͷIAMάϧʔϓʹՃ 20 ࢀՃऀڞ௨ • IAMάϧʔϓ • ֤छϙϦγʔΛΞλον • IAMϩʔϧ • EC2ʹʮAmazonEC2RoleforSSMʯͱ ʮAmazonS3FullAccessʯΛڐՄ͢ΔͨΊ • ΠϯελϯεϓϩϑΝΠϧͷ࡞ΛΕͣʹ ࠓճPythonͰॻ͖·ͨ͠
ߏஙྫ (IAMϢʔβͱIAMάϧʔϓ) # IAM Group iam_group = iam.Group(self, "HandsonGroup", group_name
= "HandsonGroup", managed_policies = [ iam.ManagedPolicy.from_aws_managed_policy_name("AmazonS3FullAccess"), ] ) # IAM Users cnt = 10 for i in range(1, cnt + 1): iam_user = iam.User(self, f"handson-seminar-iamuser-{i}", user_name = f"handson-seminar-iamuser-{i}", groups = [iam_group], ) 21
ࣗݾֶश༻ͷॳظڥઃఆCFNςϯϓϨʔτ cdk synth ͷίϚϯυͰɺCloudFormationςϯϓϨʔτΛग़ྗͰ͖Δɻ 22 $ cdk synth handson-stack >
cfn-template-handson.yml
AWS CDKͷ༻ײ • ͍ͭͷϓϩάϥϛϯάݴޠͰॻ͚Δ҆৺ײ (ݸਓతʹ) • ݁ߏলུͯ͠هड़Ͱ͖Δ • ϋϯζΦϯͰࢿྉʹهड़͢Δඞཁ͕͋ͬͨͷͰVPC໊ࢦఆ͕ͨ͠ɺ CloudFormationςϯϓϨʔτΑΓهड़ྔ͕ݮͬͨ
• ݟ͕͠ϥΫ • ࠔͬͨͱ͖ɺAPIϦϑΝϨϯεઌۦऀͷTypeScriptίʔυΛࢀর • ݴޠҟͳͬͯɺΫϥεϝιου͕ڞ௨Խ͞Ε͍ͯΔ 23
AWS Amplify Console 24
AWS Amplify Console • ੩తWebϗεςΟϯάαʔϏε • Ϗϧυ&σϓϩΠ͢ΔͨΊͷɺγϯϓϧͳCI/CDػೳ͋Γ • AmplifyΛߏ͢Δཁૉͷ1ͭ •
ࠓճAmplify ConsoleͷΈ͍ͬͯ·͢ 25
Amplify Consoleͷಋೖ 1. Deployͷ”GET STARTED”Λબ 2. GitϦϙδτϦαʔϏεΛબ 3. ϦϙδτϦͱϒϥϯνΛબ 4.
ϏϧυઃఆΛՃ 5. อଘͯ͠σϓϩΠ!!!
ͳͥAmplify ConsoleΛͬͨͷ͔ʁ (1) ͔ࣗΒͰࣗݾֶशͰ෮श͍ͤͯ͋͛ͨ͞ • Amplify ConsoleͰࢿྉΛWebͰެ։͢ΕOK • ύεϫʔυอޢ(Basicೝূ)Ͱ͖Δ •
VPCͷॳظઃఆɺCDKͰ࡞ͨ͠CloudFormationςϯϓ ϨʔτΛࢿྉαΠτ͔Βμϯϩʔυͯ͠༻ͯ͠Β͑OK 27
ͳͥAmplify ConsoleΛͬͨͷ͔ʁ (2) σϓϩΠ·ͰͷखॱΛϥΫʹ͍ͨ͠ • ࠓ·ͰͷJAWS-UG৽ׁͰͬͯͨ͜ͱ • ฤू࣌: MarkdownͰॻ͘ →
masterϒϥϯνʹϚʔδ → GitHubʹpush • Ϗϧυ&σϓϩΠ࣌: MarkdownΛHTMLʹม͢Δ → S3ʹઃஔ͢Δ • ࠓճͬͨ͜ͱ • ฤू࣌: MarkdownͰॻ͘ → masterϒϥϯνʹϚʔδ → GitHubʹpush • pushͨ͠ޙɺAmplify Console͕ࣗಈతʹϏϧυ & σϓϩΠͯ͘͠ΕΔ 28 ࢿྉ࡞Δͷࢲ1ਓ͚͔ͩͩΒɺ ༨ܭͳखॱΛ౿·ͳ͍Α͏ʹ͍ͨ͠
Ϗϧυ & σϓϩΠ ϑϩʔ 29
υΩϡϝϯταΠτΛdocsifyͰ VueϕʔεͷυΩϡϝϯταΠτΛ͓खܰʹ • Single Page Application • Ϗϧυෆཁ • MarkdownϑΝΠϧͷ··ઃஔͰ͖Δ
• JAWS-UG৽ׁͷϋϯζΦϯࢿྉ(Markdown)͕ͦͷ··͑Δ • ͰϚωδϝϯτίϯιʔϧͷUIมߋ͕݁ߏ͋ͬͨͷͰɺॻ͖͢෦ଟ͔ͬͨ • ֤छϗεςΟϯάαʔϏεͷσϓϩΠखॱ͕υΩϡϝϯτʹ༻ҙ • Amplify Consoleɺ͜ͷσϓϩΠखॱͷ௨Γʹ࣮ࢪ͠·ͨ͠ 30 IUUQTEPDTJGZKTPSH
version: 0.1 frontend: phases: build: commands: - "sed -i -e
\"s/routerMode: 'hash',/routerMode: 'history',/g\" ./docs/index.html" artifacts: baseDirectory: /docs files: - '**/*' cache: paths: [] docsifyͷυΩϡϝϯτʹ ै͑OKɻ • ϦϙδτϦϧʔτʹஔ͘ amplify.ymlӈͷΑ͏ ʹͯ͠ɺϏϧυ࣌ʹ routerModeΛ”history” ʹॻ͖͍͑ͯΔɻ Amplify ConsoleͷσϓϩΠઃఆ
ΤϯτϦϙΠϯτͷindex.htmlʹdocsifyͷઃఆΛॻ͖ɺ ֤ϖʔδMarkdownͰॻ͖·͢ɻ
࣮ࡍͷϋϯζΦϯςΩετ͜Μͳײ͡
ςΩετͱϚωδϝϯτίϯιʔϧฒͯ ϋϯζΦϯͷ༷Λ࣮ԋ & ࣾʹϥΠϒ৴͠·ͨ͠
AWS Amplify Consoleͷ༻ײ • Ϗϧυ & σϓϩΠͷख͕͔ؒͳΓল͚ͨ • ॳظઃఆҙ֎ͱ؆୯ͩͬͨ •
(docsifyͷσϓϩΠखॱʹै͚ͬͨͩͰ͋Δ͕…) • Amplify SDKAmplify CLIΘͳͯ͘ɺ·ͣAmplify Consoleͩ ͚Ͱࢼͯ͠ΈΔՁ͋Δ 35
·ͱΊ 36
·ͱΊ • ࣾͷݚमڥΛߏங͢ΔͨΊʹɺAWS CDKͱAWS Amplify ConsoleΛ͍·ͨ͠ • AWS CDKͰϋϯζΦϯͷॳظڥߏஙɻϓϩάϥϛϯάݴޠͰॻ͚ Δ҆৺ײɻهड़͕݁ߏলུͰ͖ͯɺίʔυશମ͕εοΩϦɻ
• AWS Amplify ConsoleͰϋϯζΦϯςΩεταΠτͷϏϧυ&σϓϩ ΠলྗԽɻҙ֎ͱ؆୯ɻා͘ͳ͍ɻ 37
https://jawsug-niigata.connpass.com 38
ࢀߟ • ϋϯζΦϯͷϕʔε: • JAWS-UG ৽ׁ #2 - S3 ϋϯζΦϯ
• https://jawsug-niigata.connpass.com/event/114694/ • JAWS-UG ৽ׁ #4 - EC2 / Lightsail ϋϯζΦϯ • https://jawsug-niigata.connpass.com/event/126558/ • JAWS-UG ৽ׁݝ ॳ৺ऀ͚ϋϯζΦϯ • https://nds.connpass.com/event/133878/ 39