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
TypeScriptだけでAWSを開発する
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
570
改めて考えるOSSのあり方について
ufoo68
0
71
文法で学ばないJavaScript
ufoo68
0
83
Cookieとは?
ufoo68
1
94
今更ながら、開発現場での生成AI活用について
ufoo68
0
93
28歳独身エンジニア 婚活してみた
ufoo68
0
46
OpenAIでクッキー型を作る
ufoo68
1
77
初めて開発リーダーをやってみた話
ufoo68
0
160
M5Stack用の指紋認証デバイスを試す
ufoo68
0
930
Other Decks in Programming
See All in Programming
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
680
Japan Community Day at Kubecon + CloudNativeCon Japan 2026: Learning Container Privilege Control by Building My Own Low-Level Container Runtime
ternbusty
1
150
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
180
「人を評価する AI」の設計と実装
ryoyanara
0
200
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
180
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
490
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
140
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
400
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
160
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
440
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
140
Featured
See All Featured
Chasing Engaging Ingredients in Design
codingconduct
0
270
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Scaling GitHub
holman
464
140k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
240
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Building Applications with DynamoDB
mza
96
7.2k
Building the Perfect Custom Keyboard
takai
2
840
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
56k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
890
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開発を!