Terraform-provider-aws: race condition on published version from aws_lambda_function and aws_lambda_provisioned_concurrency_config

Created on 21 Feb 2020  路  8Comments  路  Source: hashicorp/terraform-provider-aws

SUMMARY

When provisioning aws_lambda_function and attaching aws_lambda_provisioned_concurrency_config on initial provision the aws_lambda_provisioned_concurrency_config expects a published version, this is not done in time for aws_lambda_provisioned_concurrency_config to recognize the published version.

Expected results

When provisioning a new aws_lambda_function it publishes a new version attaches to an alias and successfully provisions

What actually happens:

* aws_lambda_provisioned_concurrency_config.lambda_concurrency_config: error putting Lambda Provisioned Concurrency Config (NAME): InvalidParameterValueException: Provisioned Concurrency Configs cannot be applied to unpublished function versions. { Message_: "Provisioned Concurrency Configs cannot be applied to unpublished function versions.", Type: "User" }

POTENTIAL FIX

When aws Lambda provisions make it so that publish = true is required before aws_lambda_provisioned_concurrency_config can be provisioned

needs-triage serviclambda

Most helpful comment

+1

All 8 comments

+1

Any movement here?

I am experiencing this issue as well.

experiencing the issue too

I am experiencing same issue.

This seems to be a problem not just for the first execution. I have all deployed but now want to ad the concurrency config.

resource "aws_lambda_alias" "deliver" {
  name             = "deliver"
  function_name    = aws_lambda_function.deliver.arn
  function_version = "$LATEST"
}

resource "aws_lambda_provisioned_concurrency_config" "deliver" {
  function_name                     = aws_lambda_alias.deliver.function_name
  qualifier                         = aws_lambda_alias.deliver.name
  provisioned_concurrent_executions = 1
}

and also get

aws_lambda_alias.deliver: Creating...
aws_lambda_alias.deliver: Creation complete after 1s [id=xx]
aws_lambda_provisioned_concurrency_config.deliver: Creating...

Error: error putting Lambda Provisioned Concurrency Config (xx): InvalidParameterValueException: Provisioned Concurrency Configs cannot be applied to unpublished function versions.
{
  RespMetadata: {
    StatusCode: 400,
    RequestID: "xx"
  },
  Message_: "Provisioned Concurrency Configs cannot be applied to unpublished function versions.",
  Type: "User"
}

I also tried

resource "aws_lambda_provisioned_concurrency_config" "deliver" {
  function_name                     = aws_lambda_function.deliver.function_name
  qualifier                         = aws_lambda_function.deliver.version
  provisioned_concurrent_executions = 1
}

but it seems the problem is $LATEST.
I don't understand why a concurrency configuration needs a dedicated version though.

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lambda_function#qualifier suggests aws_lambda_function allows for a qualifier but with

% terraform -v   
Terraform v0.13.3
+ provider registry.terraform.io/hashicorp/archive v1.3.0
+ provider registry.terraform.io/hashicorp/aws v3.8.0

I am getting

Error: Unsupported argument

  on foo.tf line 18, in resource "aws_lambda_function" "deliver":
  18:   qualifier = "$LATEST"

An argument named "qualifier" is not expected here.
Was this page helpful?
0 / 5 - 0 ratings