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

reserved_concurrent_executions option of aws_lambda_function gives error message #3563

Closed
maanenh opened this issue Feb 28, 2018 · 5 comments · Fixed by #3570
Closed

reserved_concurrent_executions option of aws_lambda_function gives error message #3563

maanenh opened this issue Feb 28, 2018 · 5 comments · Fixed by #3570
Labels
bug Addresses a defect in current functionality. service/lambda Issues and PRs that pertain to the lambda service.
Milestone

Comments

@maanenh
Copy link

maanenh commented Feb 28, 2018

The reserved_concurrent_executions option of aws_lambda_function does not work.

Terraform Version

  • Terraform v0.11.3
  • provider.archive v1.0.0
  • provider.aws v1.10.0

Affected Resource(s)

aws_lambda_function

Terraform Configuration Files

data "archive_file" "my_lambda" {
  type = "zip"
  source_file = "./myLambda.js"
  output_path = "myLambda.zip"
}

resource "aws_lambda_function" "my_lambda" {
  filename         = "${data.archive_file.my_lambda.output_path}"
  function_name    = "concurrentLambdaIssue"
  role             = "${var.role_arn}"
  handler          = "myLambda.handler"
  runtime          = "nodejs6.10"
  source_code_hash = "${base64sha256(file("${data.archive_file.my_lambda.output_path}"))}"
  
  reserved_concurrent_executions = 2
}

Debug Output

First execution:

  • aws_lambda_function.my_lambda: Error setting concurrency for Lambda concurrentLambdaIssue: ResourceNotFoundException: An error occurred and the request cannot be processed.
    status code: 404, request id: xx

When you run terraform apply again the messages is:

  • aws_lambda_function.my_lambda: Error creating Lambda function: ResourceConflictException: Function already exist: concurrentLambdaIssue
    status code: 409, request id: xx

Panic Output

n/a

Expected Behavior

Function created with reserved_concurrent_executions set.

Actual Behavior

See error messages.

Steps to Reproduce

  1. terraform apply

Important Factoids

  • On first execution the message is: ResourceNotFoundException. When you execute terraform apply again the messages is: Function already exist.
  • It seems the function is created during the first execution, but the state-files is not updated with this information.
  • When you look with the AWS console, the function is indeed created, but without reserved_concurrent_executions

References

@bflad
Copy link
Contributor

bflad commented Feb 28, 2018

Hi @maanenh 👋 thank you very much for this bug report and sorry you're running into trouble here.

We actually acceptance test this regularly without issue but looks like there could be some latent eventual consistency within the AWS Lambda service. There's two fixes we can apply here to help the situation:

  • Calling d.SetId() before we call PutFunctionConcurrency so any errors returned by that won't prevent Terraform from seeing the existing resource (it'll just show a plan to update the concurrency again if it errored on creation)
  • Retrying for up to a minute on the ResourceNotFound error with PutFunctionConcurrency which should catch eventual consistency issues in most cases

I have a PR ready to go for this, which I'm acceptance testing now!

@bflad bflad added bug Addresses a defect in current functionality. service/lambda Issues and PRs that pertain to the lambda service. labels Feb 28, 2018
@bflad bflad added this to the v1.11.0 milestone Feb 28, 2018
@bflad
Copy link
Contributor

bflad commented Mar 6, 2018

Both the above fixes have been implemented into master and will be released with v1.11.0 of the AWS provider, likely at the end of this week.

@maanenh
Copy link
Author

maanenh commented Mar 6, 2018

Thanks for fixing this issue.

@bflad
Copy link
Contributor

bflad commented Mar 9, 2018

This has been released in version 1.11.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 7, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/lambda Issues and PRs that pertain to the lambda service.
Projects
None yet
2 participants