newrelic/serverless-newrelic-lambda-layers

Facing a cloudformation error when running servlerless package

lucas-reap-hk opened this issue · 4 comments

{"code":"AWS_CLOUD_FORMATION_CREATE_STACK_ALREADY_EXISTS_EXCEPTION","providerError":{"message":"Stack [NewRelicLicenseKeySecret] already exists","code":"AlreadyExistsException","time":"2023-06-09T02:12:50.121Z","requestId":"23fa696b-90ed-4f9c-bb17-93c9d9beebd3","statusCode":400,"retryable":false,"retryDelay":82.09528233197582},"providerErrorCodeExtension":"ALREADY_EXISTS_EXCEPTION"}

Not sure if this is expected behaviour when running sls package

@lucas-reap-hk Thank you for the report. Does the package operation continue, or does this stop the packaging process?

During a full deployment, we might see this output as a warning if the license key secret has already been created, but it wouldn't stop deployment. I've just checked with a local test project (for which there's already a secret defined in AWS), I don't see this output on either sls deploy or sls package.

What's in the custom: newRelic block of your serverless.yml? (If you're posting it here, please redact any account-specific values.)

Jira CommentId: 213834
Commented by mrickard:

Setting to "blocked"--need more information from the customer.

Looking through the index.ts and integration.ts files, the plugin first checks for the existence of the license key secret (with checkForManagedSecretPolicy), and the plugin attempts to create it if it doesn't exist (with configureLicenseForExtension). If the creation fails because the policy exists, the plugin logs that and should continue. Typically, if the secret already exists, the plugin wouldn't try to create a new one, unless your AWS account doesn't have permissions to check for the existing secret. (If that's the case, this error message would be expected.)