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
230
2022_07_14_おすすめの技術書 LT会 - vol.4_ 問題解決を仕事にする 全ての人へ
ih6109
0
110
2021_08_19 おすすめの技術書 LT会 - vol.2 Vue.js3超入門がとにかくやさしい
ih6109
0
21k
Other Decks in Programming
See All in Programming
オンコール⼊⾨〜ページャーが鳴る前に、あなたが備えられること〜 / Before The Pager Rings
yktakaha4
2
1.1k
The Evolution of Enterprise Java with Jakarta EE 11 and Beyond
ivargrimstad
0
460
DMMを支える決済基盤の技術的負債にどう立ち向かうか / Addressing Technical Debt in Payment Infrastructure
yoshiyoshifujii
4
590
CIを整備してメンテナンスを生成AIに任せる
hazumirr
0
190
顧客の画像データをテラバイト単位で配信する 画像サーバを WebP にした際に起こった課題と その対応策 ~継続的な取り組みを添えて~
takutakahashi
4
1.4k
Vibe Codingの幻想を超えて-生成AIを現場で使えるようにするまでの泥臭い話.ai
fumiyakume
18
9.1k
ソフトウェア設計とAI技術の活用
masuda220
PRO
25
6.7k
SwiftでMCPサーバーを作ろう!
giginet
PRO
2
190
Claude Code派?Gemini CLI派? みんなで比較LT会!_20250716
junholee
1
690
リッチエディターを安全に開発・運用するために
unachang113
1
240
The Niche of CDK Grant オブジェクトって何者?/the-niche-of-cdk-what-isgrant-object
hassaku63
1
690
Advanced Micro Frontends: Multi Version/ Framework Scenarios @WAD 2025, Berlin
manfredsteyer
PRO
0
440
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
The Pragmatic Product Professional
lauravandoore
35
6.8k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
Being A Developer After 40
akosma
90
590k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
Code Review Best Practice
trishagee
69
19k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Into the Great Unknown - MozCon
thekraken
40
1.9k
We Have a Design System, Now What?
morganepeng
53
7.7k
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