LoginSignup
0
0

More than 3 years have passed since last update.

ServerlessFramework(AWS)でstage毎にS3などのリソースを別に作る方法

Posted at

provider > stage: ${opt:stage, self:custom.defaultStage}
custom > defaultStage: dev
custom > resourcePrefix : ${self:provider.stage}を使った値
と設定して
BucketNameを ${self:custom.resourcePrefix}-resourceとする

serverles..yml
service: serverless-sample

frameworkVersion: '2'

provider:
  name: aws
  runtime: python3.8
  stage: ${opt:stage, self:custom.defaultStage} 
  region: ${opt:provider, self:custom.defaultRegion}

custom:
  author: iwato
  defaultStage: dev
  defaultRegion: ap-northeast-1
  resourcePrefix: ${self:custom.author}-${self:service}-${self:provider.stage}
  environment:
    dev: # 開発環境
      key: dev-value
    test: # テスト環境
      key: test-value
    staging: # 検証環境
      key: staging-value
    prod: # 本番環境
      prod: prod-value

resources:
  Resources:
    NewResource:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${self:custom.resourcePrefix}-resource
  Outputs:
     NewOutput:
       Description: "Description for the output"
       Value: "Some output value"
0
0
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
0