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
40
What we keep in mind when migrating from Serverless Framework to AWS CDK and AWS SAM
kasacchiful
1
230
AWSでIcebergを使ってデータウェアハウスを構築してみる / 20240810-jawsug-akita
kasacchiful
0
26
サーバーレスパターンを元にAWS CDKでデータ基盤を構築する / 20240731_classmethod_odyssey_online_build_a_data_infrastructures_using_aws_cdk_based_on_serverless_patterns
kasacchiful
0
380
AWS IoT 1-clickがサービス終了するので、SORACOMに移行した話 / 20240518-jawsug-niigata-iotlt-niigata
kasacchiful
0
200
AWS Application Composerで始める、 サーバーレスなデータ基盤構築 / 20240406-jawsug-hokuriku-shinkansen
kasacchiful
1
510
AWSの各種サービス紹介と活用方法 − AI・ML活用デモを交えて − / 20231208aws-aiml-seminar
kasacchiful
0
490
Amazon Rekognition デモ / 20231208-aws_seminar-01-rekognition-demo
kasacchiful
0
500
Amazon Lookout for Vision デモ / 20231208-aws_seminar-02-lookout-vision-demo
kasacchiful
0
490
Other Decks in Programming
See All in Programming
OpenTelemetryでRailsのパフォーマンス分析を始めてみよう(KoR2024)
ymtdzzz
5
2k
Dev ContainersとGitHub Codespacesの素敵な関係
ymd65536
1
140
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
540
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
17
4.3k
Java ジェネリクス入門 2024
nagise
0
690
Tuning GraphQL on Rails
pyama86
2
1.2k
カラム追加で増えるActiveRecordのメモリサイズ イメージできますか?
asayamakk
4
1.9k
イベント駆動で成長して委員会
happymana
1
270
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.1k
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
210
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
100
Macとオーディオ再生 2024/11/02
yusukeito
0
330
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
The Invisible Side of Design
smashingmag
297
50k
Done Done
chrislema
181
16k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Docker and Python
trallard
40
3.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Optimizing for Happiness
mojombo
376
69k
Become a Pro
speakerdeck
PRO
25
5k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Making Projects Easy
brettharned
115
5.9k
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