Hello @Zareen
Happy to help.
To pass the tags
variable from your YAML pipeline to the CloudFormationCreateOrUpdateStack@1
task, you need to make a few adjustments. Please make the following changes:
Template Parameters Source:
First, ensure that you set the templateParametersSource
to 'inline'
. This allows you to directly specify the template parameters inline within your YAML.
Remove the trailing slash (/
) in the templateParameters
section.
Passing the Tags:
Instead of using $(tags)
, you should reference the tags
variable directly within the templateParameters
section.
Here’s the modified snippet for your task:
task: CloudFormationCreateOrUpdateStack@1
displayName: 'Cloudformation'
inputs:
regionName: ${{ parameters.aws_region }}
stackName: '$(Build.Repository.Name)-task-definition'
templateSource: 'file'
templateFile: './template.yaml'
templateParametersSource: 'inline'
templateParameters: |
{
"ParameterKey": "Name",
"ParameterValue": "$(Build.Repository.Name)",
"Tags": "$(tags)"
}
Make sure to replace Tags
with the appropriate key for tags in your CloudFormation template. Now the tags
variable should be correctly passed to your CloudFormation stack.
if this solves your query, please tag this as answered, so it also helps other community readers who may have similar questions.