terraform-aws-modules/terraform-aws-lambda

Provider produced inconsistent final plan: "registry.terraform.io/hashicorp/aws" produced an invalid new value for │ .timeouts: was present, but now absent.

fahadahammed opened this issue · 17 comments

Description

Working version of the infra code suddenly giving error from yesterday showing:

╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for
│ module.aws_lambda.module.the_user_info_function.module.lambda_function.aws_lambda_function.this[0]
│ to include new values learned so far during apply, provider
│ "registry.terraform.io/hashicorp/aws" produced an invalid new value for
│ .timeouts: was present, but now absent.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

Versions

  • Module version [Required]: 5.3.0

  • Terraform version:1.5.3

  • Provider version(s): AWS:5.8.0

Reproduction Code [Required]

module "lambda_function" {
  source = "terraform-aws-modules/lambda/aws"

  function_name   = var.function_name
  description     = var.function_description
  handler         = var.handler
  runtime         = var.runtime
  build_in_docker = true
  publish         = var.publish

  timeout = var.timeout

  source_path = var.source_path

  environment_variables = {
    MASTER_API_TOKEN = var.MASTER_API_TOKEN
  }

  allowed_triggers = {
    APIGatewayAny = {
      service    = "apigateway"
      source_arn = var.api_gateway_arn
    }
  }

  tags = var.tags
}

Could you please provide a reproduction code with values I can run right away? Replace var.... with something valid but what is not working.

@antonbabenko I think the variables are mostly straightforward ones.

module "the_user_info_function" {
    function_name        = "the_user_info_function"
    function_description = "This function is about giving userinfo."
    source = "./functions/the_user_info_function"
    source_path = "./lambda/functions/the_user_info_function/lambda_function.py"

    publish = true
    timeout = 10

    MASTER_API_TOKEN = var.MASTER_API_TOKEN

    api_gateway_arn = var.api_gateway_arn
    api_gateway_execution_arn = var.api_gateway_execution_arn
    
    rest_api_id = var.rest_api_id
    parent_id = var.parent_id

    authorizer_id = var.authorizer_id

    handler = "lambda_function.lambda_handler"
    api_path_part = "user-info"
}

Well, in this example you are using some kind of wrapper module, and it doesn't help much to figure out the root cause of the issue. Please try to reproduce it without the wrapper, first.

dbast commented

Have the same issue.. also terraform 1.5.3 and this simplified code

module "my_function" {
  source = "terraform-aws-modules/lambda/aws"
  version = "5.3.0"

  function_name   = "my_function"
  handler         = "my_function.handler"
  build_in_docker = false
  runtime         = "python3.10"
  source_path = [
    "../my_function/"
  ]
  memory_size = 128
  timeout     = 10

  publish = true
}

The error started to appear from the upgrade of terraform-aws-modules/lambda/aws from v5.2.0 to v5.3.0.

dbast commented

Seems like the cause of this is in 2a59ba2

timeout != timeouts.

dbast commented

So the "was present, but now absent" state issues are explained here

  • Any attribute that had a known value in the planned new state must have an identical value in the new state.
  • Any attribute that had an unknown value in the planned new state must take on a known value of the expected type in the new state. No unknown values are allowed in the new state.

The timeouts values when set to specific values or defaults are shown as planned state during planning (in terraform enterprise):
Screenshot 2023-07-31 at 16 07 28

So the value is planned, but doesn't make it into new state during apply.

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

I am getting this too. What is the solution or workarounds?

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

this is still an issue.