Improve IAM role internal handling and resolution#10067
Improve IAM role internal handling and resolution#10067issea1015 wants to merge 30 commits intoserverless:v3from
Conversation
medikoo
left a comment
There was a problem hiding this comment.
Thank you @issea1015, that looks outstanding!
In general it looks very good. I've just proposed some side improvements. Let me know what you think
Codecov Report
@@ Coverage Diff @@
## master #10067 +/- ##
===========================================
- Coverage 85.36% 12.56% -72.81%
===========================================
Files 340 335 -5
Lines 13990 13610 -380
===========================================
- Hits 11943 1710 -10233
- Misses 2047 11900 +9853
Continue to review full report at Codecov.
|
medikoo
left a comment
There was a problem hiding this comment.
Thank you @issea1015 it looks very very good. We're getting close :)
Please see my comments and let me know what you think
|
@medikoo Thank you for all this walking me through! I've just resolved all threads. Could you take a look again? |
medikoo
left a comment
There was a problem hiding this comment.
Thank you @issea1015 that looks really good.
Please see my comments, also it appears one of the tests in CIN started to fail (when run individually), have you checked what could be the case?
|
Thank you for the review. I've resolved every thread except the test one: @medikoo Could you let me know what do you mean by "tests in CIN"? I listed some broken tests in the description of this PR even though I found much more cases when I ran all unit tests. (When I wrote the description of this PR, I've just run the cases under this dir: "test/unit/lib/plugins/aws/package/") Nonetheless, all of them seem related to So again, @medikoo please let me know what do you mean by "tests in CIN" 🙏 |
@issea1015 Sorry typo sneaked in. I meant tests in CI, so in our GitHub Actions setup. We can see that Isolated unit tests fails: https://github.com/serverless/serverless/pull/10067/checks?check_run_id=3872231717 You should be able to easily reproduce it by running just this single failing test file individually |
|
Found how this branch is different from
In this branch, we escape the @medikoo Should I
|
Ok, so if I understand correctly. In new handling, if there's single resource in a policy, we do not wrap it into array for I think it's fine to do that, as this I believe introduces determinism. With this PR, single resource will never be wrapped into array. Concerning tests, it'll be great to refactor it into |
I believe the same. I updated the failing unit test to align with the changes on IAM role internal handling. Let's see if all other tests running in CI pass or not. |
|
For future ref. Other tests in CI are failed for the same reason to above one. Will fix
|
|
I've updated tests-in-CI broken by unwarped Now, in CI, we are facing broken tests that are not based on
|
Yes, that how ideally it should've handled. First those tests should be refactored, and having that, we can confirm in this PR, we do not break anything by accident |
|
@medikoo Is there any estimate on a timeline for getting this finished up, merged and a release out with it? It solves the exact problem we've run into with dynamo stream permissions getting duplicated in the default role. Can someone without prior experience of working on this project (like myself) help get those tests refactored? |
|
@jwsloan in this case we're at the stake of a generous contribution by @issea1015 and ETA is unknown. Still @issea1015 made very impressive progress, and we're leaning towards having that in. |
We will patiently await the release that includes this, then. :) |
|
I've updated the list of broken tests in the PR description. And I've classified the ones that should be handled in this PR and those that should be handled in separate PRs. |


