Soru

Zorluk: OrtaAWS CodePipeline

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?

  1. Configure the Deploy action to reference the variable using the syntax `#{SourceVariables.CommitId}` in its configuration parameters.Cevap
  2. B
    Configure the Source action to publish the commit ID to Systems Manager Parameter Store, and have the Deploy action read the value from there.
  3. C
    Update the IAM trust policy of the Deploy action's service role to trust the CodeCommit service, allowing CodeCommit to inject the commit metadata directly.
  4. D
    Place 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

1
Identify the requirement to pass runtime metadata (Commit ID) from an upstream Source stage to a downstream Deploy stage.
The developer needs to utilize AWS CodePipeline's native variable sharing capability.
Native variables are the most efficient way to share dynamic data between pipeline actions without external dependencies.
2
Locate the namespace configured on the upstream action.
The source action namespace is defined as 'SourceVariables'.
Variables are grouped under a namespace to avoid collision and to reference them uniquely.
3
Reference the variable in the downstream action configuration using the syntax: `#{Namespace.VariableName}`.
The dynamic reference is formatted as `#{SourceVariables.CommitId}`.
This is the syntax recognized by CodePipeline to resolve variables at runtime.

Anahtar Kavram

AWS CodePipeline Action Variables and Namespaces
Bu soruyu puanla