Skip to content

Instantly share code, notes, and snippets.

@bujiie
Created May 28, 2020 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bujiie/c5266af971fd84a0742adbc7ef37ff73 to your computer and use it in GitHub Desktop.
Save bujiie/c5266af971fd84a0742adbc7ef37ff73 to your computer and use it in GitHub Desktop.
Build an S3 resource only if the stage is known (i.e. do not build an S3 bucket for PR stages)
# Referenced from https://gist.github.com/DavidWells/be078deef45f8cb2e280ccc7af947392
resources:
Description: Demo Site
Conditions:
IsProd: {"Fn::Equals" : ["${self:custom.stage}", "prod"]}
IsStaging: {"Fn::Equals" : ["${self:custom.stage}", "staging"]}
IsDev: {"Fn::Equals" : ["${self:custom.stage}", "dev"]}
IsKnownStage: {"Fn::Or": [{"Condition": "IsProd"}, {"Condition": "IsStaging"}, {"Condition": "IsDev"}]}
Resources:
MyS3Bucket:
Type: AWS::S3::Bucket
Condition: IsKnownStage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment