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
540
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
220
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
AIコーディングの本質は“コード“ではなく“構造“だった / The essence of AI coding is not “code” but "structure
seike460
PRO
2
680
Devinで実践する!AIエージェントと協働する開発組織の作り方
masahiro_nishimi
6
1.9k
AI Coding Agent Enablement in TypeScript
yukukotani
15
6k
技術的負債と戦略的に戦わざるを得ない場合のオブザーバビリティ活用術 / Leveraging Observability When Strategically Dealing with Technical Debt
yoshiyoshifujii
0
150
Building an Application with TDD, DDD and Hexagonal Architecture - Isn't it a bit too much?
mufrid
0
360
AWS診断200件の分析から見る頻出指摘と対策
shoodagiri
0
110
ts-morph実践:型を利用するcodemodのテクニック
ypresto
1
480
Duke on CRaC with Jakarta EE
ivargrimstad
1
580
知識0からカンファレンスやってみたらこうなった!
syossan27
5
320
人には人それぞれのサービス層がある
shimabox
2
260
私のRubyKaigi 2025 Kaigi Effect / My RubyKaigi 2025 Kaigi Effect
chobishiba
1
200
Storybookの情報をMCPサーバー化する
shota_tech
3
1.6k
Featured
See All Featured
Designing Experiences People Love
moore
142
24k
Bash Introduction
62gerente
613
210k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.4k
Building an army of robots
kneath
306
45k
Making the Leap to Tech Lead
cromwellryan
133
9.3k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
GitHub's CSS Performance
jonrohan
1031
460k
Visualization
eitanlees
146
16k
Writing Fast Ruby
sferik
628
61k
Embracing the Ebb and Flow
colly
85
4.7k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
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