Skip to content

Terraform apply fails with error creating Lambda Event Source Mapping #138

@ofhouse

Description

@ofhouse

When setting up a new Next.js app with 0.9.0, the first apply may fail with the following error message:

Error: error creating Lambda Event Source Mapping (arn:aws:sqs:eu-central-1:430654418481:terraform-next-js-existing-cloudfront20210615141542329600000006): InvalidParameterValueException: The provided execution role does not have permissions to call ReceiveMessage on SQS
│ {
│   RespMetadata: {
│     StatusCode: 400,
│     RequestID: "a08ca594-80e3-4db8-8176-dc140f31565a"
│   },
│   Message_: "The provided execution role does not have permissions to call ReceiveMessage on SQS",
│   Type: "User"
│ }
│ 
│   with module.tf_next.module.statics_deploy.module.deploy_trigger.aws_lambda_event_source_mapping.this["sqs_source"],
│   on .terraform/modules/tf_next.statics_deploy.deploy_trigger/main.tf line 211, in resource "aws_lambda_event_source_mapping" "this":
│  211: resource "aws_lambda_event_source_mapping" "this" {

It seems like there is some race condition when the policy for the Lambda is created.

Workaround

You should be able to runterraform apply again and the stack creation would progreed without this error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions