Setting up CodePipeline template to deploy CloudFormation stack from CodeCommit

后端 未结 1 657
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-16 14:52

From a CloudFormation template, you can deploy CodeCommit and CodePipeline. From this announcement,

You can now choose AWS CloudFormation as a deploym

相关标签:
1条回答
  • 2021-01-16 15:24

    Offical Documentation:

    The IAM Role is broken too. Below is a functioning stack. For various types of CF deployments, see the CF Configuration Properties. A helpful sample CF stack is here.

    Resources:
      PipelineRepo:
        Type: AWS::CodeCommit::Repository
        Properties:
          RepositoryName: pipeline
          RepositoryDescription: Pipeline setup repo
    
      PipelineArtifacts:
        Type: AWS::S3::Bucket
    
      PipelineRole:
        Type: AWS::IAM::Role
        Properties:
          AssumeRolePolicyDocument:
            Version: 2012-10-17
            Statement:
              - Effect: Allow
                Principal:
                  Service:
                    - codepipeline.amazonaws.com
                    - cloudformation.amazonaws.com
                Action: sts:AssumeRole
          Policies:
            - PolicyName: CloudPipelinePolicy
              PolicyDocument:
                Version: 2012-10-17
                Statement:
                  - Effect: Allow
                    Action: "cloudformation:*"
                    Resource: "*"
                  - Effect: Allow
                    Action: "codecommit:*"
                    Resource: "*"
                  - Effect: Allow
                    Action: "s3:*"
                    Resource: "*"
                  - Effect: Allow
                    Action:
                      - iam:PassRole
                    Resource: "*"
    
      Pipeline:
        Type: AWS::CodePipeline::Pipeline
        Properties:
          Name: pipeline-pipeline
          ArtifactStore:
            Type: S3
            Location:
              Ref: PipelineArtifacts
          RoleArn: !GetAtt [PipelineRole, Arn]
          Stages:
            -
              Name: Source
              Actions:
                -
                  Name: CheckoutSourceTemplate
                  ActionTypeId:
                    Category: Source
                    Owner: AWS
                    Version: 1
                    Provider: CodeCommit
                  Configuration:
                    PollForSourceChanges: True
                    RepositoryName: !GetAtt [PipelineRepo, Name]
                    BranchName: master
                  OutputArtifacts:
                    - Name: TemplateSource
                  RunOrder: 1
            -
              Name: Deploy
              Actions:
                -
                  Name: CreateStack
                  ActionTypeId:
                    Category: Deploy
                    Owner: AWS
                    Provider: CloudFormation
                    Version: 1
                  InputArtifacts:
                    - Name: TemplateSource
                  Configuration:
                    ActionMode: CREATE_UPDATE
                    RoleArn: !GetAtt [PipelineRole, Arn]
                    StackName: pipeline
                    Capabilities: CAPABILITY_IAM
                    TemplatePath: TemplateSource::template.yml
                  RunOrder: 1
    
    0 讨论(0)
提交回复
热议问题