LoginSignup
0
1

More than 3 years have passed since last update.

Apex UpでNode.js × expressをAWS Lambda, API Gatewayに速攻デプロイしてみる

Posted at

はじめに

Node.js × expressのAPIのデプロイ先としてLambdaを使おうと思ったのですが
手取り早くデプロイして試したかったので、Apex Upを使ってみた。今回はその時の備忘録

Upとは

APIや静的ウェブサイトをLambda × API Gatewayにupコマンドでデプロイしてくれるツールです。

使ってみる

Upのインストール

curl -sf https://up.apex.sh/install | sh

プロジェクト作成

mkdir node-up
cd node-up
npm init
entry point: (index.js) app.js # 自分はapp.jsに変更

expressのインストール

npm install express
touch app.js
touch up.json # Upの設定ファイル

app.js

const express = require('express')
const app = express()
const { PORT = 3000 } = process.env

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(PORT);

Upの設定は以下の内容に設定

{
  "name": "node-up"
}

これで設定は完了です。

最後にgit commitします。
git commitしとかないとupしたときにエラーが出てしまいます。

git init
git add .
git commit -m "First commit"

最後にデプロイします。


up

しばらくすると以下のような内容が出てくるのでURLをチェックして表示されればおkです。


stack: complete (19.175s)
endpoint: https://.../staging/

実際の表示
hello-up.png

削除

up stack delete

さいごに

Apex Upを使えば気軽にデプロイできるのでとりあえずデプロイしたいときは重宝しそうです。

参考資料

Up公式
Up GitHub

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1