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
TypeScriptだけでAWSを開発する
Search
ufoo68
April 14, 2020
Programming
780
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TypeScriptだけでAWSを開発する
ufoo68
April 14, 2020
More Decks by ufoo68
See All by ufoo68
BlenderをCodexで動かす
ufoo68
1
760
改めて考えるOSSのあり方について
ufoo68
0
91
文法で学ばないJavaScript
ufoo68
0
100
Cookieとは?
ufoo68
1
110
今更ながら、開発現場での生成AI活用について
ufoo68
0
100
28歳独身エンジニア 婚活してみた
ufoo68
0
56
OpenAIでクッキー型を作る
ufoo68
1
87
初めて開発リーダーをやってみた話
ufoo68
0
160
M5Stack用の指紋認証デバイスを試す
ufoo68
0
970
Other Decks in Programming
See All in Programming
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
120
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
190
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
34
16k
Simple Storage Service(S3) is not simple
iwatsukayura
0
220
mrbgem 三角測量 開発
ogom
0
210
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
630
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
380
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
350
SREの越境 / SRE Collaboration
y0hgi
2
300
Verilogで学ぶCPU自作入門
uyuki234
8
4k
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
120
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
320
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
260
Chasing Engaging Ingredients in Design
codingconduct
0
340
How GitHub (no longer) Works
holman
316
150k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
290
Practical Orchestrator
shlominoach
192
12k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
450
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
480
Product Roadmaps are Hard
iamctodd
55
13k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
320
Transcript
TypeScriptだけで AWSを開発する AWS CDKを使おう
自己紹介 • 名前 ◦ ufoo68 • やってること ◦ AWSを使った開発 ◦
スポーツIoTLTの主催 • 最近とった資格 ◦ ソリューションアーキテクトアソシエイト ◦ Alexaスキルビルダー
TypeScriptだけでAWS開発をするとは
文字通り、 AWSコンソールを一切触らずに、 CloudFormationを書かずに、 AWSのすべてのインフラを構築すること
コンソールを使う問題点 一度構築したAWSのインフラ環境の再現手順を記録したい場合、以下の手段が思いつ くが、 1. コンソールで行った操作手順を記録する 2. AWS CLIで同様の環境構築をするためのシェルスクリプトを書く ぶっちゃけ、1.も2.の方法もダルいしやりたくはないよね。。。(^_^;)
CloudFormationを使う "myDynamoDBTable" : { "Type" : "AWS::DynamoDB::Table", "Properties" : {
"AttributeDefinitions": [ { "AttributeName" : {"Ref" : "HashKeyElementName"}, "AttributeType" : {"Ref" : "HashKeyElementType"} } ], "KeySchema": [ { "AttributeName": {"Ref" : "HashKeyElementName"}, "KeyType": "HASH" } ], "ProvisionedThroughput" : { "ReadCapacityUnits" : {"Ref" : "ReadCapacityUnits"}, "WriteCapacityUnits" : {"Ref" : "WriteCapacityUnits"} } } } こんな感じで、json(or yaml)でAWSのインフラや設定を定義できる AWSサービス
CloudFormationの問題点 • テンプレートファイルの記法を覚える必要がある ◦ それなりに独特のルールがあるので一種の言語に近い • 冗長な構文が増える ◦ 共通化したいなら自分でシェルスクリプト書くしかない •
何よりも型を教えてくれない! ◦ 公式ドキュメントとにらめっこするしかない
そこで、AWS CDKの紹介です AWS CDKとは、プログラミング言語を使ってAWSのクラウド環境を構築するためのオー プンソースのフレームワークである。 AWS CDKではソースコードからCloudFormationを作成してリソースのクラウドへのデ プロイを行う
対応言語 以下の言語が選択できる • TypeScript • Python • .NET • Java
CDKのいいところ • 各リソースの型が定義してある ◦ 公式ドキュメントを見ずに構文が予測できる ◦ 構文エラーをデプロイする前に検出することができる • 使い慣れた文法で書ける ◦
メジャーな言語が揃っている • 共通化ができる ◦ constructという機能でライブラリ化ができる ◦ 実装ミスを防ぐ ◦ クソ長い行数のCloudFormationに苦しむことがない
実用例
つくるもの 1. Lambdaを呼び出せるAPI Gatewayを定義する 2. 共通化する
型を定義しながらAWSが開発できる export interface LambdaApiProps { environment?: { [key: string]: string
} lambdaPath: string } export class LambdaApi extends cdk.Construct { public readonly handler: lambda.Function public readonly api: apigateway.LambdaRestApi constructor(scope: cdk.Construct, id: string, { environment, lambdaPath }: LambdaApiProps) { super(scope, id) this.handler = new lambda.Function(this, `${id}Handler`, { runtime: lambda.Runtime.NODEJS_12_X, code: lambda.Code.asset(lambdaPath), handler: 'index.handler', environment }) this.api = new apigateway.LambdaRestApi(this, `${id}Endpoint`, { handler: this.handler }) } }
ちなみに cdk-lambda-apiパッケージで公開しました(以下のように使えます) new LambdaApi(this, 'LambdaApi', { lambdaPath: 'lambda' })
さいごに • CDKを使えば、TypeScriptだけでAWSが開発できる • CloudFormationではできなかった型のチェックも可能 • なんなら自ら型を定義できる • 重複するインフラの共通化・npm公開もできる •
型のある安心安全なAWS開発を!