我正在添加资源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 本地堆栈0.10.5
我能够验证是否已成功创建函数 通过检查此命令
awslocal lambda list-functions
我看到了这个问题,因为AWS Provider已创建了lambda函数,但是,本地堆栈未返回状态,这是provider.aws可以正常使用的状态。因此,它因此错误而失败。
我打开了TRACE日志,可以看到这些aws.provider日志,它正在等待Lambda的状态更改为ACTIVE,并且它一直在ping lambda/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"
}
答案 0 :(得分:0)
这是与Terraform的AWS Provider的Localstack兼容性的问题。在https://github.com/localstack/localstack/issues/1835
处查看问题描述最后,Localstack开发人员通过将state添加为ACTIVE来应用了修订https://github.com/localstack/localstack/pull/1838,现在,它已被Terraform的aws提供者所采用。