LoginSignup
5
5

More than 5 years have passed since last update.

Serverless Frameworkのresourcesを使えば、CloudFormationを利用してS3などのリソースを作成できます。
で、その書き方はおおよそこんな感じ。

serverless.yml
resources:
  Resources:
    ExampleLogs:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: example-logs
  Outputs:
    RdsLogs:
      Description: "Example Log Bucket"
      Value:
        Ref: "ExampleLogs"

OutputsRefの値と、Resourcesで設定した名前(今回はExampleLogs)は同じにしましょう。

成功すれば、Serverless FrameworkのOutputsに出力されます。

スクリーンショット 2016-11-02 0.04.23.png

ちなみにCloudFormationの記法に従えば以下のようにOutputsの値を使用できます。

serverless.yml
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "s3:GetObject"
        - "s3:PutObject"
      Resource:
        - {
          "Fn::Join": [
            "",
            [
              "arn:aws:s3:::",
              {
                "Ref": "ExampleLogs"
              }
            ]
          ]
          }
5
5
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
5