将环境变量从 AWS Codepipeline 传递到 CodeBuild
Passing EnvironmentVariables from AWS Codepipeline to CodeBuild
我在将 EnvironmentVariables 从 AWS Codepipeline 传递到 CodeBuild 时遇到问题。我能找到的关于这个主题的唯一文档是 this AWS documentation,它给出了一个基本示例,但正如您在下面看到的,我需要一个导入的子值。所有尝试都给我错误:Value of property Configuration must be an object with String (or simple type) properties
.
- Name: EmptyHostingBucket
Actions:
- Name: EmptyHostingBucket
RunOrder: 5
ActionTypeId:
Category: Build
Owner: AWS
Provider: CodeBuild
Version: 1
Configuration:
ProjectName: !Ref CodeBuildEmptyBucket
EnvironmentVariables:
- Name: HOSTING_BUCKET
Value:
Fn::ImportValue: !Sub "${ProjectName}-website-hosting-bucket"
InputArtifacts:
- Name: SourceArtifacts
OutputArtifacts:
- Name: BuildEmptyBucket
这可能是因为:
The value for the EnvironmentVariables parameter takes the form of a JSON array of environment variable objects.
所以应该是string,如图here:
EnvironmentVariables:
!Sub
- '[{"name":"HOSTING_BUCKET","value":"${BucketName}","type":"PLAINTEXT"}]'
- BucketName:
Fn::ImportValue: !Sub "${ProjectName}-website-hosting-bucket"
以上为示例。可能还需要做一些调整。
我在将 EnvironmentVariables 从 AWS Codepipeline 传递到 CodeBuild 时遇到问题。我能找到的关于这个主题的唯一文档是 this AWS documentation,它给出了一个基本示例,但正如您在下面看到的,我需要一个导入的子值。所有尝试都给我错误:Value of property Configuration must be an object with String (or simple type) properties
.
- Name: EmptyHostingBucket
Actions:
- Name: EmptyHostingBucket
RunOrder: 5
ActionTypeId:
Category: Build
Owner: AWS
Provider: CodeBuild
Version: 1
Configuration:
ProjectName: !Ref CodeBuildEmptyBucket
EnvironmentVariables:
- Name: HOSTING_BUCKET
Value:
Fn::ImportValue: !Sub "${ProjectName}-website-hosting-bucket"
InputArtifacts:
- Name: SourceArtifacts
OutputArtifacts:
- Name: BuildEmptyBucket
这可能是因为:
The value for the EnvironmentVariables parameter takes the form of a JSON array of environment variable objects.
所以应该是string,如图here:
EnvironmentVariables:
!Sub
- '[{"name":"HOSTING_BUCKET","value":"${BucketName}","type":"PLAINTEXT"}]'
- BucketName:
Fn::ImportValue: !Sub "${ProjectName}-website-hosting-bucket"
以上为示例。可能还需要做一些调整。