CDK failing to assign tags to resources

I've been attempting to insert a specific Tag into a log group, but it doesn't seem to be getting included. I've double-checked cdk.out and confirmed that it's not listed there, nor has it been added to the actual resource.

      const lg = new LogGroup(this, `${id}-lg`, {
        logGroupName: `/aws/appsync/apis/${this.graphQLApi.attrApiId}`,
        removalPolicy: RemovalPolicy.DESTROY,
      });
      Tags.of(lg).add('test', 'works');

Answer №1

After reaching out to AWS, we discovered that Tags are not compatible with Cloudformation for Log groups, which means they are also not supported by CDK.

Answer №2

It is not guaranteed that all tags are supported in CDK or CloudFormation, as CDK essentially generates CloudFormation templates. Despite the fact that AWS resources themselves may support tagging, CDK is still a relatively new project with frequent updates, making it sometimes challenging to differentiate between intended functionality and minor bugs.

Currently, CloudFormation's AWS::Logs::LogGroup resource lacks tagging support. Although a PR to add tags via CloudFormation was recently merged in May 2021, it has yet to be publicly released. As a result, tagging for this particular resource is not currently supported by CDK/CloudFormation; an update to CDK will likely be required once this feature becomes available in CloudFormation.

To determine tag support, one can apply tags to all resources within a CDK app construct using the CDK aspect. Refer to Tagging. By replacing myConstruct with the entire CDK app construct, all resources in the app will inherit the tag, facilitating easy application of project-wide tags such as project code or environment identifiers.

Tags.of(myConstruct).add('key', 'value');

This process can also be accomplished using core.Tag.add:

# In Python
from aws_cdk import (
    core
)
core.Tag.add(
    scope=app,
    key=key,
    value=value
)

If a CDK-created AWS resource lacks a specific tag, it indicates that CDK does not currently support tagging for that particular resource.

Before spending significant time troubleshooting issues, it's advisable to search through CDK GitHub issues to potentially uncover existing bug reports.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to retrieve the value of bindings in the component controller using Angular 1.5 and Typescript?

In my quest to develop a versatile left-hand menu component that can dynamically display different menu structures based on input strings, I stumbled upon an interesting challenge. By binding a string to the <left-hand-menu-component> element like so ...

Create generic functions that prioritize overloading with the first generic type that is not included in the parameters

I encountered an issue while utilizing generic overload functions, as demonstrated below in the playground. The generic type T1 is solely used in the return type and not the parameters. Therefore, when attempting to use overload #2, I am required to speci ...

Tips for incorporating Material UI Icon v1.0.0-beta.36 into a .tsx component

Currently utilizing material-ui-icons v1.0.0-beta.36. I am endeavoring to incorporate a Search icon within a .tsx component. .tsx component: import React, { Component, ReactElement } from 'react' import Search from 'material-ui-icons/Sear ...

Unlocking the TypeScript UMD global type definition: A step-by-step guide

I have incorporated three@^0.103.0 into my project, along with its own type definitions. Within my project's src/global.d.ts, I have the following: import * as _THREE from 'three' declare global { const THREE: typeof _THREE } Additio ...

Tips on changing the parent's state by sending a function as a prop to its children

I am facing an issue with my parent component A and its child component B. The parent component can have multiple instances of the child component, and I need to process data in the parent component based on changes made in the child component. To achieve ...

The value specified as type '{ value: BigNumber; }' cannot be assigned to the parameter type 'Overrides & { from?: string | Promise<string> | undefined; }'

I am currently working on a smart contract using Solidity (version 0.8.0) at my buildspace project. Below is a snippet of my code written in TypeScript (4.5.x)/JavaScript and Node.js 16.13.x: ... const waveContractFactory = await hre.ethers.getContractFact ...

Utilizing a Chrome profile is ineffective in WebdriverIO

Instead of dealing with signing in every time, I prefer pre-signing in on my profile. Even though I am using the code below, it's still not loading in the specified profile. What can I do to resolve this issue? const browser = await remote({ capabi ...

Strategies for handling a collection of objects with immutability

Using TypeScript, I am trying to manage a list of objects without relying on ngrx and with immutability. As an example, this is how I'm approaching it: let items = <any>[]; let item1 = { n: 'toto' }; // ADD item1 items ...

Exploring the usage of intervalTimer with async and fakeAsync functions

In a particular section of the Angular Testing Guide, it discusses how to test components with asynchronous services, pointing out that: When writing test functions involving done rather than async and fakeAsync, it may be more cumbersome but remains a ...

Easy steps to bring in type definitions from an npm package using Vite

I am currently developing a package with several ts functions that will be utilized by multiple repositories, including mobile and web applications. In our team, we use vite as our primary build tool, which is also integrated into the repository. Below is ...

Can a parent class retrieve an attribute from one of its child classes?

Within my code, I have a parent class where I am creating a function called store-relation and a child class that defines a table in the store. The issue arises when I try to connect the save() function from the parent class to the child's table which ...

What is the timing for the execution of top-level non-export code in TypeScript?

I am currently puzzled about the execution of code in files. Let's say we have a file1.ts with the following content: export interface myInterface {} export function myFunction() {} export const myConst: {} // ... and more exports // top-level non- ...

Utilize NodeJS and Typescript to input data into a postgreSQL database

Here is my code snippet: signup.post('/signup', urlendcodedParser, async(req: Request, res: Response) => { const username = req.body.username; const password = req.body.password; const age = req.body.age; const email = req ...

Alert: Angular has detected that the entry point '@libray-package' includes deep imports into 'module/file'

Recently updated the project to Angular 9.1 and now encountering multiple warnings from the CLI regarding various libraries, such as these: Warning: The entry point '@azure/msal-angular' includes deep imports into 'node_modules/msal/lib-com ...

strictBindCallApply causing issues when working with generic parameters

Take a look at this slightly contrived code snippet: export function evaluate<T>(this: { value: T }) { return this.value; } class SomeClass { value: ''; constructor() { const result = evaluate.call(this); } } You might notice ...

Retrieve the weekday dates for a specific year, month, and relative week number using Javascript or Typescript

I am in need of a custom function called getDaysOfWeekDates that can take a year, a month (ranging from 0 to 11), and the week number of each month (usually 4-5 weeks per month) as parameters, and return a list of dates containing each day of that particul ...

What is the best way to ensure TypeScript recognizes a variable as a specific type throughout the code?

Due to compatibility issues with Internet Explorer, I find myself needing to create a custom Error that must be validated using the constructor. customError instanceof CustomError; // false customError.constructor === CustomError; // true But how can I m ...

The property 'key' is not found within the type 'string | { key: string; element: Element; }'

Why is this error message appearing? The issue states: Property 'key' does not exist on type 'string | { key: string; element: Element; }' It seems to be triggered by the following code: <th key={header?.key ? header.key : header} r ...

Can you pass a generic type as a parameter for another generic in Java?

Simply provide a generic type like a callback: type FUNC<ARG,RET, F> = (arg: ARG) => F<RET>; type PROMISE<T> = Promise<T>; type IDENT<T> = T; type A = FUNC<number, void, IDENT>; type A_PROMISE = FUNC<number, void, ...

"triggering passcode verification with a click of a React

Struggling with a React issue and seeking help. I've been following a tutorial on YouTube, working in CodeSandbox. Whenever I click the button, an error pops up. Can anyone assist me in resolving this? Here is a snippet of my code: Link to my CodeSan ...