Created
August 5, 2020 10:40
-
-
Save StanGenchev/d19e8689a0e173be84d9b7486877d951 to your computer and use it in GitHub Desktop.
CloudFormation CodePipeline Conditional Action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: 2010-09-09 | |
Transform: | |
- AWS::Serverless-2016-10-31 | |
Parameters: | |
ProjectId: | |
Type: String | |
Stage: | |
Type: String | |
Conditions: | |
StageNameProd: !Equals [!Ref Stage, prod] | |
Resources: | |
... | |
CodePipelineStack: | |
Type: AWS::CodePipeline::Pipeline | |
Properties: | |
Name: "Example-pipeline" | |
RoleArn: !GetAtt CodePipelineRole.Arn | |
ArtifactStore: | |
Location: !Ref ArtifactStoreBucket | |
Type: S3 | |
Stages: | |
... | |
- Name: Deploy | |
Actions: | |
- Name: GenerateChangeSet | |
ActionTypeId: | |
Category: Deploy | |
Owner: AWS | |
Version: 1 | |
Provider: CloudFormation | |
InputArtifacts: | |
- Name: BuildArtifact | |
Configuration: | |
ActionMode: CHANGE_SET_REPLACE | |
Capabilities: CAPABILITY_NAMED_IAM | |
ChangeSetName: !Sub "${Stage}-${ProjectId}-changeset" | |
RoleArn: !GetAtt CloudFormationRole.Arn | |
StackName: !Sub "${Stage}-${ProjectId}-stack-${AWS::Region}" | |
TemplatePath: BuildArtifact::template.yml | |
RunOrder: 3 | |
Region: !Ref AWS::Region | |
Namespace: DeployVariables | |
- !If | |
- StageNameProd | |
- Name: DeployApproval | |
ActionTypeId: | |
Category: Approval | |
Owner: AWS | |
Version: 1 | |
Provider: Manual | |
Configuration: | |
NotificationArn: arn:aws:sns:us-west-2:00123456789:codepipeline-appvoral | |
CustomData: !Sub "Approve the changeset for ${ProjectId} to deploy to the ${Stage} stage." | |
RunOrder: 4 | |
- !Ref AWS::NoValue | |
- Name: ExecuteChangeSet | |
ActionTypeId: | |
Category: Deploy | |
Owner: AWS | |
Version: 1 | |
Provider: CloudFormation | |
Configuration: | |
ActionMode: CHANGE_SET_EXECUTE | |
ChangeSetName: !Sub "${Stage}-${ProjectId}-changeset" | |
StackName: !Sub "${Stage}-${ProjectId}-stack-${AWS::Region}" | |
RunOrder: !If [StageNameProd, 5, 4] | |
Region: !Ref AWS::Region |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment