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

Add validator to check consistency of resource name used for IamResource #1819

Merged
merged 11 commits into from
Jun 20, 2023

Conversation

hpmellema
Copy link
Contributor

@hpmellema hpmellema commented Jun 13, 2023

Background

The IamResource trait indicates properties of a Smithy resource in AWS IAM. If no name parameter is provided to the IamResource trait then a shape's IamResource name is assumed to just be the resource's name, otherwise the name parameter is used.

The name of an IamResource is expected to match the name of the resource in the resource's ARN. For examples if the resource has an arn trait of @arn(template: "my-shape") then the IamResource name should be "my-shape" for that resource.

Description of changes:

  • Adds new validator and associated unit tests to check that the name specified for the IamResource trait is consistent with the resource name in the resource's ARN template

Note: This validator throws a DANGER event instead of an ERROR so that the validation event can be suppressed if needed for backwards compatibility.

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

@hpmellema hpmellema marked this pull request as ready for review June 13, 2023 18:08
@hpmellema hpmellema requested a review from a team as a code owner June 13, 2023 18:08
@hpmellema hpmellema requested a review from mtdowling June 20, 2023 16:43
@hpmellema hpmellema merged commit 436942e into smithy-lang:main Jun 20, 2023
@hpmellema hpmellema deleted the validate-iam-resource branch June 20, 2023 18:14
jvschneid added a commit to jvschneid/smithy that referenced this pull request Jun 22, 2023
jvschneid added a commit that referenced this pull request Jun 22, 2023
syall pushed a commit to Xtansia/smithy that referenced this pull request Aug 11, 2023
…rce (smithy-lang#1819)

* Add validator to check consistency of resource name used for IamResource

* Update arn parsing method to be private

* Update smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java

Co-authored-by: Michael Dowling <[email protected]>

* Update smithy-aws-iam-traits/src/main/java/software/amazon/smithy/aws/iam/traits/IamResourceTraitValidator.java

Co-authored-by: Michael Dowling <[email protected]>

* Address PR comments

* Add errorfiles test runner

* Revert "Address PR comments"

This reverts commit 3753ac2.

* Re-add changes without accidentally popped stashed changes

* Update to use orElseGet

* Re-add change that was accidentally removed

* Add newline at end of file

---------

Co-authored-by: Michael Dowling <[email protected]>
syall pushed a commit to Xtansia/smithy that referenced this pull request Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants