-
Notifications
You must be signed in to change notification settings - Fork 247
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_cdk) Python constructs do not implement a compatible interface #4658
Comments
Our team has also found a smaller example that doesn't work and produces a much more obscure error. Stack contents: vpc: aws_ec2.Vpc = aws_ec2.Vpc(
self,
"Vpc",
max_azs=1,
subnet_configuration=[
aws_ec2.SubnetConfiguration(
name="PublicSubnets",
subnet_type=aws_ec2.SubnetType.PUBLIC,
cidr_mask=26,
),
aws_ec2.SubnetConfiguration(
name="PrivateSubnets",
subnet_type=aws_ec2.SubnetType.PRIVATE_WITH_EGRESS,
cidr_mask=20,
),
],
nat_gateways=1,
restrict_default_security_group=True,
)
aws_ec2.SecurityGroup(
self,
"SecurityGroup",
vpc=vpc,
allow_all_outbound=True,
allow_all_ipv6_outbound=False,
description="This is a test",
) Error:
|
We're running into similar issues with
|
I'm also experiencing this on deploys that were working yesterday before the aws-cdk upgrade. I believe pinning the typeguard version to <3 will fix for now, but would be good to get this resolved. |
Yes, the workaround is to pin |
This seems to be intentional behavior in typeguard >=3 But I don't understand yet why. PEP3102 explicitly allows keyword-only arguments without defaults. |
This check seems to have been added ages ago, so the pre-conditions to trigger this check must have changed |
Check seems to pass with => typeguard 4.3.0 is introducing this issue. |
Seems to be introduced by this commit: agronholm/typeguard@241d120#diff-0ac00416d20efb96e963a903c7c8f8e7a5070064af5b4673ad441c7e3114265eR727 |
We yanked the 10.3.1 release of constructs from PyPI as a quick mitigation for most users. Opened an issue with typeguard to better understand this requirement agronholm/typeguard#495 |
Reverting to and pinning an older version of jsii-pacmak that will generate python bindings with correct dependency constraints for typeguard. Needs to be reverted once aws/jsii#4658 is resolved.
Another example from aws_cdk import App, Stack
from aws_cdk import aws_lambda, aws_s3
from aws_cdk import aws_s3_notifications as s3_notify
app = App()
stack = Stack(app, "bucket-stack")
bucket = aws_s3.Bucket(stack, "Bucket")
bucket.add_event_notification(
event=aws_s3.EventType.OBJECT_CREATED,
dest=s3_notify.LambdaDestination(
aws_lambda.Function.from_function_arn(
stack,
"ObjectCreatedLambda",
"arn:aws:lambda:us-west-2:460106496004:function:ObjectCreatedLambda-qQkkxlUaClaJ",
)
),
)
app.synth() |
Narrows the typeguard dependency constraint down to actually supported versions. [email protected] is incompatible with the currently generated bindings, see #4658 --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
It appears the issue has now been resolved, and I've confirmed this with AWS, who directed me to this solution. We implemented the same workaround yesterday by specifying the Typeguard version. I appreciate everyone who worked on resolving this issue in a timely manner. notes: Failed deployment: Typeguard was downloaded only once: I am not sure why typeguard is installed twice every time aws-cdk-lib is ran but it's how all our release look. |
This might be a quirk of your package manager. Using |
Good suggestion but looks like to me how pip handles the install? |
Yeah, I see the same. I think pip isn't just very clever in resolving dependencies. |
|
This might be resolved in typeguard 4.4.0 |
@mrgrain I just tried with
|
Describe the bug
Similar (old) issue: aws/aws-cdk#15651
aws_ec2.SubnetSelection cannot be initialized from a list of aws_ec2.Subnet's because aws_ec2.ISubnet is not a compatible interface
Fix
We yanked
construct==10.3.1
and releasedconstruct==10.3.2
with correct dependency constraints.Make sure your project is not using
construct==10.3.1
and not usingtypeguard==4.3.0
Workaround
In
requirements.txt
, pin the version of typeguard:Expected Behavior
Passing a list of aws_ec2.Subnet's to an aws_ec2.SubnetSelection can initialize properly
Current Behavior
Error Message:
Reproduction Steps
requirements.txt
requirements-dev.txt
app1/app.py
app2/app.py
Deploy:
Observe the error. I also confirmed that a print statement for
subnet_list
prints['subnet-0b39XXXXXX']
Possible Solution
Not sure
Additional Information/Context
Package Version
attrs 24.2.0
aws-cdk.asset-awscli-v1 2.2.206
aws-cdk.asset-kubectl-v20 2.1.3
aws-cdk.asset-node-proxy-agent-v6 2.1.0
aws-cdk.cloud-assembly-schema 38.0.1
aws-cdk-lib 2.162.0
boto3 1.35.38
botocore 1.35.38
cattrs 23.2.3
constructs 10.3.1
importlib_resources 6.4.5
iniconfig 2.0.0
jmespath 1.0.1
jsii 1.103.1
packaging 24.1
pip 24.0
pluggy 1.5.0
publication 0.0.3
py 1.11.0
pytest 6.2.5
python-dateutil 2.9.0.post0
s3transfer 0.10.3
setuptools 65.5.0
six 1.16.0
toml 0.10.2
typeguard 4.3.0
typing_extensions 4.12.2
urllib3 2.2.3
SDK version used
CDK 2.162.0 (build c8d7dd3), python 3.11, node 18 & 20
Environment details (OS name and version, etc.)
Amazon Linux 2023 & Ubuntu 20.04 on WSL
The text was updated successfully, but these errors were encountered: