(CfnLambdaHook): (interface TargetFiltersProperty does not match Cfn template specs)
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
This interface makes the `targets` property required. It actually isn't. CloudFormation allows one to use either `targets` or the combination of the other three properties. Right now, it's impossible to actually use the other three properties (`actions`, `invocationPoints`, and `targetNames`) because you can't leave out `targets`, and will get a deploy error if you provide both.
CloudFormation's doc for this data type is inaccurate: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-cloudformation-lambdahook-targetfiltersitems.html
The correct description is shown here: https://docs.aws.amazon.com/cloudformation-cli/latest/hooks-userguide/hooks-target-filtering.html
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
It's possible to use the properties `actions`, `invocationPoints`, and `targetNames` instead of `targets` if desired.
### Current Behavior
Code doesn't compile if `targets` is not provided.
Stack doesn't deploy if both `targets` and the set of [`actions`, `invocationPoints`, `targetNames`] is provided. (That's correct)
### Reproduction Steps
new CfnLambdaHook(stackSet, 'Hook', {
alias: `Renovo::Lambda::${props.hookName}`,
executionRole: hookRole.roleArn,
failureMode: 'FAIL',
hookStatus: 'ENABLED',
lambdaFunction: hookLambda.functionArn,
targetOperations: ['RESOURCE'],
targetFilters: {
actions: ['CREATE'],
invocationPoints: ['PRE_PROVISION'],
targetNames: ['AWS::RDS::DBInstance'],
},
});
Compiler error: `Type '{ actions: string[]; invocationPoints: string[]; targetNames: string[]; }' is not assignable to type 'IResolvable | TargetFiltersProperty | undefined'.
Property 'targets' is missing in type '{ actions: string[]; invocationPoints: string[]; targetNames: string[]; }' but required in type 'TargetFiltersProperty'.ts(2322)`
### Possible Solution
Make `targets` optional.
Possibly provide validation that both `targets` and the set of [`actions`, `invocationPoints`, `targetNames`] is not provided. (Or just let CloudFormation reject it.)
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
aws-cdk-lib@2.199.0
### AWS CDK CLI version
2.1017.0 (build f227c9b)
### Node.js Version
v20.9.0
### OS
Ubuntu 22.04 amd64
### Language
TypeScript
### Language Version
typescript@4.9.5
### Other information
_No response_
Contributor guide
Research direction
Start at the CfnLambdaHook TargetFiltersProperty definition and compare its required fields with the CloudFormation CLI hook target-filtering guide linked in the issue. Reproduce the TypeScript example, then verify that the three alternative properties compile without targets and that providing both forms remains rejected by CloudFormation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100