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
Kotlinでサーバーレス! 「Kotless」の紹介
Search
h.isoe
September 29, 2021
Programming
1
550
Kotlinでサーバーレス! 「Kotless」の紹介
サーバーレス LT #r_serverlesslt
https://rakus.connpass.com/event/221200/
上記のLT登壇で利用したスライドです。
h.isoe
September 29, 2021
Tweet
Share
More Decks by h.isoe
See All by h.isoe
Go言語のモジュール管理_完全に理解した
ih6109
0
240
2022_07_14_おすすめの技術書 LT会 - vol.4_ 問題解決を仕事にする 全ての人へ
ih6109
0
110
2021_08_19 おすすめの技術書 LT会 - vol.2 Vue.js3超入門がとにかくやさしい
ih6109
0
22k
Other Decks in Programming
See All in Programming
サーバーサイドのビルド時間87倍高速化
plaidtech
PRO
0
710
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
260
実用的なGOCACHEPROG実装をするために / golang.tokyo #40
mazrean
1
230
[FEConf 2025] 모노레포 절망편, 14개 레포로 부활하기까지 걸린 1년
mmmaxkim
0
1.5k
CSC305 Summer Lecture 12
javiergs
PRO
0
140
開発チーム・開発組織の設計改善スキルの向上
masuda220
PRO
18
10k
プロポーザル駆動学習 / Proposal-Driven Learning
mackey0225
2
950
Microsoft Orleans, Daprのアクターモデルを使い効率的に開発、デプロイを行うためのSekibanの試行錯誤 / Sekiban: Exploring Efficient Development and Deployment with Microsoft Orleans and Dapr Actor Models
tomohisa
0
240
Azure SRE Agentで運用は楽になるのか?
kkamegawa
0
1.6k
フロントエンドのmonorepo化と責務分離のリアーキテクト
kajitack
2
160
More Approvers for Greater OSS and Japan Community
tkikuc
1
110
Zendeskのチケットを Amazon Bedrockで 解析した
ryokosuge
3
280
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
4 Signs Your Business is Dying
shpigford
184
22k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Side Projects
sachag
455
43k
Agile that works and the tools we love
rasmusluckow
330
21k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.1k
Transcript
Kotlinでサーバーレス! 「Kotless」の紹介 2021/09/29 サーバーレス LT 磯江 宏由紀
自己紹介 ❖ 磯江 宏由紀(Twitter:@ihirhs) ➢ 虎の穴ラボ株式会社 ▪ 通販サイトの開発 ▪ ファンクラブプラットフォームサービスの開発
➢ Java、Kotlinを利用したサーバサイド開発 ➢ 直近一ヶ月はRailsとVue.jsの開発! ❖ サーバーレスやりたい! ➢ 今のスキルも活かしたい! ➢ Kotlessがあるじゃないか! 2
アジェンダ ❖ Kotlessってなに? ➢ 仕組み ➢ 利用に必要なもの ➢ 構成 ❖
アプリケーションを定義する ❖ デプロイ設定を定義する ❖ Kotlessのオススメポイント ❖ Kotlessを利用する上での注意点 3
Kotlessってなに? ❖ Kotlin製のサーバーレスフレームワーク ➢ アプリケーションの開発に注力するためのフレームワーク ❖ アプリケーションのコードからデプロイに必要なTerraformのコードを生成 ❖ ローカルでの動作確認からデプロイまで可能 ❖
ver0.1.6現在、AWSでのみ対応 ❖ 次バージョン0.2.0でMicrosoft Azure 4
Kotlessの仕組み 5
❖ AWSアカウント ➢ +AWS Command Line Interfaceの導入 ❖ アプリケーションを公開するためのRoute53で管理しているDNSゾーン ❖
Kotlessアーティファクトを保存しておくS3バケット ❖ AWS Certificate Managerの証明書 ❖ デプロイするコード Kotlessを利用するために必要なもの 6
Kotlessの構成 ❖ アプリケーションを定義する ➢ Kotless DSL ▪ フレームワーク独自の記法でコーディング ➢ Ktor
▪ サーバーサイドKotlinのフレームワーク「Ktor」の記法でコーディング ➢ Spring Boot ▪ アノテーションを利用してルーティングを設定 ❖ デプロイ設定を定義する ➢ Gradleプラグイン ▪ 利用するS3バケットやDNSなどを設定 ▪ ローカル実行やデプロイなどの Gradleタスクを提供 7
アプリケーションを定義する(Kotless DSL) ❖ アノテーションでルーティング 8 @Get("/") fun main() = "Hello
world!"
アプリケーションを定義する(Ktor) ❖ Kotlessを継承して、prepareメソッドをOverride ❖ ルーティングとレスポンスはKtorの記法 9 class Server : Kotless()
{ override fun prepare(app: Application) { app.routing { get("/") { call.respondText { "Hello World!" } } } } }
アプリケーションを定義する(Spring Boot) ❖ Kotlessを継承して、bootKlassをOverride ❖ ルーティングはSpring Bootの記法 10 @SpringBootApplication open
class Application : Kotless() { override val bootKlass: KClass<*> = this::class } @RestController object Pages { @GetMapping( "/") fun main() = "Hello World!" }
デプロイ設定を定義する(build.gradle.kts) 11 kotless { config { bucket = "kotless.s3.example.com" //
利用するS3バケット terraform { profile = "example" // AWS CLIのプロファイル region = "us-east-1" } } webapp { // アプリケーションを公開するドメイン route53 = Route53("kotless", "example.com") } }
デプロイする Gradleタスクの「deploy」を実行するだけ 12
Kotlessのオススメポイント ❖ アプリケーションの開発に専念できる ❖ Ktor、SpringBootなどサーバーサイドKotlinの知見を活用できる ❖ ローカルでの動作確認ができる 13
Kotlessを利用する上での注意点 ❖ まだメジャーバージョンがリリースされていない ➢ 実装が大きく変わるかも? ❖ 一般公開したくない場合には、ひと手間必要 ❖ デプロイしてしまうとAWS費用がかかります ➢
自分の場合はS3、Route53で$1/月 14
Kotless関連のリンク https://github.com/JetBrains/kotless https://site.kotless.io/ 15