amazon-web-services - 将环境变量从 AWS Codepipeline 传递到 CodeBuild

标签 amazon-web-services aws-cloudformation aws-codepipeline aws-codebuild

我在将环境变量从 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/

相关文章:

linux - 如何将 Google Drive 备份到 AWS Glacier?

amazon-web-services - Amazon s3 与 Ec2 存储文件

amazon-web-services - 如何在cloudformation中添加自定义属性?

amazon-web-services - 为什么通过 CloudFormation 创建的 CloudWatch 请求计数警报会产生 "Insufficient Data"?

aws-cloudformation - 如何更新状态为 UPDATE_ROLLBACK_COMPLETE 的 CloudFormation 堆栈?

javascript - 如何使用 AWS CodePipeline 缩小 JS

postgresql - 使用 Zeppelin Spark 2.0 和 Pyspark 连接到 AWS Redshift

amazon-web-services - 在 AWS Cognito 中重新发送 phone_number 属性验证码

amazon-web-services - 如何将 CloudFormation 参数作为类型 : Number? 传递

java - 如何自动将 jar 从 s3 部署到 aws lambda?