A developer is configuring a CI/CD pipeline in AWS CodePipeline. The pipeline consists of a Source stage, a Build stage running AWS CodeBuild, and a Deploy stage running AWS CloudFormation. During the Build stage, CodeBuild executes a script that generates a dynamic configuration token required by the CloudFormation template as a parameter named ConfigToken. The pipeline must support concurrent executions without resource state conflicts, out-of-band credential dependencies, or exposure of sensitive data. Which configuration should the developer implement to pass this dynamic token to the CloudFormation deployment action?
- AWrite the dynamic token to AWS Secrets Manager using an AWS SDK call during the build phase. In the CloudFormation Deploy action, reference the token in the template parameters using the dynamic reference pattern {{resolve:secretsmanager:ConfigToken}}.
- BGenerate a variables.json file containing the token in a subdirectory of the repository during the build. Configure CodePipeline to pass this subdirectory as a secondary input artifact to the Deploy stage, and reference it in the CloudFormation ParameterOverrides using the syntax SecondaryArtifact::variables.json::ConfigToken.
- Define ConfigToken under exported-variables in the env section of the CodeBuild buildspec.yml and assign the value during the build phase. Set a Namespace (e.g., BuildVariables) in the CodePipeline build action, and configure the CloudFormation Deploy action ParameterOverrides using the format {"ConfigToken": "#{BuildVariables.ConfigToken}"}.Cevap
- DConfigure the CodeBuild service role with a trust policy that allows it to assume the CodePipeline service role. During the build phase, execute a script that calls the AWS CLI update-pipeline command to modify the default parameter values of the pipeline's CloudFormation Deploy stage.
Cevap
Define the ConfigToken under exported-variables in the env section of the buildspec.yml, set a Namespace on the CodePipeline build action, and reference it in the CloudFormation ParameterOverrides using the format {"ConfigToken": "#{BuildVariables.ConfigToken}"}.
The correct option is to define ConfigToken under exported-variables in the env section of the CodeBuild buildspec.yml, assign a Namespace to the Build action, and configure the CloudFormation ParameterOverrides using the syntax #{Namespace.Variable}. CodePipeline natively supports variable sharing across actions using execution namespaces. Each execution has its own runtime scope, which ensures that concurrent pipeline runs remain isolated and do not overwrite each other's data.
Adım Adım Çözüm
Anahtar Kavram
AWS CodePipeline variables and namespaces