Closes: #8396
Broken Tests:
{ "test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js": [ "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should throw an error if the region is not us-east-1", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should create corresponding resources when cloudFront events are given", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should create different origins for different domains with the same path", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should create different origins for the same domains with the same path but different protocols", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should create different origins with different ids for different domains in the same function", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should use previous created origin for the same params", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should create origins with all values given as an object", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should correctly deep merge arrays with objects", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should throw if more than one cloudfront event with different origins were defined as a default", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should use behavior without PathPattern as a DefaultCacheBehavior", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should create DefaultCacheBehavior if non behavior without PathPattern were defined", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should create DefaultCacheBehavior if non behavior without PathPattern were defined but isDefaultOrigin flag was set", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should throw if non of the cloudfront event with different origins were defined as a default", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should use previous created behavior for the same params and different event types", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should create behavior with all values given as an object", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should throw if more than one behavior with the same PathPattern", "AwsCompileCloudFrontEvents > #compileCloudFrontEvents() > should throw if some of the event type in any behavior is not unique" ], "test/unit/lib/plugins/aws/package/compile/events/kafka.test.js": [ "test/unit/lib/plugins/aws/package/compile/events/kafka.test.js > when there are kafka events defined > should update default IAM role with SecretsManager statement" ], "test/unit/lib/plugins/aws/package/compile/events/msk/index.test.js": [ "AwsCompileMSKEvents > when there are msk events defined > should update default IAM role with MSK statement" ], "test/unit/lib/plugins/aws/package/compile/events/rabbitmq.test.js": [ "test/unit/lib/plugins/aws/package/compile/events/rabbitmq.test.js > when there are rabbitmq events defined > should update default IAM role with DescribeBroker statement", "test/unit/lib/plugins/aws/package/compile/events/rabbitmq.test.js > when there are rabbitmq events defined > should update default IAM role with SecretsManager statement" ], "test/unit/lib/plugins/aws/package/compile/events/sqs.test.js": [ "AwsCompileSQSEvents > #compileSQSEvents() > should remove all non-alphanumerics from queue names for the resource logical ids", "AwsCompileSQSEvents > #compileSQSEvents() > when a queue ARN is given > should create event source mappings when a queue ARN is given", "AwsCompileSQSEvents > #compileSQSEvents() > when a queue ARN is given > should allow specifying SQS Queues as CFN reference types", "AwsCompileSQSEvents > #compileSQSEvents() > when a queue ARN is given > should add the necessary IAM role statements" ], "test/unit/lib/plugins/aws/package/compile/events/stream.test.js": [ "AwsCompileStreamEvents > #compileStreamEvents() > should remove all non-alphanumerics from stream names for the resource logical ids", "AwsCompileStreamEvents > #compileStreamEvents() > when a DynamoDB stream ARN is given > should create event source mappings when a DynamoDB stream ARN is given", "AwsCompileStreamEvents > #compileStreamEvents() > when a DynamoDB stream ARN is given > should allow specifying DynamoDB and Kinesis streams as CFN reference types", "AwsCompileStreamEvents > #compileStreamEvents() > when a DynamoDB stream ARN is given > should allow specifying OnFailure destinations as CFN reference types", "AwsCompileStreamEvents > #compileStreamEvents() > when a DynamoDB stream ARN is given > should add the necessary IAM role statements", "AwsCompileStreamEvents > #compileStreamEvents() > when a Kinesis stream ARN is given > should create event source mappings when a Kinesis stream ARN is given", "AwsCompileStreamEvents > #compileStreamEvents() > when a Kinesis stream ARN is given > should create stream consumer when a Kinesis stream with consumer \"true\" is given", "AwsCompileStreamEvents > #compileStreamEvents() > when a Kinesis stream ARN is given > should add the necessary IAM role statements" ], "test/unit/lib/plugins/aws/package/compile/events/websockets/lib/api.test.js": [ "#compileApi() > should add the websockets policy" ], "test/unit/lib/plugins/aws/package/compile/functions.test.js": [ "AwsCompileFunctions > #compileFunctions() > when using onError config > when IamRoleLambdaExecution is used > should create necessary resources if a SNS arn is provided", "AwsCompileFunctions > #compileFunctions() > when using awsKmsKeyArn config > when IamRoleLambdaExecution is used > should create necessary resources if a KMS key arn is provided", "AwsCompileFunctions > #compileFunctions() > when using tracing config > when IamRoleLambdaExecution is used > should create necessary resources if a tracing config is provided" ] }Broken Tests - Should be handled in this PR:
Broken Tests - Should be handled in separate PRs: