Skip to content

[@aws-cdk/aws-events] Unable to use Aws.STACK_NAME as eventBusName when creating EventBus #10467

@knihit

Description

@knihit

When creating a CDK construct in a stack, I am trying to create an EventBus. The eventBusName is a parameter to this construct. I wanted to use the Aws.STACK_NAME as part of the eventBusName, but it seems to be a token issue. I also tried Token.asString(Aws.STACK_NAME). That did not work either. The expectation would be that it would create a 'Ref' assignment to give the name as Cfn Create time.

Reproduction Steps

const bus = new EventBus (scope, 'InferenceEvents', { eventBusName: Aws.STACK_NAME });

OR

const bus = bus = new EventBus (scope, 'InferenceEvents', { eventBusName: Token.asString(Aws.STACK_NAME) });

What did you expect to happen?

The name of the event bus be resolved at Cfn deploy time. With cdk synth, the generated template should have 'Ref' to the stack name

What actually happened?

I got the following error during cdk synth.
'eventBusName' must satisfy: /^[\/\.\-_A-Za-z0-9]{1,256}$/Subprocess exited with error 1

I believe the same thing might happen with CfnParameter if used to assign the value to eventbusname (instead of using Aws.STACK_NAME)

Environment

  • CLI Version : aws-cli/2.0.48 Python/3.8.5 Darwin/19.6.0 source/x86_64
  • Framework Version: CDK 1.63.0
  • Node.js Version: 14.11.0
  • OS : 10.15 (MacOS Catalina)
  • Language (Version): tsc 4.0.3

Other


This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-eventsRelated to CloudWatch EventsbugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions