Ken J
Ken J

Reputation: 4562

AWS CodePipeline Add Github Source from CloudFormation Template

I'm working off of the Cloudformation stack from this tutorial:

https://aws.amazon.com/blogs/compute/continuous-deployment-for-serverless-applications/

It creates a pipeline with a CodeCommit repository as a source. I'd like to switch this to a Github repository. Here's the code that is defining this resource:

 Pipeline:
        Type: AWS::CodePipeline::Pipeline
        Properties:
            ArtifactStore: 
                Location: !Ref BuildArtifactsBucket
                Type: S3
            Name: !Sub ${ServiceName}_pipeline
            RoleArn: !GetAtt PipelineExecutionRole.Arn
            Stages:
                - Name: Source
                  Actions:
                    - Name: CodeCommitRepo
                      ActionTypeId:
                        Category: Source
                        Owner: AWS
                        Provider: CodeCommit
                        Version: 1
                      Configuration:
                        RepositoryName: !Sub '${ServiceName}_repo'
                        BranchName: master
                      OutputArtifacts:
                        - Name: SourceZip
                      RunOrder: 1

How is GitHub defined as a resource and how is the authentication handled for a private repository?

Upvotes: 1

Views: 1112

Answers (1)

varnit
varnit

Reputation: 1897

For github you need to replace provider with github for example

 Pipeline:
        Type: AWS::CodePipeline::Pipeline
        Properties:
            ArtifactStore: 
                Location: !Ref BuildArtifactsBucket
                Type: S3
            Name: !Sub ${ServiceName}_pipeline
            RoleArn: !GetAtt PipelineExecutionRole.Arn
            Stages:
                - Name: Source
                  Actions:
                    - Name: GithubRepo
                      ActionTypeId:
                        Category: Source
                        Owner: ThirdParty
                        Provider: GitHub
                        Version: 1
                      Configuration:
                        "Owner": "MyGitHubAccountName",
                        "Repo": "MyGitHubRepositoryName",
                        "PollForSourceChanges": "false",
                        "Branch": "master",
                        "OAuthToken": "****"

                      OutputArtifacts:
                        - Name: SourceZip
                      RunOrder: 1

For more information click on

code pipeline thirdparty source provider

Here, is how to get github personal token and insert it to your code pipeline

github personal token intergration into code pipeline

Upvotes: 3

Related Questions