0

我正在添加资源aws_lambda_permission以将事件从 S3 发送到 Lambda。但是 Terraform 抱怨以下错误消息。

Error: error waiting for Lambda Function (py-lambda-foo) creation: unexpected state '', wanted target 'Active'. last error: %!s(<nil>)

使用 Terraform:Terraform v0.12.17 provider.aws v2.41.0 Localstack 0.10.5

我能够通过检查此命令来验证功能是否已成功创建

 awslocal lambda list-functions

我看到这个问题,因为 AWS Provider 已经创建了 lambda 函数,但是 localstack 没有返回 provider.aws 所期望的状态。因此,它因此错误而失败。

我打开了 TRACE 日志,我可以看到这些 aws.provider 日志,它正在等待 Lambda 的状态更改为 ACTIVE 并且它一直在 pinglambda/GetFunction

2019-12-07T08:16:24.328Z [DEBUG] plugin.terraform-provider-aws_v2.41.0_x4: 2019/12/07 08:16:24 [DEBUG] Waiting for state to become: [Active]
2019-12-07T08:16:29.336Z [DEBUG] plugin.terraform-provider-aws_v2.41.0_x4: 2019/12/07 08:16:29 [DEBUG] [aws-sdk-go] DEBUG: Request lambda/GetFunction Details:

这是我们收到的 createFunction 响应

{
    "CodeSha256": "xnITd7GQzVtuke7kOR5LP7iprBAmgz5iu15WISiVd0U=",
    "CodeSize": 5503941,
    "Description": "",
    "Environment": {
        "Variables": {
            "foo": "bar"
        }
    },
    "FunctionArn": "arn:aws:lambda:eu-west-1:000000000000:function:py-lambda-foo",
    "FunctionName": "py-lambda-foo",
    "Handler": "app.lambda_handler",
    "LastModified": "2019-12-07T08:16:21.097+0000",
    "MemorySize": 128,
    "RevisionId": "f04d5dad-5e1e-41f0-9c96-387b7ab2313f",
    "Role": "arn:aws:iam::000000000000:role/iam_for_lambda",
    "Runtime": "python3.7",
    "Timeout": 3,
    "TracingConfig": {
        "Mode": "PassThrough"
    },
    "Version": "$LATEST"
}

4

1 回答 1

0

这是 Localstack 与 Terraform 的 AWS 提供程序的兼容性问题。看看这里的问题描述https://github.com/localstack/localstack/issues/1835

最后,Localstack 开发人员通过将状态添加为 ACTIVE 来应用修复https://github.com/localstack/localstack/pull/1838,现在这已被 Terraform 的 aws-provider 获取。

于 2019-12-07T17:57:06.980 回答