首页 > 解决方案 > AWS CloudFormation:如何在 AWS Pipeline 中使用 Github Enterprise 作为源

问题描述

在文档中,我们给出了以下示例:

AppPipeline: 
  Type: AWS::CodePipeline::Pipeline 
  Properties: 
    RoleArn:
      Ref: CodePipelineServiceRole 
    Stages: 
      - 
        Name: Source 
        Actions: 
          - 
            Name: SourceAction
            ActionTypeId: 
              Category: Source 
              Owner: AWS 
              Version: 1 
              Provider: S3 
            OutputArtifacts: 
              - 
                Name: SourceOutput 
            Configuration: 
              S3Bucket: 
                Ref: SourceS3Bucket 
              S3ObjectKey: 
                Ref: SourceS3ObjectKey 
            RunOrder: 1

我试图更新它以使用 GitHub 企业,但不幸的是它不起作用。有人可以展示如何正确配置它。这就是我尝试这样做的方式:

- Name: Source
  Actions:
    - Name: Source
      RunOrder: 1
      InputArtifacts: []
      ActionTypeId:
        Category: Source
        Owner: ThirdParty
        Provider: GitHubEnterpriseServer
      Configuration:
        Owner: !Sub ${GitHubRepositoryOwner}
        Repo: !Sub ${GitHubRepositoryName}
        Branch: !Sub ${GitHubIntegrationBranch}
        OAuthToken: !Sub ${GitHubPersonalAccessToken}
        PollForSourceChanges: false # Must be set to false when using webhooks
      OutputArtifacts:
        - Name: SourceArtifact

更新:

我发现 Github Enterprise 使用 codestar-connections。我已将代码编辑为如下所示:

  Stages:
    - Name: Source
      Actions:
        - InputArtifacts: []
          ActionTypeId:
            Version: '1'
            Owner: AWS
            Category: Source
            Provider: CodeStarSourceConnection
          OutputArtifacts:
            - Name: SourceArtifact
          RunOrder: 1
          Configuration:
            ConnectionArn: "arn:aws:codestar-connections:exxxxxxxxf382816da8"
            FullRepositoryId: "https://github.xxxxxx/cloudformation"
            BranchName: "main"
            OutputArtifactFormat: "CODE_ZIP"
          Name: ApplicationSource

我现在处理的问题是连接权限:

User: arn:aws:iam::xxxxxx is not authorized to perform: codestar-connections:PassConnection on resource:

标签: amazon-web-servicesgithub-enterpriseaws-cloudformation-custom-resource

解决方案


推荐阅读