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 CDK × Reactでliffをつくる
Search
tokku5552
June 29, 2022
Programming
590
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
190
Google CloudとAWSのコンテナ実行環境比較
tokku5552
0
250
高スループット・低レイテンシを実現する技術
tokku5552
3
17k
AWS CDKのススメ
tokku5552
1
550
Messaging APIのメッセージオブジェクトを検証できるChrome拡張機能を作った話
tokku5552
1
160
FlutterにLINEログインを仕込んで通知メッセージを送る
tokku5552
2
1k
Flutterで単体テストを行う方法とGitHub Actionsを使った自動化
tokku5552
1
140
ネットワーク基礎 - WEBページが表示されるまで
tokku5552
1
320
インフラエンジニアのお仕事(オンプレ)
tokku5552
0
170
Other Decks in Programming
See All in Programming
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
160
Agentic UI
manfredsteyer
PRO
0
180
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
370
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
11
4.3k
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
200
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
260
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
350
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
210
The NotImplementedError Problem in Ruby
koic
1
850
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
260
OSもどきOS
arkw
0
570
Featured
See All Featured
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
390
How to build a perfect <img>
jonoalderson
1
5.7k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
Automating Front-end Workflow
addyosmani
1370
210k
The browser strikes back
jonoalderson
0
1.3k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
240
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
160
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
Building AI with AI
inesmontani
PRO
1
1.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
210
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
490
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オススメです!!!! ご清聴ありがとうございました