I'm using the AWS JavaScript SDK v3 CloudFormation client to get a list of stacks.
Now I want to get any tags associated with each stack. But I see no way to do it!
Tried looking through docs... expecting something like what they have for aws-sdk/client-mgn
import { MgnClient, ListTagsForResourceCommand } from "@aws-sdk/client-mgn"; // ES Modules import
// const { MgnClient, ListTagsForResourceCommand } = require("@aws-sdk/client-mgn"); // CommonJS import
const client = new MgnClient(config);
const input = { // ListTagsForResourceRequest
resourceArn: "STRING_VALUE", // required
};
const command = new ListTagsForResourceCommand(input);
const response = await client.send(command);
// { // ListTagsForResourceResponse
// tags: { // TagsMap
// "<keys>": "STRING_VALUE",
// },
// };
You can send a DescribeStacksCommand for the given stack.
The DescribeStacksOutput response contains an array of Stack objects, each of which contains an array of Tag objects. For example:
const command = new DescribeStacksCommand(input);
const response = await client.send(command);
The DescribeStacksOutput response object will look like this:
{
Stacks: [
{
StackId: "STRING_VALUE",
StackName: "STRING_VALUE",
Description: "STRING_VALUE",
...
Tags: [
{
Key: "STRING_VALUE",
Value: "STRING_VALUE",
},
],
},
],
NextToken: "STRING_VALUE",
};