我在下面的场景中尝试使用 terraform api_gateway 进行 POC。
path= /demo/user(GET) -> 调用 lamda 函数 (hello)。
path= /demo/user/{id)(put) -> 调用 lamda 函数(测试)。
所以我在这里创建了以下资源
resource "aws_api_gateway_rest_api" "MyDemoAPI" {
name = "MyDemoAPI"
description = "This is my API for demonstration purposes"
}
resource "aws_api_gateway_resource" "MyDemoResource" {
rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id
parent_id = aws_api_gateway_rest_api.MyDemoAPI.root_resource_id
path_part = "demo"
}
resource "aws_api_gateway_integration" "MyDemoIntegration" {
rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id
resource_id = aws_api_gateway_resource.MyDemoResource.id
http_method = aws_api_gateway_method.MyDemoMethod.http_method
type = "AWS_PROXY"
uri = "<lambda function arn>/invocation"
}
Run Code Online (Sandbox Code Playgroud)
在 terraform apply 中,它正在 /demo 下创建资源
,但这里如何实现路径?
path= …