Skip to content

Terraform apply with aws_lambda_event_source_mapping does not create the mapping #13662

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

Open
krolique opened this issue Jun 8, 2020 · 6 comments · May be fixed by #42561
Open

Terraform apply with aws_lambda_event_source_mapping does not create the mapping #13662

krolique opened this issue Jun 8, 2020 · 6 comments · May be fixed by #42561
Labels
bug Addresses a defect in current functionality. service/lambda Issues and PRs that pertain to the lambda service.

Comments

@krolique
Copy link

krolique commented Jun 8, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.26

Affected Resource(s)

aws_lambda_function
aws_dynamodb_table
aws_lambda_event_source_mapping

Terraform Configuration Files

provider "aws" {
    region = "us-west-2"
}

terraform {
    required_providers {
        aws = {
            version = "2.53"
        }
        credstash = {
            version = "~> 0.4"
        }
    }
    required_version = ">= 0.12"
    backend "s3" {
        bucket = "s3-prod-terraform-infrastructure"
        key = "terraform-prod.tfstate"
        lock_table = "terraform-infrastructure-state"
        region = "us-west-2"
    }
}

Debug Output

Error: Provider produced inconsistent final plan

When expanding the plan for
aws_lambda_event_source_mapping.dataeng_keystore_dev_kinesis_lambda_mapping to
include new values learned so far during apply, provider
"registry.terraform.io/-/aws" produced an invalid new value for
.event_source_arn: was cty.StringVal(""), but now
cty.StringVal("arn:aws:dynamodb:us-west-2:014157409456:table/dataengineering-keystore-dev/stream/2020-06-08T14:35:09.320").

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

Panic Output

Expected Behavior

Terraform apply should have created a DynamoDB stream, lambda function and mapped the stream events to the lambda function.

Actual Behavior

Terraform apply did not create the aws_lambda_event_source_mapping

Error: Provider produced inconsistent final plan

When expanding the plan for
aws_lambda_event_source_mapping.dataeng_keystore_dev_kinesis_lambda_mapping to
include new values learned so far during apply, provider
"registry.terraform.io/-/aws" produced an invalid new value for
.event_source_arn: was cty.StringVal(""), but now
cty.StringVal("arn:aws:dynamodb:us-west-2:014157409456:table/dataengineering-keystore-dev/stream/2020-06-08T14:35:09.320").

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

Releasing state lock. This may take a few moments...

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jun 8, 2020
@mattfysh
Copy link

mattfysh commented Aug 1, 2020

Ran into this issue just now as well, I believe the current workaround is to manually specify a depends_on

@name-is-manmay
Copy link

A temporary workaround would be:

resource "aws_dynamodb_table" "your_table" {
  name         = "your-table-name"
  billing_mode = "PAY_PER_REQUEST"
  hash_key     = "hash_key_name"
  stream_enabled   = true
  stream_view_type = "NEW_IMAGE"

  attribute {
    name = "attribute_name"
    type = "S"
  }
}


resource "aws_lambda_event_source_mapping" "map_events" {
  event_source_arn  = data.aws_dynamodb_table.your_table_on_aws.stream_arn
  function_name     = aws_lambda_function.your_lambda_function.arn 
  starting_position = "LATEST"
}


data "aws_dynamodb_table" "your_table_on_aws" {
  name = "your-table-name"
  depends_on = [aws_dynamodb_table.your_table]
}

resource "aws_lambda_function" "your_lambda_function" {
    ...
     ...
      ...
}

It worked for me. :)

@nathancahill
Copy link

@mattfysh running in to this issue as well, where are you specifying the depends_on?

@justinretzolk
Copy link
Member

Hi all 👋 Thank you for taking the time to file this and for the additional input. Given that there's been a few Terraform and AWS Provider releases since the last report, is anyone still experiencing this issue?

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 22, 2021
@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 22, 2021
@piekstra
Copy link

piekstra commented Aug 4, 2022

@justinretzolk I'm seeing this issue. Related to #23364 and #650

@RadJaz
Copy link

RadJaz commented May 14, 2025

If anyone is experiencing the issue where updating stream_enabled does not cause terraform to detect a change in stream_arn, updating the AWS provider version to >=4.39.0 should resolve your issue. That particular issue was resolved with #27664.

There is a very similar issue (#42560) where the exact same behavior occurs, except is caused by changing the stream_view_type argument instead of stream_enabled. That bug is resolved by #42561.

It's not entirely clear which of these bugs this issue is specifically referring to, but I've marked #42561 as a PR that would close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/lambda Issues and PRs that pertain to the lambda service.
Projects
None yet
7 participants