dayjournal memo

Total 975 articles!!

Serverless Framework #006 – AWSデプロイ設定

Yasunori Kirimoto's avatar


画像



AWSのデプロイ設定をするメモ。



serverless.tsに設定追加。

serverless.ts

import type { AWS } from '@serverless/typescript';

const serverlessConfiguration: AWS = {
  service: 'sample',
  frameworkVersion: '2',
  custom: {
    webpack: {
      webpackConfig: './webpack.config.js',
      includeModules: true
    }
  },
  // Add the serverless-webpack plugin
  plugins: ['serverless-webpack'],
  provider: {
    name: 'aws',
    runtime: 'nodejs12.x',
    region: 'ap-northeast-1',
    profile: 'AWSのプロファイルユーザー名',
    apiGateway: {
      minimumCompressionSize: 1024,
    },
    environment: {
      AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
    },
  },
  functions: {
    hello: {
      handler: 'handler.hello',
      events: [
        {
          http: {
            method: 'get',
            path: 'hello',
          }
        }
      ]
    }
  }
}

module.exports = serverlessConfiguration;

対象のリージョンを設定。

region: 'ap-northeast-1',

対象のAWSのプロファイルユーザー名を設定。

profile: 'AWSのプロファイルユーザー名',



Serverless FrameworkをAWSで手軽に始める方法を公開しています。
Serverless Framework #001 – 環境構築
Serverless Framework #002 – AWS事前準備



book

Q&A