A developer is configuring a multi-stage release pipeline in AWS CodePipeline. The first stage contains a Source action that retrieves code from an AWS CodeCommit repository, and the developer has assigned the namespace `SourceVariables` to this action. In a downstream Deploy stage, the developer wants to reference the specific commit ID that triggered the pipeline execution to dynamic-tag the deployment resources. Which of the following is the correct method to pass this commit ID variable from the Source stage to the Deploy stage?
- Configure the Deploy action to reference the variable using the syntax `#{SourceVariables.CommitId}` in its configuration parameters.Cevap
- BConfigure the Source action to publish the commit ID to Systems Manager Parameter Store, and have the Deploy action read the value from there.
- CUpdate the IAM trust policy of the Deploy action's service role to trust the CodeCommit service, allowing CodeCommit to inject the commit metadata directly.
- DPlace a buildspec.yml file in the CodeCommit repository root and define the variable under the env/variables section to make it globally available to the Deploy stage.
Cevap
Configure the Deploy action to reference the variable using the syntax `#{SourceVariables.CommitId}` in its configuration parameters.
AWS CodePipeline supports namespaces and variables to share execution-state data between different actions. By setting a namespace (like 'SourceVariables') on an action, any of its output variables, such as 'CommitId', can be referenced in downstream action configurations using the syntax '#{Namespace.VariableName}'. Therefore, configuring the Deploy action with '#{SourceVariables.CommitId}' is the correct method.
Adım Adım Çözüm
Anahtar Kavram
AWS CodePipeline Action Variables and Namespaces