aws-cloudformation / rain

A development workflow tool for working with AWS CloudFormation.
Apache License 2.0
784 stars 71 forks source link

Asset deployment and a sample web application #511

Closed ericzbeard closed 1 day ago

ericzbeard commented 1 month ago

This PR adds the concept of Metadata commands to Rain, and it adds a complete serverless web application sample. (Sorry I know this is a huge PR, but I needed to add a lot of new features to make it possible to deploy a fully functional application with a single deploy command)

Resources:
  Bucket:
    Type: AWS::S3::Bucket
    Metadata:
      Rain:
        Version: 1
        EmptyOnDelete: true
        RunBefore:
          Command: before-deployment.sh
        RunAfter:
          Command: after-deployment.sh
        Content: site 
        DistributionLogicalId: SiteDistribution

Rain will run the commands indicated before and after deployment. Then after a create or update operation, rain will upload the contents of the specified directory to this S3 bucket. Then it will invalidate a CloudFront distribution. On a delete operation, it will delete all contents of the bucket.

This PR also adds some useful new modules in the test/modules directory and shows how to use them in test/webapp/webapp.yaml. Once the module system feels mature enough, I'd like to dedicate an entire repo to rain modules.

You should be able to deploy the sample with rain deploy --experimental test/webapp/webapp.yaml. The only manual operation will be to go into Cognito and create a user, then you can go to the Hosted UI in the app client configuration section to log in. The Dynamo table is empty at first, you can manually add some entries since the web app only does GETs.