这是我的代码
# HTTP API
resource "aws_apigatewayv2_api" "api" {
name = local.apigw_name
protocol_type = "HTTP"
target = aws_lambda_function.function.arn
}
resource "aws_apigatewayv2_route" "default_route" {
api_id = aws_apigatewayv2_api.api.id
route_key = "$default"
authorization_type = "AWS_IAM" # <- THE IMPORTANT PART
# modify the integration settings
target = aws_lambda_function.function.arn
}
我收到以下错误消息。我可以通过 AWS 控制台或 AWS CLI 完成这项工作,但不能使用 Terraform。
│ Error: error creating API Gateway v2 route: ConflictException: Route with key $default already exists for this API
│
│ with aws_apigatewayv2_route.default_route,
│ on main.tf line 20, in resource "aws_apigatewayv2_route" "default_route":
│ 20: resource "aws_apigatewayv2_route" "default_route" {