aws-amplify / aws-amplify/amplify-cli
custom CDK Stack type clash after upgrading aws-cdk-lib version
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
v20.5.0
### Amplify CLI Version
12.2.2
### What operating system are you using?
Mac
### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No
### Describe the bug
Run `amplify add custom` -> AWS CDK
In the generated AWS CDK code, uncomment the example on accessing other Amplify Resources:
```
// Access other Amplify Resources
const retVal:AmplifyDependentResourcesAttributes = AmplifyHelpers.addResourceDependency(this,
amplifyResourceProps.category,
amplifyResourceProps.resourceName,
[
{category: , resourceName: },
]
);
```
Observe that `this` is triggering a compile error:
```
Argument of type 'this' is not assignable to parameter of type 'Stack'.
Property 'toYamlString' is missing in type 'cdkStack' but required in type 'Stack'.ts(2345)
stack.d.ts(328, 5): 'toYamlString' is declared here.
```
### Expected behavior
No compile error when using example code. Ability to access Amplify generated resources in custom CDK code.
### Reproduction steps
Please see steps above
### Project Identifier
_No response_
### Log output
```
# Put your logs below this line
```
### Additional information
_No response_
### Before submitting, please confirm:
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
Contributor guide
Research direction
Reproduce the compile error in the generated AWS CDK custom stack using the example with AmplifyHelpers.addResourceDependency, then inspect the Stack type declarations referenced by the error and the helper's parameter type. Done means the generated example compiles without the type clash and can access Amplify-generated resources.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100