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

Get "ResourceConflictException" after opt-in AWS lambda states update #415

Closed
rayandben2000 opened this issue Oct 21, 2021 · 13 comments · Fixed by #423
Closed

Get "ResourceConflictException" after opt-in AWS lambda states update #415

rayandben2000 opened this issue Oct 21, 2021 · 13 comments · Fixed by #423

Comments

@rayandben2000
Copy link

I'm submitting a...


[x] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request 
[ ] Other... Please describe: 

Expected Behavior

It should deploy lambda successfully when I opt-in AWS lambda states update.

Current Behavior

I follow the Coming soon: Expansion of AWS Lambda states to all functions to add aws:states:opt-in in function’s description. Running ask deploy will failed and get error message:

[Error]: CliError: The lambda deploy failed for Alexa region "default": ResourceConflictException: The operation cannot be performed at this time. An update is in progress for resource: arn:aws:lambda:${my function id}

If I remove aws:states:opt-in in function’s description, it can deploy normally.

Your Environment and Context

  • ask-cli version: 2.24.1
  • Operating System and version:
  • Node.js version used for development: v15.12.0
  • Yarn version used for development: 1.21.1
@jsetton
Copy link
Contributor

jsetton commented Oct 25, 2021

@RonWang I can confirm this issue which affects the lambda-deployer workflow. From what I can see, the CLI is currently expecting the Lambda function creation and update process to be blocking as it has been until this change. A wait for the proper State and LastUpdateStatus function properties before continuing the Lambda deployment process needs to be added.

In all, the lambda-deployer workflow will be broken once the general update phase for this change is completed, which is currently stated for December 6th.

@Xyon75
Copy link

Xyon75 commented Nov 18, 2021

I'm having this issue since this morning deploying in the eu-west-1 region.
Is there any way to fix this before Dec 6th?

@tmsoft
Copy link

tmsoft commented Nov 19, 2021

Set the function description to "aws:states:opt-out" to deploy again.

@mhaddy
Copy link

mhaddy commented Nov 26, 2021

Any update here? I'm using the lambda-deployer and unless I add aws:states:opt-out to my Lambda description, I'm unable to deploy. aws:states:opt-in and having it both result in the same error noted above. As of 12/6, my workflows will be blocked.

@arctouch-pedrocosta
Copy link

Any updates? I'm also experiencing the same problem as other engineers here. My workflow will be blocked as of 12/6 and this is the main SDK to deploy Alexa Skills with lambda functions.

@sam-goodwin
Copy link

Looks like it's a problem with how we use revision id when updating lambda function. Tracing that code:

CLI will load the Lambda Function information from AWS and store it in deployState

currentRegionDeployState.lambda = lambdaData.lambda;

Then, when updating the Lambda, the revisionId is extracted from that object:

let { revisionId } = deployState.lambda;

And then uses it when updating the Function:

let { revisionId } = deployState.lambda;
lambdaClient.updateFunctionCode(zipFile, functionName, revisionId, (codeErr, codeData) => {
if (codeErr) {
return callback(codeErr);
}
reporter.updateStatus(`Update a lambda function (${functionName}) in progress...`);
const { runtime } = userConfig;
const { handler } = userConfig;
revisionId = codeData.RevisionId;
lambdaClient.updateFunctionConfiguration(functionName, runtime, handler, revisionId, (configErr, configData) => {

It calls UpdateFunctionConfiguration afterwards but it uses the latest RevisionId:

revisionId = codeData.RevisionId;

From the conversation here, this seems to be related to AWS Lambda States. Reading the docs: https://docs.aws.amazon.com/lambda/latest/dg/functions-states.html

The following operations fail while function creation is pending:

  • Invoke
  • UpdateFunctionCode
  • UpdateFunctionConfiguration
  • PublishVersion

I think the fix is to wait until the state changes before calling UpdateFunctionConfiguration.

@sam-goodwin
Copy link

Hey all, sorry for the delay on this. I've put together a PR for what I think should fix this issue. Still need to test but would also like some feedback on the desired behavior: #422

@sam-goodwin
Copy link

I will test this once I get back in to the office. Until then, feel free to check out #422 and run the following commands to install it as your CLI

npm install
npm run prepublishOnly
npm pack
npm install -g ./ask-cli-2.24.1.tgz

@arctouch-pedrocosta
Copy link

Hi @sam-goodwin, thank you for the update on this issue, I will be watching your PR, based on the latest comments sounds like I should wait to update to the newer version, will keep an eye out.

@jsetton
Copy link
Contributor

jsetton commented Dec 7, 2021

If anyone want to test the PR I submitted above, you can install it using the command below:

npm install -g jsetton/ask-cli#lambda-state-update-fix

@arctouch-pedrocosta
Copy link

Hi @jsetton my tests were successful with your branch, I was able to deploy latest code changes to my lambda function code to AWS without issues. It's looking good on my end. My understanding is that your code still have to finish going through review before a new release can be rolled out correct?

@arctouch-pedrocosta
Copy link

Really appreciate your work so far @jsetton !

@jsetton
Copy link
Contributor

jsetton commented Dec 8, 2021

My understanding is that your code still have to finish going through review before a new release can be rolled out correct?

This is correct but you can use the version I submitted in the meantime. Since ask-cli checks for the latest available official release each time you run the tool, you will be notified when to switch back to the official one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants