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

fix(iam): role/group/user's path not included in ARN #13258

Merged
merged 28 commits into from
Apr 13, 2022

Conversation

saltman424
Copy link
Contributor

Solution to #13156


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Feb 24, 2021

@github-actions github-actions bot added the @aws-cdk/aws-iam Related to AWS Identity and Access Management label Feb 24, 2021
@mergify
Copy link
Contributor

mergify bot commented Feb 24, 2021

Title does not follow the guidelines of Conventional Commits. Please adjust title before merge.

@saltman424 saltman424 changed the title @aws-cdk/aws-iam: added path to concrete role/group/user ARN fix(@aws-cdk/aws-iam): added path to concrete role/group/user ARN Feb 24, 2021
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to update tests, and I'm pretty sure the default / would already be included (so now your ARN would look like arn:aws:...:role//rolename

@saltman424
Copy link
Contributor Author

@rix0rrr I have not had a chance to familiarize myself with the repo's testing structure. Do you have specific recommendations on what I should update and where? Also, I got rid of the 'resourceName' argument to avoid the default slash because as I understand it, just using the 'resource' argument shouldn't include any separator. Is this understanding inaccurate?

@rix0rrr
Copy link
Contributor

rix0rrr commented Feb 25, 2021

Do you have specific recommendations on what I should update and where?

There will be role.test.ts, user.test.ts, etc. files in the packages/@aws-cdk/aws-ec2/test directory. That would be a good place to add them.

Now this specific case is somewhat tricky to test, as it only comes into play when objects are being used transparently in a cross-env scenario. So in your unit test, you will need to create an App and two Stacks with different envs, create a Role/Group/User in one stack with a path and use its ARN in the other stack (just create a CfnResource with made-up properties, one of them using the ARN).

Then check that the value you're getting looks like what you expect.

I think there's even 3 cases I'd be interested in:

  • No path supplied
  • Path supplied that does NOT end in a /
  • Path supplied that ends in a /
  • (What if path STARTS with a /...?)

I wonder if IAM does any path normalization, or whether it rejects values with additional /es, or whether it just pastes them right in. We're going to have to mimic IAMs behavior here.

@rix0rrr
Copy link
Contributor

rix0rrr commented Feb 25, 2021

As for what you did with the ARN components:

I liked the original better, where resource = 'role' and resourceName = 'path/to/role'. Seems more logical to me (although it would produce the same string ultimately)

@saltman424
Copy link
Contributor Author

saltman424 commented Feb 25, 2021

@rix0rrr I can work on most of that. I just have one question (below).

Based on the documentation, my understanding was that IAM rejects any path that does not both start and end with a slash, so my implementation expects both. If you want CDK to support all of the cases you mentioned, we probably need to add path normalization in CDK as I believe CloudFormation will still require both. It shouldn't be hard, but do you want me to add that as part of this pull request?

I also did the pure resource implementation because it is slightly simpler when given both a beginning and ending slash, as I don't have to conditionally strip a leading slash from the path. But I can add the logic to allow us to use the resourceName argument if you think that'll be more readable.

With all that being said, I may not be able to get to it immediately. But let me know if you would like me to include path normalization or just add better error handling, and I'll let you know when I have had a chance to make these updates.

@mergify mergify bot dismissed rix0rrr’s stale review February 25, 2021 15:24

Pull request has been modified.

@rix0rrr
Copy link
Contributor

rix0rrr commented Mar 3, 2021

Based on the documentation, my understanding was that IAM rejects any path that does not both start and end with a slash, so my implementation expects both.

Good call. That is fine then. If we want to make that requirement more flexible, that PR would then be the moment to do that.

rix0rrr
rix0rrr previously requested changes Mar 3, 2021
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tests

@mergify mergify bot dismissed rix0rrr’s stale review April 20, 2021 14:55

Pull request has been modified.

@rix0rrr rix0rrr changed the title fix(@aws-cdk/aws-iam): added path to concrete role/group/user ARN fix(iam): role/group/user's path not included in ARN Apr 22, 2021
rix0rrr
rix0rrr previously approved these changes Apr 22, 2021
@mergify
Copy link
Contributor

mergify bot commented Apr 22, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Contributor

mergify bot commented Apr 22, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@kadishmal
Copy link

@saltman424 can you resolve the conflicts? The PR is still pending.

@mergify
Copy link
Contributor

mergify bot commented Nov 24, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@gitpod-io
Copy link

gitpod-io bot commented Dec 14, 2021

@mergify mergify bot dismissed rix0rrr’s stale review December 14, 2021 21:58

Pull request has been modified.

@rix0rrr rix0rrr added bug This issue is a bug. p1 and removed @aws-cdk/aws-iam Related to AWS Identity and Access Management labels Mar 4, 2022
@saltman424
Copy link
Contributor Author

@rix0rrr sorry for taking so long for this. I didn't realize it still wasn't merged. It should be ready for your review.

@mergify
Copy link
Contributor

mergify bot commented Apr 13, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 2d10f6e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit ef2b480 into aws:master Apr 13, 2022
@mergify
Copy link
Contributor

mergify bot commented Apr 13, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

StevePotter pushed a commit to StevePotter/aws-cdk that referenced this pull request Apr 27, 2022
Solution to aws#13156 


----

*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
bug This issue is a bug. p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants