-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Lambda Provisioned Concurrency bug and caveat #11152
Comments
I have some ideas about how I might go about fixing the first problem. I'll see if I can submit a PR in the next few days. To add some additional flavor to the original bug report, the lambda put-provisioned-concurrency docs support the following values for the function name parameter:
The resource is persisted into state via the following invocation: d.SetId(fmt.Sprintf("%s:%s", functionName, qualifier)) The func that parses the id from the state file uses the following code: func resourceAwsLambdaProvisionedConcurrencyConfigParseId(id string) (string, string, error) {
parts := strings.SplitN(id, ":", 2)
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
return "", "", fmt.Errorf("unexpected format of ID (%s), expected FUNCTION_NAME:QUALIFIER", id)
}
return parts[0], parts[1], nil
} For each of the valid function name values noted in the API documentation, the function name, qualifier arn that this method returns are as follows:
In the case of the two latter items in the table, the |
We have simillar problem while using the alias name as documented in terraform here. The provisioned concurrency settings are applied, but TF doesn't move on further on any further updates with the following error (details are modified for security reasons) TF Version: Terraform v0.11.14 Error: Error refreshing state: 1 error occurred: |
Unfortunately, that's the issue you'll receive on state refresh until the issue is closed (there's an associated PR open to resolve it). Essentially, it's splitting the resource id on the colon character into the function argument and qualifier argument. Since an ARN has multiple colons in it, it ends up looking something like If you need a short-term workaround, remove the resource from your state file and re-create using the function name (via the |
Am having the same error, even when using the alias name instead of the ARN as suggested. Here is the information from my state file which depicts the same. "aws_lambda_provisioned_concurrency_config.provisionedConcurrency": { Also, the information/error is deceiving - since my qualifier from statefile doesn't have any : in it, but the error says it is Error: Error refreshing state: 1 error occurred: Let me know if am doing this wrong |
@Gopinath1986 Can you share the original Terraform code used to generate that state file? We tend to see this issue when then As one potential cause, the |
@ericksoen : here is the piece of code that am using. Hope this helps. resource "aws_lambda_function" "function" { vpc_config { tags = "${var.tags}" |
From what I can tell, this One of the issues you may still be encountering is that you have an invalid resource id in your state file and state refreshes happen before evaluating changes. Are you in a position to remove the If that still fails, is it possible to pass |
@ericksoen : Thanks for all your time on this. As suggested, we have removed the current state from the file and re-ran the same scripts (no modifications) and it went through and the subsequent run as well didn't result in error. Am pasting the output from TF, for reference. this output also proves that the Suggestion 2 is already in place and the only workaround is to remove the state and re-run the scripts (let me know if am wrong). An execution plan has been generated and is shown below.
Terraform will perform the following actions:
Plan: 1 to add, 0 to change, 0 to destroy. Do you want to perform these actions? Enter a value: yes |
Should we at least update the Example usage in the documentation in the mean time so that others won't get this error? |
What can be done to get some movement on this issue? It's been open for over a year, has a PR (with tests) against it that hasn't been merged. In the mean time this is the workaround we've used to avoid this:
|
@edeesis : we have upgraded our TF version to 0.12.29 and the provider version to 3.0 and above and are not seeing this issue. |
I'm still experiencing a form of this error (it just says "ValidationException" no detail in the output) with AWS Provider 3.0 and Terraform version v0.14.7 This is the terraform that seemingly causes the error:
It successfully applies, but fails on creating future plans. |
The function_name in the alias definition should be the lambda function name and not the arn. Give it a try function_name = aws_lambda_function.lambda.arn ==> function_name = aws_lambda_function.lambda.function_name |
Yeah, that's exactly what I suggested in this comment: #11152 (comment) But the fact of the matter is both the AWS docs here: https://docs.aws.amazon.com/lambda/latest/dg/API_PutProvisionedConcurrencyConfig.html And the terraform docs here: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_provisioned_concurrency_config Both permit using an arn, so like angelarosario suggested, the docs should be updated or this PR merged. |
I have experienced another problem when using function version method is that somehow Terraform thinks that the function has new published version even though it hasn't and subsequently triggers replacement of lambda provisioned concurrency config. What makes it worse is that the replacement actually attempts to create then destroy - explicitly adding lifecycle here's the terraform output of my apply stage to show the sequence of create and destroy:
|
I'm with you here. I just rebased #11679 off the more recent changes to
|
I encounter a similar problem:
This happens when I use the lambda's
My terraform version: |
Hey everyone 👋 - Problem 1 (failed ID parsing when |
This functionality has been released in v5.4.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
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. |
Community Note
Terraform Version
Terraform v0.12.16
Affected Resource(s)
Terraform Configuration Files
Actual Behavior
I have found two problems with
aws_lambda_provisioned_concurrency_config
.Problem 1
When using a lambda
arn
for the function_name property (it is documented as possible) terraform will fail with this errorIf you use lambda
function_name
it works as expected.Problem 2
Provisioning
provisioned_concurrent_executions
takes a very very long time (more than 3 minutes) to deploy because I think Terraform is waiting for all provisioned concurrency checks to be ok. I think the problem gets worse the more you addprovisioned_concurrent_executions
.Expected Behavior
Problem 1
Should be possible to use
arn
for function_name property as documented.Problem 2
Should add a flag to skip waiting for all
provisioned_concurrent_executions
.Steps to Reproduce
terraform apply
The text was updated successfully, but these errors were encountered: