Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
AWS CDK × Reactでliffをつくる
Search
tokku5552
June 29, 2022
Programming
610
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
AWS CDK × Reactでliffをつくる
AWS CDK × Reactでliffをつくる
tokku5552
June 29, 2022
More Decks by tokku5552
See All by tokku5552
他責思考で考える、EMとICの本音
tokku5552
1
200
Google CloudとAWSのコンテナ実行環境比較
tokku5552
0
270
高スループット・低レイテンシを実現する技術
tokku5552
3
17k
AWS CDKのススメ
tokku5552
1
580
Messaging APIのメッセージオブジェクトを検証できるChrome拡張機能を作った話
tokku5552
1
180
FlutterにLINEログインを仕込んで通知メッセージを送る
tokku5552
2
1.1k
Flutterで単体テストを行う方法とGitHub Actionsを使った自動化
tokku5552
1
170
ネットワーク基礎 - WEBページが表示されるまで
tokku5552
1
340
インフラエンジニアのお仕事(オンプレ)
tokku5552
0
180
Other Decks in Programming
See All in Programming
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
contenteditable と日本語入力に向き合う
colorful12
0
200
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
Event is what happens
moro
2
850
すこし踏み込む CancellationToken
htkym
2
1.7k
Next.js: The final boss of Web Performance
guaca
0
270
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
320
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
620
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
160
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
180
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
560
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Everyday Curiosity
cassininazir
0
360
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Test your architecture with Archunit
thirion
2
2.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3.1k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
550
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
340
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Transcript
AWS CDK x ReactでLIFFアプリ LINE Monthly LT #3 2022/6/29
自己紹介 とっく(@tokkuu) • ミロゴス株式会社のエンジニア • php/python/TypeScript • AWS周り 3-tierからサーバレスまで •
元々はSIerのインフラエンジニア • LINE API歴は半年くらい 2
はじめに • 前提知識 ◦ AWSリソース(CloudFront/S3) ◦ CloudFormationの概要(json or yamlでテンプレートを書いてスタック作成 )
◦ LINE Developersコンソールの操作・liffについて • このスライドの元ネタ ◦ https://zenn.dev/tokku5552/articles/liff-cdk-create • 参考 ◦ https://developers.line.biz/ja/docs/liff/ 3
AWS CDKとは • AWSが提供するIaC(Infrastructure as Code)ツールの一つ ◦ CloudFormationのテンプレートを作成し、デプロイしてくれるツール • CloudFormationが対応しているものは対応していると考えて良い
◦ サーバーレスでないリソースも作れる • 特徴はjsonやyamlではなく、プログラミング言語でインフラを記述できるところ。 ◦ IDEの補完などの補助機能が使える。画像は TypeScriptの場合の例 4
AWS CDK×Reactでのliffのはじめかた
構成 • AWS CDKがCloudFormationの スタックを作成 • CloudFrontとS3バケットが 作成される • liffのコードもビルドしたものをcdkで
デプロイ 6 ・リポジトリ https://github.com/tokku5552/liff-cdk-sample
AWS CDK × Reactでのliffのはじめかた • cdk init ◦ cdkの雛形が作られる ◦
サーバーレスな構成でアプリケーションコードと一緒に管理するときは cdkのプロジェクト構成がトップにあったほうがやりやすい。 • create-liff-app ◦ プロジェクトルートで実行するが、途中で聞かれる project nameのフォルダが 勝手に切られ、その下に作成される。(好都合) • ここまででyarn devでliffが起動&cdk deployでデプロイできる ◦ cdkはstackを定義していないので、 liffがデプロイされるわけではないが ローカルの環境構築はこれだけ 7
フォルダ構成 . ├── README.md ├── bin/ │ └── liff-cdk-sample.ts ├──
cdk.json ├── cdk.out/ ├── lib/ │ └── liff-cdk-sample-stack.ts ├── liff-app/ │ ├── index.html │ ├── package.json │ ├── src/ │ │ ├── App.css │ │ ├── App.tsx │ │ ├── favicon.ico │ │ ├── main.tsx │ │ └── vite-env.d.ts │ ├── vite.config.ts ├── package.json └── tsconfig.json 8 • cdk init でbin,lib,cdk.jsonなどが作られる ◦ binがcdkコマンドのエントリポイント ◦ libの下にスタックのコードを置いていく • create-liff-appではproject nameで指定した フォルダが作られる ◦ その下はviteというビルドツールで Reactの雛形の構 成が生成されている ◦ cd liff-app && yarn devでliffアプリがローカルで起 動する
stackの記述 export class LiffCdkSampleStack extends Stack { constructor(scope: Construct, id:
string, props?: StackProps) { super(scope, id, props); const liffAppBucket = new s3.Bucket(this, 'LiffAppBucket', { websiteIndexDocument: 'index.html' }); const liffAppDistribution = new cloudfront.CloudFrontWebDistribution(this, 'LiffAppDistribution', { originConfigs: [ { s3OriginSource: { s3BucketSource: liffAppBucket, originAccessIdentity: liffAppIdentity }, behaviors: [{isDefaultBehavior: true}] } ], }) Stackを継承したclassの中の constructorに作りたいリソースを 書いていく 前段で作成したS3バケットを変数に入 れておき、CloudFrontのオリジンに渡し ている。これで連携可能 9 ※途中省略しています
デプロイ npx cdk deploy CloudFormationのスタックが作られる 10
liffアプリ起動🎉 11
まとめ • liffアプリをAWS上で、Reactで作る場合はAWS CDKがおすすめ • CDKならホスティングのみならず、API Gateway + Lambda +
DynamoDBみたいな 構成もかなり短く記述できる • とにかくAWS CDKオススメです!!!! ご清聴ありがとうございました