-
Notifications
You must be signed in to change notification settings - Fork 4k
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): RuleTargetInput.fromObject generating invalid template during CDK deploy #31851
Comments
further debugging on my side makes it appear that the culprit for the deployment error is actually the selector under Am doing some further testing to confirm, but this may be another case of playing hide-and-seek with punctuation |
Hi @CrypticCabub , thanks for reaching out. I tried to repro the mentioned scenario. However for me, the comma is not added in both the cases when I do |
I believe the root cause is that "$." is not the correct selector but rather should be just "$". Am still having some problems with permissions not allowing EventBridge to actually write the log to cloudwatch, but deployment isn't failing anymore |
@CrypticCabub ,I am still not able to repro the scenario you mentioned initially but did some observations by tweaking the code - So I tried replacing the
const logGroup = new LogGroup(this, "LogGroup", {});
const eventBus = new EventBus(this, "EventBus", {
description: "example event bus",
});
new Rule(this, "EventBusRule", {
description: "logs all events that get sent to the event bus",
eventBus: eventBus,
targets: [
new CloudWatchLogGroup(logGroup, {
installLatestAwsSdk: false,
retryAttempts: 20,
logEvent: RuleTargetInput.fromObject({
message: `EventBus received ${EventField.fromPath("$.detail-type")} event`,
module: "EventBus",
event: EventField.fromPath("$."),
}),
}),
],
eventPattern: {
source: [{ prefix: "" }] as any[],
},
});
}
const logGroup = new LogGroup(this, "LogGroup", {});
const eventBus = new EventBus(this, "EventBus", {
description: "example event bus",
});
new Rule(this, "EventBusRule", {
description: "logs all events that get sent to the event bus",
eventBus: eventBus,
targets: [
new CloudWatchLogGroup(logGroup, {
installLatestAwsSdk: false,
retryAttempts: 20,
logEvent: RuleTargetInput.fromObject({
message: `EventBus received ${EventField.fromPath("$.detail-type")} event`,
module: "EventBus",
event: EventField.fromPath("$.detail-type"),
}),
}),
],
eventPattern: {
source: [{ prefix: "" }] as any[],
},
});
}
which means the earlier InputTemplate was wrongly generated due to the path mentioned. Deploying the changed code succeeded- AFAIU, the |
yes, I can confirm that the issue appears to have been the |
Comments on closed issues and PRs are hard for our team to see. |
Describe the bug
When using RuleTargetInput.fromObject() with EventField.fromPath fields, CDK generates an invalid InputPathsMap by including a trailing comma in the InputsPathMap.
However, this behavior is not consistent. When running
cdk synth
, the InputsPathMap is generated correctly, but it is not generated correctly when attempting to deploy withcdk deploy
or withTemplate.fromStack()
in snapshot tests. (see examples)Regression Issue
Last Known Working CDK Version
N/A
Expected Behavior
When using RuleTargetInput.fromObject(), I expect a valid InputsPathMap to be generated every time
Current Behavior
Running a snapshot test or cdk deploy produces the following:
whereas running cdk synth produces the following:
The additional comma in the first example makes the stack undeployable and causes the following CloudFormation Error:
Reproduction Steps
cdk app:
snapshot test example:
Possible Solution
Not sure why the use of cdk synth would have a different result than cdk deploy, but the issue is likely a simple off-by-one error on a for loop somewhere.
Additional Information/Context
No response
CDK CLI Version
2.163.0 (build ad5325a)
Framework Version
No response
Node.js Version
18.18.2
OS
Mac
Language
TypeScript
Language Version
5.6.3
Other information
No response
The text was updated successfully, but these errors were encountered: