.../articles/
Serverless Odds and Ends

Serverless Odds and Ends

2020.03.30

Lately I've been using Serverless on a variety of projects, including personal ones.

Put simply, it's a tool that lets you efficiently create and update resources of the kind known as FaaS (Function as a Service), like AWS Lambda or Google Cloud Functions.

Apex and AWS's own SAM CLI could also be considered similar tools.


Background

With Serverless, you can deploy with a single command, so there's no need to bundle code and dependencies before uploading. That makes it easy to deploy from your local machine or run it from CI.

If the deployment flow were completely unified, there'd be no issue, but sometimes you normally deploy from CI yet want to deploy a small fix locally, or you want to roll back after a failed deploy.

In situations like that, I'd occasionally find myself wondering "wait, what state is this in right now?", so I wanted an easy way to attach version information.

So I made it read the information from package.json and add it at deploy time.


What I did

I had been managing additional information in a separate YAML file, but I recently learned that JSON files can be loaded too.

If you've installed serverless under your project via npm or yarn, you should have a package.json, so let's load its version field as additional info.

As an example, suppose a directory contains the source code along with package.json and serverless.yml.

package.json has a version of 1.0.0.

{
  ...
  "version": "1.0.0",
  ...
}

To load this in serverless.yml, do the following.

custom:
  package: ${file(./package.json)} # Load package.json

With this in place, writing ${self:custom.package.version} lets you attach the version info of 1.0.0 at Serverless deploy time, so I passed it into a VERSION environment variable.

provider:
  ...
  environment:
    VERSION: ${self:custom.package.version} # Assign to the VERSION environment variable

This assumes you keep the version info updated appropriately, but now I can easily check which state is currently deployed.

written by

.../article/

Articles

All articles

From Firebase to Vercel, Contentful to microCMS — a migration log written with Claude Code

From Firebase to Vercel, Contentful to microCMS — a migration log written with Claude Code

We moved our corporate site's hosting and CMS, and made it bilingual along the way. The constraints we only found by running against real data were more useful than the migration itself, so this post focuses on where we got stuck.

Can't Read POST Data with Firebase Functions × Remix?

Can't Read POST Data with Firebase Functions × Remix?

How to read POST data from a Remix action when running on Firebase Functions.

Generative AI for Executives and Leaders: An Approach to Self-Driven DX

Generative AI for Executives and Leaders: An Approach to Self-Driven DX

Building a structure where executives and leaders themselves can identify issues and evaluate solutions using generative AI. We introduce how combining this with our hands-on support dramatically improves both the quality and speed of digital transformation.

Deploying a Monorepo Next.js App (App Router) to AWS Amplify

Deploying a Monorepo Next.js App (App Router) to AWS Amplify

Notes on the obstacles we hit while deploying a Next.js app managed in a monorepo to AWS Amplify.

Keeping Production Running Smoothly with Remote Work and Online Meetings [Documentation]

Keeping Production Running Smoothly with Remote Work and Online Meetings [Documentation]

Many production companies have adopted remote work as a result of the pandemic, and we are one of them.

Designing an E-Commerce Site That Sells: How to Find Great Reference Examples

Designing an E-Commerce Site That Sells: How to Find Great Reference Examples

There is no single formula for e-commerce design that sells. Driving revenue requires a solid concept, and getting to that concept requires thorough research.

Productivity Tools We Recommend as a Production Company, Including Services That Work Well Solo

Productivity Tools We Recommend as a Production Company, Including Services That Work Well Solo

With remote work becoming the norm during the COVID-19 pandemic, our team now works from home most days of the week.

We Released Thought Recorder, a Figma Plugin for Keeping a Commit History of Your Designs

We Released Thought Recorder, a Figma Plugin for Keeping a Commit History of Your Designs

We hope this helps web designers who work in Figma. Read on for how to use it.

How to Build an E-Commerce Site, and Which Platforms We Recommend

How to Build an E-Commerce Site, and Which Platforms We Recommend

Shopping online for fashion, appliances, and even groceries is now routine. With the pandemic accelerating the shift, we receive a steady stream of questions about which platform to use and how much it costs.

Generating FastAPI Schema Classes from OpenAPI

Generating FastAPI Schema Classes from OpenAPI

We chose FastAPI, a relatively modern framework, for a Python API project. FastAPI can generate an OpenAPI definition from your backend code, but here we do the opposite: generating FastAPI schema classes from an OpenAPI definition prepared in advance.

View all articles

Contact us