Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-events: eventSourceName does not accept parameters #20718

Closed
keetonian opened this issue Jun 13, 2022 · 3 comments
Closed

aws-events: eventSourceName does not accept parameters #20718

keetonian opened this issue Jun 13, 2022 · 3 comments
Assignees
Labels
@aws-cdk/aws-events Related to CloudWatch Events bug This issue is a bug.

Comments

@keetonian
Copy link
Contributor

keetonian commented Jun 13, 2022

Describe the bug

I am trying to use a parameter for the eventSourceName part of an AWS EventBus resource, but it is failing in validation. I can set up the event bus if I give the string directly, but any method of referencing a parameter in this field fails. I haven't tried doing this in pure CFN, but I assume parameters would work in this field in pure CFN.

Expected Behavior

Code should work and accept parameters for the EventSourceName.

Current Behavior

I get the following validation error:

Error: 'eventSourceName' must satisfy: /^aws\.partner(\/[\.\-_A-Za-z0-9]+){2,}$/

from the following code:

eventSourceName: partnerEventName.valueAsString

Reproduction Steps

Add the following snippet of code to any stack:

    const partnerEventName = new CfnParameter(this, "MongoPartnerEventName", {
      type: "String",
      description: "Event name for Mongo partner event. This can be found on the console after setting up this event in Mongo.",
      default: "aws.partner/mongodb.com/stitch.trigger/123abc"
    })


    const bus = new events.EventBus(this, "mongo-event-bus", {
      eventSourceName: partnerEventName.valueAsString //cdk.Fn.ref("MongoPartnerEventName")
    })

Possible Solution

Fix validation to allow tokens or CFN functions. It looks like this was fixed for EventBusName in #10772 but not for this field.

Additional Information/Context

I'm trying to use parameters so I can deploy this to multiple different environments.

CDK CLI Version

2.23.0

Framework Version

No response

Node.js Version

v17.6.0

OS

OSX

Language

Typescript

Language Version

ts-node 10.7.0

Other information

/Users/keeton/workplace/leland-ops-slack-backend/node_modules/aws-cdk-lib/aws-events/lib/event-bus.ts:275
        throw new Error(
              ^
Error: 'eventSourceName' must satisfy: /^aws\.partner(\/[\.\-_A-Za-z0-9]+){2,}$/
    at Function.eventBusProps (/Users/keeton/workplace/leland-ops-slack-backend/node_modules/aws-cdk-lib/aws-events/lib/event-bus.ts:275:15)
    at new EventBus (/Users/keeton/workplace/leland-ops-slack-backend/node_modules/aws-cdk-lib/aws-events/lib/event-bus.ts:311:56)
    at new LelandOpsSlackBackendStack (/Users/keeton/workplace/leland-ops-slack-backend/lib/leland-ops-slack-backend-stack.ts:35:17)
    at Object.<anonymous> (/Users/keeton/workplace/leland-ops-slack-backend/bin/leland-ops-slack-backend.ts:7:1)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Module.m._compile (/Users/keeton/workplace/leland-ops-slack-backend/node_modules/ts-node/src/index.ts:1597:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/keeton/workplace/leland-ops-slack-backend/node_modules/ts-node/src/index.ts:1600:12)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
@keetonian keetonian added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 13, 2022
@github-actions github-actions bot added the @aws-cdk/aws-events Related to CloudWatch Events label Jun 13, 2022
@keetonian
Copy link
Contributor Author

keetonian commented Jun 13, 2022

As a general question, if my PR gets merged, about how long after that would it be until I can use this from npm/yarn? I need to decide if I can wait on this for a few days or if I need to do something less ideal.

mergify bot pushed a commit that referenced this issue Jun 14, 2022
Addresses #20718 

Adds a check to see if the value is a token before running the validation regex on `eventSourceName`.

Simple fix following a similar fix in #10772

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@peterwoodworth
Copy link
Contributor

We release a new version of CDK usually every week. your fix should be live sometime next week 🙂

Fix has been merged, so i will close this issue.

@peterwoodworth peterwoodworth removed the needs-triage This issue or PR still needs to be triaged. label Jun 16, 2022
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

daschaa pushed a commit to daschaa/aws-cdk that referenced this issue Jul 9, 2022
Addresses aws#20718 

Adds a check to see if the value is a token before running the validation regex on `eventSourceName`.

Simple fix following a similar fix in aws#10772

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-events Related to CloudWatch Events bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants