alicloud_api_gateway_plugin

更新时间:

Provides a Api Gateway Plugin resource.

For information about Api Gateway Plugin and how to use it, see What is Plugin.

-> NOTE: Available since v1.187.0.

Example Usage

Basic Usage


variable "name" {
  default = "terraform_example"
}

provider "alicloud" {
  region = "cn-hangzhou"
}


resource "alicloud_api_gateway_plugin" "default" {
  description = var.name
  plugin_name = var.name
  plugin_data = jsonencode({
    "routes" : [
      {
        "name" : "Vip",
        "condition" : "$CaAppId = 123456",
        "backend" : {
          "type" : "HTTP-VPC",
          "vpcAccessName" : "slbAccessForVip"
        }
      },
      {
        "name" : "MockForOldClient",
        "condition" : "$ClientVersion < '2.0.5'",
        "backend" : {
          "type" : "MOCK",
          "statusCode" : 400,
          "mockBody" : "This version is not supported!!!"
        }
      },
      {
        "name" : "BlueGreenPercent05",
        "condition" : "1 = 1",
        "backend" : {
          "type" : "HTTP",
          "address" : "https://beta-version.api.foo.com"
        },
        "constant-parameters" : [
          {
            "name" : "x-route-blue-green",
            "location" : "header",
            "value" : "route-blue-green"
          }
        ]
      }
    ]
  })
  plugin_type = "routing"
}

Argument Reference

The following arguments are supported:

  • description - (Optional) The description of the plug-in, which cannot exceed 200 characters.
  • plugin_data - (Required) The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
  • plugin_name - (Required) The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
  • plugin_type - (Required, ForceNew) The type of the plug-in. Valid values:
    • "trafficControl"
    • "ipControl"
    • "backendSignature"
    • "jwtAuth"
    • "basicAuth"
    • "cors"
    • "caching"
    • "routing"
    • "accessControl"
    • "errorMapping"
    • "circuitBreaker"
    • "remoteAuth"
    • "logMask"
    • "transformer".
  • tags - (Optional, Map) The tag of the resource.

Attributes Reference

The following attributes are exported:

  • id - The ID of the resource supplied above.
  • create_time - Create time.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 5 mins) Used when create the Plugin.
  • delete - (Defaults to 5 mins) Used when delete the Plugin.
  • update - (Defaults to 5 mins) Used when update the Plugin.

Import

Api Gateway Plugin can be imported using the id, e.g.

$ terraform import alicloud_api_gateway_plugin.example <id>