amazon-web-services - 如何使用 terraform 在 AWS API 网关中添加 URL 查询字符串参数?

标签 amazon-web-services terraform

我想在API中传递account_id,如下所示https://exampleapi.com/dev?account_id=12345

以下是用于创建 AWS API 网关的 terraform 代码段:

resource "aws_api_gateway_method" "example_api_method" {
  rest_api_id = "${aws_api_gateway_rest_api.example_api.id}"
  resource_id = "${aws_api_gateway_resource.example_api_resource.id}"
  http_method = "GET"
  authorization = "NONE"
 
}

resource "aws_api_gateway_integration" "example_api_method-integration" {
  rest_api_id = "${aws_api_gateway_rest_api.example_api.id}"
  resource_id = "${aws_api_gateway_resource.example_api_resource.id}"
  http_method = "${aws_api_gateway_method.example_api_method.http_method}"
  type = "AWS"
  uri = "arn:aws:apigateway:${var.aws_region}:lambda:path/functions/${var.lambda_arn}/invocations"
  integration_http_method = "GET"
}

最佳答案

    resource "aws_api_gateway_method" "example_api_method" {
      rest_api_id = "${aws_api_gateway_rest_api.example_api.id}"
      resource_id = "${aws_api_gateway_resource.example_api_resource.id}"
      http_method = "GET"
      authorization = "NONE"

      request_parameters = {
        "integration.request.querystring.account_id"=true
      }
    }

有关更多信息,请查看位于 https://www.terraform.io/docs/providers/aws/r/api_gateway_method.html 的 aws_api_gateway_method 资源的 request_parameters 字段。

关于amazon-web-services - 如何使用 terraform 在 AWS API 网关中添加 URL 查询字符串参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44801462/

相关文章:

amazon-web-services - 如何在 hive (AWS Data Pipeline) 中使用 scriptVariables

mysql - 是否可以从 Amazon Aurora 迁移回 Amazon RDS 中的 native MySQL?

objective-c - mac osx 中的亚马逊 s3?

Terraform:您什么时候会手动更改状态?

Terraform - 重构模块 : Error: Provider configuration not present

amazon-web-services - 地形 RDS : Restore data after destroy due to modification?

ruby-on-rails - AWS实例运行时间

amazon-web-services - AWS Cloudformation 遇到不支持的属性类型

amazon-web-services - Aws ecs fargate 可用性区如何工作?

azure - 来自内联虚拟网络资源的子网 ID