How to use environment variables with the typescript definition file

I’ve used this excellent template to get going with Node and typescript serverless/lib/plugins/create/templates/aws-nodejs-typescript at master · serverless/serverless · GitHub

In the handler definition I’m trying to reference environment variables

When I print out the variable, there is no interpolation. The variable is still ${env.CONFIG_TABLE} with the braces


I would like to use environment variables for CI and .env for local development.

const serverlessConfiguration: AWS = {
  service: 'trial-service',
  frameworkVersion: '2',
  useDotenv: true,

I set the variable in the environment section of the handler. The file functions/my-function/index.ts is

import schema from './schema';
import { handlerPath } from '@libs/handlerResolver';

export default {
  handler: `${handlerPath(__dirname)}/handler.main`,
  events: [
      http: {
        method: 'post',
        path: 'make-payment',
        request: {
          schema: {
            'application/json': schema
  environment: {

I’ve got it

  environment: {
    CONFIG_TABLE : process.env.CONFIG_TABLE,