I am trying to get Tags to work in a C# AWS CDK project but I can't seem to get anything to work except for the Depreciated syntax. For example in the following code:
using Amazon.CDK;
using Amazon.CDK.AWS.S3;
namespace HelloCdk
{
public class HelloCdkStack : Stack
{
internal HelloCdkStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
// The code that defines your stack goes here
var g_bucket = new Bucket(this, "GameContent", new BucketProps
{
Versioned = false,
PublicReadAccess = true,
AutoDeleteObjects = true, //delete and
RemovalPolicy = RemovalPolicy.DESTROY, //destroy bucket when CF Stack deleted.
WebsiteIndexDocument = "index.html",
WebsiteErrorDocument = "index.html"
});
Tag.Add(g_bucket, "key", "value");
}
}
}
The above code will succeed when I issue the cdk synth
command. However, I get a warning message that says:
warning CS0618: 'Tag.Add(Construct, string, string, ITagProps?)' is obsolete: 'use "Tags.of(scope).add()"'
But, when I try to use "Tags.of...", the cdk synth
command throws the following error:
error CS1061: 'TagManager' does not contain a definition for 'of' and no accessible extension method 'of'...
What do I need to change to get the recommended tagging approach to work?