-
Notifications
You must be signed in to change notification settings - Fork 51
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
Paginating List Policies requests to retrieve all #298
base: main
Are you sure you want to change the base?
Paginating List Policies requests to retrieve all #298
Conversation
|
Thank you for contributing, @salomax ! Would you be able to sign the CLA and fix the errors flagged by |
Thank you, @salomax ! We've had a number of PRs to close lately, as well as a release that updated the test fixtures. Would you be willing to rebase against the current |
Hi @mrickard I'm more than happy for contributing. |
Thank you, @salomax ! It looks like you'll need to update the layer versions referenced in the test fixtures for this to pass tests. (One of the essential roles of this plugin is to retrieve the latest layer version, so those will change as new layers are released.) You should be able to see the necessary changes by running |
Codecov Report
@@ Coverage Diff @@
## master #298 +/- ##
==========================================
- Coverage 30.03% 29.69% -0.34%
==========================================
Files 4 4
Lines 526 532 +6
Branches 139 139
==========================================
Hits 158 158
- Misses 342 348 +6
Partials 26 26
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I'm coming across the following error message during the deployment:
✖ {"code":"AWS_CLOUD_FORMATION_CREATE_STACK_ALREADY_EXISTS_EXCEPTION","providerError":{"message":"Stack [NewRelicLicenseKeySecret] already exists","code":"AlreadyExistsException","time":"2022-12-06T18:09:28.151Z","requestId":"0b4610b5-5d62-4ceb-bcb1-de502a4e5482","statusCode":400,"retryable":false,"retryDelay":70.36437087742422},"providerErrorCodeExtension":"ALREADY_EXISTS_EXCEPTION"}
I've investigated the error and I found an issue related to fetching AWS policies, in the following line:
serverless-newrelic-lambda-layers/src/integration.ts
Line 97 in dc6a76e
The AWS request returns a truncated list and in case the AWS account has more than 100 policies (our case has 373) hence pagination is needed otherwise, the existing New Relic policy might not be fetched and a new one is going to be created. If it's been created before an AlreadyExistsException is thrown.
For a better understanding of how the pagination works on AWS list policies API request, see: https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListPolicies.html
BTW I'm not a TypeScript developer so feel free to manage it in a proper way.