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
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
290
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
370
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
1
180
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
330
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
730
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
22
22k
最近”作らせてる” ローカルAIアプリの話
akit37
0
460
golang-bob.pdf
iwatsukayura
0
130
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
250
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
590
APNsからLive Activityを開始する話
yumnumm
0
170
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
980
Featured
See All Featured
My Coaching Mixtape
mlcsv
0
350
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
400
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
590
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.1k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
530
The Language of Interfaces
destraynor
162
27k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
530
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
260
Rails Girls Zürich Keynote
gr2m
96
14k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
750
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オススメです!!!! ご清聴ありがとうございました