Creating an S3 bucket and adding a file using the Serverless Framework

732 views Asked by At

Is it possible to specify a static file to upload to an S3 bucket resource in my serverless.yaml file?

i.e.

resources:
  Resources:
   PropertiesBucket:
     Type: AWS::S3::Bucket
     Properties:
       BucketName: ${self:provider.stage}-MyBucket
     File:
        ./myfile.json
        ????
1

There are 1 answers

1
wjordan On BEST ANSWER

Adding a static file to an S3 bucket is not supported by any official AWS CloudFormation resources, but gilt/cloudformation-helpers has a custom resource, Put S3 Objects, that can do this. See Usage for instructions on installation and usage.