5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Serverless Framework OSS版のoss-serverlessを試す

Last updated at Posted at 2025-06-04

Serverless Framework

Serverless FrameworkはIaCツールの1つで、AWSのリソース作成時によく使われています。

Lambda等のAWSリソースをコード管理する際にとても便利なツールなのですが、バージョン4系の発表とともに新たなライセンス形態が導入されるなど、v3系を使っていた人には大きなアップデートが入っています。

As we announced at the end of 2023, Serverless Framework CLI will continue to be free for individual developers and small businesses, but will no longer be free for Organizations that have greater than $2M in annual revenue. These Organizations will require a commercial Subscription.

These changes only apply to Serverless Framework V.4 and beyond and not to earlier versions. Serverless Framework V.3 will continue to be maintained via critical security and bug fixes through 2024.

とあるように、v4利用時は、年間売上が200万ドルを超える組織は有償サブスクリプションの購入が必要になります。

このサブスクリプション購入にネックを感じる人は多いのではないでしょうか。
(ちなみに、v3のサポート期限は2024年で終了してはいます。)

そんな中、oss-serverlessというリポジトリを見つけました。

oss-serverless

This repository is a maintained alternative to Serverless Framework v3. It exists for those that cannot upgrade to Serverless Framework v4 and is a drop-in replacement for v3.

The repository has been created and is maintained by Bref maintainers and contributors. The main goal of this repository is to provide continuity for Bref users, so that these Bref projects keep working for the next 5 years. No major new features are planned. However, community contributions to keep the project running (even for languages other than PHP), like adding support to new runtime versions, adapting to AWS changes, bugfixes, and other small improvements are welcome.

と、あるように
Serverless Framework v4にアップグレードできないユーザー向けに、 Brefチームがv3の代替版を維持しているリポジトリです。
ちなみにBrefとは、AWS Lambda用のPHPランタイムを提供するツールです。

v4系を使用するには抵抗があり、v3系のまま塩漬けにしてしまっていた際の解決策に、また、v4系から別のIaCツールへの移行を検討する際の選択肢の1つになりえそうだったので、ひとまず試すことにしました。

今回は、既存のServerless Framework (v3)から、oss-serverlessへの移行を試してみました。

Serverless Framework の新規プロジェクトを作成〜デプロイまで

3系をインストール

$ npm install -g serverless@3.39.0

slsコマンドで新規プロジェクトを作成

$ sls

Creating a new serverless project

? What do you want to make? AWS - Node.js - HTTP API
? What do you want to call this project? aws-node-http-api-project

✔ Project successfully created in aws-node-http-api-project folder

? Register or Login to Serverless Framework No

? Do you want to deploy now? No

What next?
Run these commands in the project directory:

serverless deploy    Deploy changes
serverless info      View deployed endpoints and resources
serverless invoke    Invoke deployed functions
serverless --help    Discover more commands

主な自動作成ファイルの中身を確認

serverless.yml
service: aws-node-http-api-project
frameworkVersion: '3'

provider:
  name: aws
  runtime: nodejs18.x

functions:
  api:
    handler: index.handler
    events:
      - httpApi:
          path: /
          method: get
index.js
module.exports.handler = async (event) => {
  return {
    statusCode: 200,
    body: JSON.stringify(
      {
        message: "Go Serverless v3.0! Your function executed successfully!",
        input: event,
      },
      null,
      2
    ),
  };
};

デプロイを行う

sls deployコマンドを実行

$ sls deploy                  

Deploying aws-node-http-api-project to stage dev (us-east-1)

✔ Service deployed to stack aws-node-http-api-project-dev (100s)

.
.
.

Need a faster logging experience than CloudWatch? Try our Dev Mode in Console: run "serverless dev"

デプロイが正常終了し、スタックが新規作成されていることを確認できました。

スクリーンショット 2025-06-04 23.05.46.png

oss-serverlessへの移行

既存のserverlessパッケージ削除

$ npm remove -g serverless
   note: using Volta to uninstall serverless
Removed executable 'serverless' installed by 'serverless'
Removed executable 'sls' installed by 'serverless'
success: package 'serverless' uninstalled

oss-serverlessのインストール

$ npm install -g osls

npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm warn deprecated superagent@7.1.6: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net

added 487 packages in 16s

78 packages are looking for funding
  run `npm fund` for details

バージョンの確認

$ serverless --version

osls version: 3.51.0

oss-serverlessでdeployを検証する

Serverless Frameworkのv3ではLambda関数のNode.jsランタイムサポートはv18系(v20系の誤りでした。6/6追記)まででしたが、
oss-serverlessでは最新のv22系のLambda関数のNode.jsランタイムサポートされています。

そこで、Node.jsのランタイムを22系にして、oss-serverlessでデプロイを試してみます。

serverless.ymlでnodejsのランタイムバージョンを22に変更します。

serverless.yml
service: aws-node-http-api-project
frameworkVersion: '3'

provider:
  name: aws
-  runtime: nodejs18.x
+  runtime: nodejs22.x

functions:
  api:
    handler: index.handler
    events:
      - httpApi:
          path: /
          method: get

sls deployコマンドを実行します。

$ sls deploy 

デプロイ終了後、Lambda関数のランタイムを確認してみます。

スクリーンショット 2025-06-04 23.51.19.png

無事、oss-serverlessを使用して(Serverless Framework本家のv4を使用せず)、Lambda関数のNode.jsランタイムを22系にバージョンアップすることができました。

最後に

本家Serveless Frameworkからoss-serverlessへの移行を試してみました。
少ない手数で楽に移行できるのが実感できました。

npmでの週間ダウンロード数も2025年5月現在は2万程度で安定してきているようです。

The main goal of this repository is to provide continuity for Bref users, so that these Bref projects keep working for the next 5 years.

とあるように、開発元のBrefはoss-serverlessで5年間の維持を目的にしているため、いずれは終わりが来る可能性は高いですが、一時的な退避先としては使えるかもしれません。

5
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
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?