Skip to content
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

Lambda creation fails in version 2.40.0 in LocalStack #11037

Closed
ciaransweet opened this issue Nov 27, 2019 · 4 comments
Closed

Lambda creation fails in version 2.40.0 in LocalStack #11037

ciaransweet opened this issue Nov 27, 2019 · 4 comments
Labels
service/lambda Issues and PRs that pertain to the lambda service.

Comments

@ciaransweet
Copy link

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 "me too" comments, 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 Version = 1.12.6
aws Provider Version = 2.40

Affected Resource(s)

  • aws_lambda_function

Terraform Configuration Files

resource aws_lambda_function find-images {
  function_name = "sentinel-find-images"
  handler = "sentinel-find-images.handler"
  role = ""
  runtime = "python3.6"
  filename = "../../lambda/sentinel-find-images/sentinel-find-images.zip"
  timeout = 900
  memory_size = 3000
  environment {
    variables = {
      STAGE = "TESTING"
    }
  }
}

Debug Output

https://gist.github.com/ciaranevans/de537317f933b98df7af306bb86e2730 For failing run
https://gist.github.com/ciaranevans/0a30164e61ae444198a59fad37c80013 For successful run

Expected Behavior

Terraform finishes deployment with line similar to:

Apply complete! Resources: 24 added, 0 changed, 0 destroyed.

Actual Behavior

All functions failed to deploy (According to Terraform), shown in debug logs above.

However they are actually deployed - my tests that wait for them to be deployed kick off and pass...

Tests are initiated once:

aws lambda list-functions --endpoint-url=http://localhost:4574 | jq '.[] | length'

returns a number == to the number of functions I'm deploying

Steps to Reproduce

  1. Create AWS provider with LocalStack with:
provider aws {
  region                      = "eu-west-2"
  s3_force_path_style         = true
  skip_credentials_validation = true
  skip_metadata_api_check     = true
  skip_requesting_account_id  = true

  endpoints {
    apigateway     = "http://localhost:4567"
    cloudwatchlogs = "http://localhost:4586"
    dynamodb       = "http://localhost:4569"
    iam            = "http://localhost:4593"
    lambda         = "http://localhost:4574"
    s3             = "http://localhost:4572"
    sns            = "http://localhost:4575"
    sqs            = "http://localhost:4576"
    ssm            = "http://localhost:4583"
  }
}
  1. Create a Lambda function resource
  2. terraform apply

Important Factoids

  • Deploying against LocalStack
  • Works with aws provider version 2.39
  • Does not work with aws provider version 2.40

References

@ghost ghost added the service/lambda Issues and PRs that pertain to the lambda service. label Nov 27, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 27, 2019
@ewbankkit
Copy link
Contributor

ewbankkit commented Nov 27, 2019

@CiaranEvans My guess is that this is a LocalStack-specific problem.
The AWS Lambda GetFunctionConfiguration API now returns a State field and the Terraform AWS Provider (as of v2.40.0) uses this field to ensure that the lambda function is created successfully.
A missing value (as in the current LocalStack implementation) results in an empty State value which isn't either the in-progress value (Pending) or success value (Active), triggering the error you experienced.

You can pin the provider version to v2.39.0 until LocalStack support this functionality; I'd suggest opening an issue in their repo and referencing this issue.

@ciaransweet
Copy link
Author

ciaransweet commented Nov 27, 2019

@ewbankkit Great, thanks for taking a look into this!

I did indeed end up pinning the version. Couldn't quite figure out which end of the stick was going wrong!

Letting the LocalStack folks know!

@ciaransweet
Copy link
Author

Fixed in the latest version of LocalStack, tested with version 2.41.0 of the AWS Provider

@ghost
Copy link

ghost commented Mar 28, 2020

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.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
@breathingdust breathingdust removed the needs-triage Waiting for first response or review from a maintainer. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/lambda Issues and PRs that pertain to the lambda service.
Projects
None yet
Development

No branches or pull requests

3 participants