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
510
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
200
2022_07_14_おすすめの技術書 LT会 - vol.4_ 問題解決を仕事にする 全ての人へ
ih6109
0
100
2021_08_19 おすすめの技術書 LT会 - vol.2 Vue.js3超入門がとにかくやさしい
ih6109
0
21k
Other Decks in Programming
See All in Programming
2,500万ユーザーを支えるSREチームの6年間のスクラムのカイゼン
honmarkhunt
6
4.2k
ESLintプラグインを使用してCDKのセオリーを適用する
yamanashi_ren01
2
380
Immutable ActiveRecord
megane42
0
120
さいきょうのレイヤードアーキテクチャについて考えてみた
yahiru
1
540
チームの立て直し施策をGoogleの 『効果的なチーム』と見比べてみた
maroon8021
0
270
はてなにおけるfujiwara-wareの活用やecspressoのCI/CD構成 / Fujiwara Tech Conference 2025
cohalz
3
3.2k
Alba: Why, How and What's So Interesting
okuramasafumi
0
240
2025.01.17_Sansan × DMM.swift
riofujimon
2
670
Fibonacci Function Gallery - Part 2
philipschwarz
PRO
0
230
Scaling your build logic
antalmonori
1
150
ASP.NET Core の OpenAPIサポート
h455h1
0
160
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
980
Featured
See All Featured
A Tale of Four Properties
chriscoyier
157
23k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
11
900
GraphQLとの向き合い方2022年版
quramy
44
13k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
520
Fantastic passwords and where to find them - at NoRuKo
philnash
50
3k
4 Signs Your Business is Dying
shpigford
182
22k
Building an army of robots
kneath
302
45k
It's Worth the Effort
3n
184
28k
Facilitating Awesome Meetings
lara
51
6.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
6
220
A Philosophy of Restraint
colly
203
16k
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