-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
(Role): Class Role
incorrectly implements interface IRole
(Python) (CDK v2)
#20278
Comments
Can you try |
Unfortunately there's likely not much we will be able to do to help unless you are able to link us a repository which you can clone and consistently reproduce this issue. It's very likely still some mismatched dependency issue - as I'm unable to reproduce it. Can you still reproduce this error in brand new projects on the latest version and cli? |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
I ran into the same issue on OS X with VSCode and pylance. As a workaround I used an assertion to get rid of the error: my_lambda_role = iam.Role(
self,
"MyLambdaRole",
assumed_by=iam.ServicePrincipal("lambda.amazonaws.com"),
)
# HACK: Stop type checkers from complaining about class Role not implementing interface IRole.
# See: https://github.com/aws/aws-cdk/issues/20278
# See: https://github.com/aws/aws-cdk/issues/15150
assert isinstance(my_lambda_role, iam.IRole)
my_lambda_role.add_managed_policy(
iam.ManagedPolicy.from_aws_managed_policy_name(
"service-role/AWSLambdaBasicExecutionRole"
)
)
my_lambda_function = lambda_.DockerImageFunction(
self,
"MyLambdaFunction",
code=lambda_.DockerImageCode.from_image_asset(
directory=str(self.root_directory / "my_lambda"),
follow_symlinks=SymlinkFollowMode.ALWAYS,
),
role=my_lambda_role,
) |
This is still an issue, and it's not only limited to |
Describe the bug
This issue is in reference to this issue and my comment on it.
Error (using
PyLance
):Steps I've taken to mitigate, given feedback above:
npm update
npm i -g aws-cdk
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt -r requirements-dev.txt -c constraints.txt
I'm not sure how the
Pipfile
plays into this, but would appreciate any clarification possible.Expected Behavior
No error to be thrown.
Current Behavior
Error thrown.
Reproduction Steps
Possible Solution
Seems that incompatible dependencies has caused this issue. I have tried to update dependencies, but have not been successful in solving.
Additional Information/Context
No response
CDK CLI Version
2.23.0 (build 50444aa)
Framework Version
2.23.0
Node.js Version
v14.17.4
OS
Mac
Language
Python
Language Version
Python 3.9.6
Other information
No response
The text was updated successfully, but these errors were encountered: