【发布时间】:2020-11-20 03:27:17
【问题描述】:
我的问题: Codepipeline 如何读取 SourceCodeArtifact 中的 json 文件中的字段值?
我有一个 Gthub 存储库,其中包含一个文件 imageManifest.json,如下所示:
{
"image_id": "docker.pkg.github.com/my-org/my-repo/my-app",
"image_version": "1.0.1"
}
我希望我的 AWS Codepipeline Source 阶段能够从 imageManifest.json 读取 image_version 的值,并将其作为参数传递给管道后续阶段中的 CloudFormation 操作。
供参考,这是我的源阶段。
Stages:
- Name: GitHubSource
Actions:
- Name: SourceAction
ActionTypeId:
Category: Source
Owner: ThirdParty
Version: '1'
Provider: GitHub
OutputArtifacts:
- Name: SourceCodeArtifact
Configuration:
Owner: !Ref GitHubOwner
Repo: !Ref GitHubRepo
OAuthToken: !Ref GitHubAuthToken
这是我的部署阶段:
- Name: DevQA
Actions:
- Name: DeployInfrastructure
InputArtifacts:
- Name: SourceCodeArtifact
ActionTypeId:
Category: Deploy
Owner: AWS
Provider: CloudFormation
Version: '1'
Configuration:
StackName: !Ref AppName
Capabilities: CAPABILITY_NAMED_IAM
RoleArn: !GetAtt [CloudFormationRole, Arn]
ParameterOverrides: !Sub '{"ImageId": "${image_version??}"}'
请注意,上面最后一行中的image_version 只是我的理想占位符,以说明我希望如何使用image_version json 值。
Codepipeline 如何读取 SourceCodeArtifact 中的 json 文件中的字段值?
阶梯函数?拉姆达?代码构建?
【问题讨论】:
标签: aws-lambda amazon-cloudformation aws-codepipeline aws-step-functions