Setting up CodePipeline template to deploy CloudFormation stack from CodeCommit

£可爱£侵袭症+ 提交于 2019-12-01 12:50:44
Sudharsan Sivasankaran

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!