Failed to create CDK project in CDK >= 2.73.0
- Dominant language
- Python
- Stars
- 11.1k
- Forks
- 1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 2
Description
## procedure
1. Install libraries.
-> Reference :: https://aws.github.io/chalice/tutorials/cdk.html
```
npm install -g aws-cdk
python3 -m pip install chalice "chalice[cdkv2]"
```
2. chalice new-project
Select `[CDK] REST API with DynamoDB backend`
3. deploy
```
python3 -m pip install -r requirements.txt
cdk deploy
```
## Result
Failed to deploy. Traceback
```
Traceback (most recent call last):
File "/home/USERNAME/ChaliceA4AB/example/jp/sandwich-shop/infrastructure/app.py", line 4, in
from aws_cdk import core as cdk
File "/home/USERNAME/.local/lib/python3.9/site-packages/aws_cdk/core/__init__.py", line 7501, in
class ConstructNode(metaclass=jsii.JSIIMeta, jsii_type="@aws-cdk/core.ConstructNode"):
File "/home/USERNAME/.local/lib/python3.9/site-packages/aws_cdk/core/__init__.py", line 7560, in ConstructNode
runtime_info: typing.Optional[typing.Union[_aws_cdk_cx_api_9a62db47.RuntimeInfo, typing.Dict[builtins.str, typing.Any]]] = None,
AttributeError: module 'aws_cdk.cx_api' has no attribute 'RuntimeInfo'
```
## Reason
CDK v2.72.0 has no package `aws_cdk.core`
https://github.com/aws/aws-cdk/tree/v2.72.0/packages/aws-cdk-lib/core
But CDK v2.73.0 later, package has `aws_cdk.core`
https://github.com/aws/aws-cdk/tree/v2.73.0/packages/aws-cdk-lib/core
Chalice determines the version in this way. But 2.73.0 later, this source does not work correctly.
```
try:
from aws_cdk import core as cdk # As V1
except ImportError:
import aws_cdk as cdk # As V2
```
Contributor guide
Research direction
Start by reproducing the generated project from the AWS CDK tutorial and run cdk deploy with CDK 2.73.0 or later. Inspect infrastructure/app.py and the shown CDK version-detection logic; done means the generated project deploys without the aws_cdk.cx_api.RuntimeInfo traceback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100