- Newest
- Most votes
- Most comments
Hi,
You could use describeStacks api: https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_DescribeStacks.html.
Its Stack response object (https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_Stack.html) contains a list of tags.
Hope it is an acceptable answer ;)
in addition to @alatech
yes ou can use the describeStacks API to retrieve information about your CloudFormation stack, including the tags associated with it
and as an example code
const { CloudFormationClient, DescribeStacksCommand } = require('@aws-sdk/client-cloudformation');
(async () => {
const stackName = 'your-stack-name';
// Create a CloudFormation client
const cloudFormation = new CloudFormationClient({ region: 'us-west-2' });
try {
// Call describeStacks to get stack information
const response = await cloudFormation.send(
new DescribeStacksCommand({
StackName: stackName,
})
);
// Extract stack information
const stack = response.Stacks[0];
const tags = stack.Tags;
console.log(`Tags for stack ${stackName}:`, tags);
} catch (error) {
console.error('Error retrieving stack tags:', error);
}
})();
https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cloudformation/classes/describestackscommand.html https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cloudformation/index.html
Thanks for your response !!
I assume Tags can be extracted the same way for stacks obtained from ListStacksOutput as well.
Relevant content
- Accepted Answerasked a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 4 months ago
I think so. That api returns a stack summary, which will return stack name among other info. You can then call describeStacks using the name as parameter, same as described above