【发布时间】:2018-12-19 14:21:10
【问题描述】:
我有一个在帐户 CI 中运行的跨帐户管道,通过 CloudFormation 在另一个帐户 DEV 中部署资源。 部署后,我将工件输出保存为 JSON 文件,并希望通过 CodeBuild 在另一个管道操作中访问它。 CodeBuild 在 DOWNLOAD_SOURCE 阶段失败,并显示以下消息:
CLIENT_ERROR: AccessDenied: Access Denied status code: 403, request id: 123456789, host id: xxxxx/yyyy/zzzz/xxxx= 主要来源和 源版本 arn:aws:s3:::my-bucket/my-pipeline/DeployArti/XcUNqOP
问题很可能是 CloudFormation 在不同帐户中执行时使用与管道本身不同的密钥加密工件。
是否可以为 CloudFormation 提供一个明确的 KMS 密钥来加密工件,或者以任何其他方式访问管道中的这些工件?
在单个帐户中执行时一切正常。
这是我的代码 sn-p(部署在 CI 帐户中):
MyCodeBuild:
Type: AWS::CodeBuild::Project
Properties:
Artifacts:
Type: CODEPIPELINE
Environment: ...
Name: !Sub "my-codebuild"
ServiceRole: !Ref CodeBuildRole
EncryptionKey: !GetAtt KMSKey.Arn
Source:
Type: CODEPIPELINE
BuildSpec: ...
CrossAccountCodePipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
Name: "my-pipeline"
RoleArn: !GetAtt CodePipelineRole.Arn
Stages:
- Name: Source
...
- Name: StagingDev
Actions:
- Name: create-stack-in-DEV-account
InputArtifacts:
- Name: SourceArtifact
OutputArtifacts:
- Name: DeployArtifact
ActionTypeId:
Category: Deploy
Owner: AWS
Version: "1"
Provider: CloudFormation
Configuration:
StackName: "my-dev-stack"
ChangeSetName: !Sub "my-changeset"
ActionMode: CREATE_UPDATE
Capabilities: CAPABILITY_NAMED_IAM
# this is the artifact I want to access from the next action
# within this CI account pipeline
OutputFileName: "my-DEV-output.json"
TemplatePath: !Sub "SourceArtifact::stack/my-stack.yml"
RoleArn: !Sub "arn:aws:iam::${DevAccountId}:role/dev-cloudformation-role"
RoleArn: !Sub "arn:aws:iam::${DevAccountId}:role/dev-cross-account-role"
RunOrder: 1
- Name: process-DEV-outputs
InputArtifacts:
- Name: DeployArtifact
ActionTypeId:
Category: Build
Owner: AWS
Version: "1"
Provider: CodeBuild
Configuration:
ProjectName: !Ref MyCodeBuild
RunOrder: 2
ArtifactStore:
Type: S3
Location: !Ref S3ArtifactBucket
EncryptionKey:
Id: !GetAtt KMSKey.Arn
Type: KMS
【问题讨论】:
标签: amazon-web-services aws-codepipeline aws-codebuild aws-kms multiple-accounts