Skip to content
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-iam): role contains invalid characters for service roles #8691

Closed
ThomasSteinbach opened this issue Jun 23, 2020 · 4 comments · Fixed by #8692
Closed

(aws-iam): role contains invalid characters for service roles #8691

ThomasSteinbach opened this issue Jun 23, 2020 · 4 comments · Fixed by #8692
Assignees
Labels
@aws-cdk/aws-iam Related to AWS Identity and Access Management bug This issue is a bug. in-progress This issue is being actively worked on. p2

Comments

@ThomasSteinbach
Copy link
Contributor

I have a service account role - generated by AWS itself - with about following ARN:

ssm_role_arn = "arn:aws:iam::123456789123:role/aws-service-role/ssm.amazonaws.com/AWSServiceRoleForAmazonSSM"

Then

aws_iam.Role.from_role_arn(id, "my_ssm_role", role_arn=ssm_role_arn).role_name

returns aws-service-role/ssm.amazonaws.com/AWSServiceRoleForAmazonSSM but should return just AWSServiceRoleForAmazonSSM instead.

Using the Role from_role_arn leads to errors on deployment, as the role name contains invalid characters like /.


This is 🐛 Bug Report

@ThomasSteinbach ThomasSteinbach added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 23, 2020
@github-actions github-actions bot added the @aws-cdk/aws-iam Related to AWS Identity and Access Management label Jun 23, 2020
ThomasSteinbach added a commit to ThomasSteinbach/aws-cdk that referenced this issue Jun 23, 2020
I am no typescript programmer but I think this change could solve aws#8691
@ThomasSteinbach
Copy link
Contributor Author

I have added a code change #8692 which shows, how the bug could be fixed in my opinion. Note that I am not a typescript developer and the code change is just a proposal. Hopefully ist accelerates the bugfix.

@ThomasSteinbach
Copy link
Contributor Author

Hi @skinny85 , I've seen that you have implemented the original support for service roles. However AWS also known "service linked roles" which have a little different ARN which aws_cdk.aws_iam.Role.fromRoleArn currently can't handle. See the documentation:

https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html

The ARN format is

arn:aws:iam::*:role/aws-service-role/SERVICE-NAME.amazonaws.com/SERVICE-LINKED-ROLE-NAME-PREFIX*

In the cdk synth CloudFormation output CDK writes the whole ARN instead of just the role name, which equals to the SERVICE-LINKED-ROLE-NAME-PREFIX*. The deployment then complains about invalid characters in the role name reference.

I hope I am not too pushy, but could you please have a look, if you could extend your solution for those "service linked roles". That would be very kind, as this is a really blocker for my work with CDK. I am not able to patch this bug locally, as we are using CDK with python and I don't know how to patch, build and package the CDK library on my machine.

I have already made a proposal with #8692

@skinny85
Copy link
Contributor

Replied in the PR 🙂

@SomayaB SomayaB added in-progress This issue is being actively worked on. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 25, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Jul 8, 2020

Don't the docs specifically state that role paths aren't supported?

@rix0rrr rix0rrr added the p2 label Jul 8, 2020
@mergify mergify bot closed this as completed in #8692 Jul 8, 2020
mergify bot pushed a commit that referenced this issue Jul 8, 2020
)

Fixes #8691

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-iam Related to AWS Identity and Access Management bug This issue is a bug. in-progress This issue is being actively worked on. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants