Skip to content

(xray): Invalid template synthesis for X-Ray resources when using Tags.of() #29388

@GavinZZ

Description

@GavinZZ

Describe the bug

When using Tags() methods for aws_xray .CfnGroup class and aws_xray .CfnSamplingRule , the tag's Key and Value values are not passcal-cased.

However, in 2.130.0, when using Tags() method behavior for CfnGroup class and CfnSamplingRule, the tag's are not added.

I find that Tags() methods changed in release 2.131.0 https://github.com/aws/aws-cdk/pull/28989/files

Expected Behavior

cdk synth should run successfully

Current Behavior

cdk synth fails due to

Tags:
        - key: Environment # expected is Key: Environment
          value: Prod # expected is Value: Prod

Reproduction Steps

import { Construct } from 'constructs';
import { aws_xray as xray } from 'aws-cdk-lib';

export class AppStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const xRay = new xray.CfnGroup(this, 'XRayGroup', {
      groupName: 'ECSSample',
      filterExpression: `ok`,
      insightsConfiguration: {
        insightsEnabled: false,
        notificationsEnabled: false,
      },
    });

    new xray.CfnSamplingRule(this, 'ApplicationRule', {
      samplingRule: {
        ruleName: 'app',
        resourceArn: '*',
        priority: 10,
        fixedRate: 0,
        reservoirSize: 10,
        serviceName: '*',
        serviceType: '*',
        host: '*',
        httpMethod: '*',
        urlPath: '*',
        version: 1,
      },
    });

    cdk.Tags.of(this).add("Environment", "Prod");
  }
}

Possible Solution

Use latest type instead of legacy type for this Tags property.

Additional Information/Context

No response

CDK CLI Version

2.131.0

Framework Version

No response

Node.js Version

18

OS

MacOs

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions