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

Paginating List Policies requests to retrieve all #298

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

salomax
Copy link

@salomax salomax commented Dec 6, 2022

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:

const results = await this.awsProvider.request(

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.

@CLAassistant
Copy link

CLAassistant commented Dec 6, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@mrickard
Copy link
Member

mrickard commented Dec 6, 2022

Thank you for contributing, @salomax ! Would you be able to sign the CLA and fix the errors flagged by npm run lint?

@mrickard
Copy link
Member

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 master branch?

@salomax
Copy link
Author

salomax commented Jan 13, 2023

Hi @mrickard I'm more than happy for contributing.
I rebased the branch against master and it seems that's already up-to-date.
Let me know if I have to do something else.

@mrickard
Copy link
Member

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 npm run test on your local machine, and globally replacing the outdated versions with the latest.

@codecov
Copy link

codecov bot commented Jan 20, 2023

Codecov Report

Merging #298 (a4ff1b9) into master (dc6a76e) will decrease coverage by 0.34%.
The diff coverage is 0.00%.

@@            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              
Flag Coverage Δ
unit-tests 29.69% <0.00%> (-0.34%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/integration.ts 3.60% <0.00%> (-0.21%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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