正如Terraform Resource: 执行 apply 时发生连接错误中所述
我将代码更改为以下内容
provisioner "remote-exec" {
connection {
type = "ssh"
host = aws_eip.nat-eip.public_ip
user = "ubuntu"
private_key = file("/id_rsa.pem")
}
inline = [
"chmod +x /tmp/start_node.sh",
"sudo sed -i -e 's/\r$//' /tmp/start_node.sh", # Remove the spurious CR characters.
"sudo /tmp/start_node.sh",
]
}
Run Code Online (Sandbox Code Playgroud)
但我仍然遇到同样的错误
Error: Invalid function argument
on explorer.tf line 60, in resource "aws_instance" "explorer":
60: private_key = file("/id_rsa.pem")
Invalid value for "path" parameter: no file exists at /id_rsa.pem;
this function works only with files …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 SNS codestar-notifications 为 AWS lambda 创建触发器
。
使用控制台创建触发器时,它会自动添加对 SNS 主题的订阅。
。此外,这也可以在另一个方向上工作,即如果我通过显式添加其 arn 来创建 SNS 作为 Lambda 函数的订阅,它会自动将触发器链接到 Lambda 函数。
但是当使用 terraform 创建订阅时,如下所示:
resource "aws_sns_topic_subscription" "subscribe_lambda_to_first_topic" {
topic_arn = module.first_topic.sns-topic-detail.arn
protocol = "lambda"
endpoint = module.lambda_function.lambda_function.arn
}
Run Code Online (Sandbox Code Playgroud)
它不会在 AWS Lambda 中创建触发器。
我尝试使用 Terraform 中的事件源映射创建触发器,如下所示
resource "aws_lambda_event_source_mapping" "lambda_source" {
event_source_arn = module.first_topic.sns-topic-detail.arn
function_name = module.lambda_function.lambda_function.arn
starting_position = "LATEST"
}
Run Code Online (Sandbox Code Playgroud)
它向我抛出一个错误,说它只能用于
错误:创建 Lambda 事件源映射时出错(arn:aws:sns:us-west-2:619867110810:codestar-notifications-emc-sns-to-lambda):InvalidParameterValueException:无法识别的事件源,必须是 kinesis、dynamodb 流或 sqs 。不支持的源 arn : arn:aws:sns:us-west-2:619867110810:codestar-notifications-emc-sns-to-lambda { RespMetadata: { StatusCode: 400, RequestID: "83bf57cb-b50d-49a8-9547-72fac69778d1" },Message_:“无法识别的事件源,必须是 kinesis、dynamodb 流或 sqs。不支持的源 …
amazon-web-services amazon-sns aws-lambda terraform terraform-provider-aws