我在将环境变量从 AWS Codepipeline 传递到 CodeBuild 时遇到问题。我能找到的关于这个主题的唯一文档是 this AWS documentation它给出了一个基本示例,但正如您在下面看到的,我需要一个导入的子值。所有尝试都会出现错误:属性配置的值必须是具有字符串(或简单类型)属性的对象
。
- 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.
因此它应该是字符串,如图here :
EnvironmentVariables:
!Sub
- '[{"name":"HOSTING_BUCKET","value":"${BucketName}","type":"PLAINTEXT"}]'
- BucketName:
Fn::ImportValue: !Sub "${ProjectName}-website-hosting-bucket"
以上是示例。可能还需要进行一些调整。
关于amazon-web-services - 将环境变量从 AWS Codepipeline 传递到 CodeBuild,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64979651/