Up-to-date reference of API arguments for API Gateway API service you can get at documentation portal
opentelekomcloud_apigw_api_v2¶
Provides an API gateway API resource.
Example Usage¶
variable "vpc_id" {}
variable "subnet_id" {}
variable "secgroup_id" {}
resource "opentelekomcloud_apigw_gateway_v2" "gateway" {
name = "my_gw"
spec_id = "BASIC"
vpc_id = var.vpc_id
subnet_id = var.subnet_id
security_group_id = var.secgroup_id
availability_zones = ["eu-de-01", "eu-de-02"]
description = "test gateway 2"
ingress_bandwidth_size = 5
ingress_bandwidth_charging_mode = "bandwidth"
maintain_begin = "02:00:00"
}
resource "opentelekomcloud_apigw_environment_v2" "env" {
name = "my_env"
instance_id = opentelekomcloud_apigw_gateway_v2.gateway.id
description = "test description"
}
resource "opentelekomcloud_apigw_group_v2" "group" {
name = "my_group"
instance_id = opentelekomcloud_apigw_gateway_v2.gateway.id
description = "test description"
environment {
variable {
name = "test-name"
value = "test-value"
}
environment_id = opentelekomcloud_apigw_environment_v2.env.id
}
}
resource "opentelekomcloud_apigw_api_v2" "api" {
gateway_id = opentelekomcloud_apigw_gateway_v2.gateway.id
group_id = opentelekomcloud_apigw_group_v2.group.id
name = "my_api"
type = "Public"
request_protocol = "HTTP"
request_method = "GET"
request_uri = "/user_info/{user_age}"
security_authentication_type = "APP"
match_mode = "EXACT"
success_response = "Success response"
failure_response = "Failed response"
description = "Created by script"
request_params {
name = "user_age"
type = "NUMBER"
location = "PATH"
required = true
maximum = 200
minimum = 0
}
request_params {
name = "X-TEST-ENUM"
type = "STRING"
location = "HEADER"
maximum = 20
minimum = 10
sample = "ACC_TEST_XXX"
passthrough = true
enumeration = "ACC_TEST_A,ACC_TEST_B"
}
backend_params {
type = "REQUEST"
name = "userAge"
location = "PATH"
value = "user_age"
}
http {
url_domain = "opentelekomcloud.my.com"
request_uri = "/getUserAge/{userAge}"
request_method = "GET"
request_protocol = "HTTP"
timeout = 30000
retry_count = 1
}
http_policy {
url_domain = "opentelekomcloud.my.com"
name = "my_policy1"
request_protocol = "HTTP"
request_method = "GET"
effective_mode = "ANY"
request_uri = "/getUserAge/{userAge}"
timeout = 30000
retry_count = 1
backend_params {
type = "REQUEST"
name = "userAge"
location = "PATH"
value = "user_age"
}
backend_params {
type = "SYSTEM"
name = "%[2]s"
location = "HEADER"
value = "serverName"
system_param_type = "internal"
}
conditions {
origin = "param"
param_name = "user_age"
type = "EXACT"
value = "28"
}
}
}
Argument Reference¶
The following arguments are supported:
region- (Optional, String, ForceNew) Specifies the region where the API is located. If omitted, the provider-level region will be used. Changing this will create a new API resource.gateway_id- (Required, String, ForceNew) Specifies an ID of the APIG dedicated instance to which the API belongs to. Changing this will create a new API resource.group_id- (Required, String) Specifies an ID of the APIG group to which the API belongs to.type- (Required, String) Specifies the API type. The valid values arePublicandPrivate.version- (Optional, String) Specifies the API version.name- (Required, String) Specifies the API name. The valid length is limited from can contain3to255, only Chinese and English letters, digits and following special characters are allowed:-_./(())::、. The name must start with a digit, Chinese or English letter.request_method- (Required, String) Specifies the request method of the API. The valid values areGET,POST,PUT,DELETE,HEAD,PATCH,OPTIONSandANY.request_uri- (Required, String) Specifies the request address, which can contain a maximum of512characters, the request parameters enclosed with brackets ({}).The address can contain special characters, such as asterisks (*), percent signs (%), hyphens (-), and underscores (_) and must comply with URI specifications.
The address can contain environment variables, each starting with a letter and consisting of
3to32characters.
Only letters, digits, hyphens (-), and underscores (_) are allowed in environment variables.
request_protocol- (Required, String) Specifies the request protocol of the API. The valid values areHTTP,HTTPSandBOTH.security_authentication_type- (Optional, String) Specifies the security authentication mode of the API request. The valid values areNONE,APP,IAMandAUTHORIZER, defaults toNONE.security_authentication_enabled- (Optional, Bool) Specifies whether the authentication of the application code is enabled. The application code must located in the header whensecurity_authentication_enabledistrue.authorizer_id- (Optional, String) Specifies the ID of the authorizer to which the API request used. It is Required whensecurity_authentication_typeisAUTHORIZER.body_description- (Optional, String) Specifies the description of the API request body, which can be an example request body, media type or parameters. The request body does not exceed20,480characters.cors- (Optional, Bool) Specifies whether CORS is supported, defaults tofalse.description- (Optional, String) Specifies the API description. The description contains a maximum of255characters and the angle brackets (< and >) are not allowed.match_mode- (Optional, String) Specifies the route matching mode. The valid values areEXACTandPREFIX, defaults toEXACT.success_response- (Optional, String) Specifies the example response for a successful request. The response contains a maximum of20,480characters.failure_response- (Optional, String) Specifies the example response for a failure request. The response contains a maximum of20,480characters.response_id- (Optional, String) Specifies the APIG group response ID.tags- (Optional, List) Tags. Use letters, digits, and special characters(-*#%.:_)and start with a letter. By default,10tags are supported. To increase the quota, contact technical support to modify theAPI_TAG_NUM_LIMITconfiguration.request_params- (Optional, List) Specifies the configurations of the front-end parameters. The object structure is documented below.backend_params- (Optional, List) Specifies the configurations of the backend parameters. The object structure is documented below.mock- (Optional, List, ForceNew) Specifies the mock backend details. The object structure is documented below. Changing this will create a new API resource.func_graph- (Optional, List, ForceNew) Specifies the function graph backend details. The object structure is documented below. Changing this will create a new API resource.http- (Optional, List, ForceNew) Specifies the web backend details. The object structure is documented below. Changing this will create a new API resource.mock_policy- (Optional, List) Specifies the Mock policy backends. The maximum blocks of the policy is 5. The object structure is documented below.func_graph_policy- (Optional, List) Specifies the Mock policy backends. The maximum blocks of the policy is 5. The object structure is documented below.http_policy- (Optional, List) Specifies the example response for a failed request. The maximum blocks of the policy is 5. The object structure is documented below.
The request_params block supports:
name- (Required, String) Specifies the request parameter name. The valid length is limited from can contain1to32, only letters, digits, hyphens (-), underscores (_) and periods (.) are allowed. If Location is specified asHEADERandsecurity_authentication_typeis specified asAPP, the parameter name cannot beAuthorization(case-insensitive) and cannot contain underscores.required- (Optional, Bool) Specifies whether the request parameter is required.passthrough- (Optional, Bool) Specifies whether to transparently transfer the parameter.enumeration- (Optional, String) Specifies the enumerated value(s). Use commas to separate multiple enumeration values, such asVALUE_A,VALUE_B.location- (Optional, String) Specifies the location of the request parameter. The valid values arePATH,QUERYandHEADER, defaults toPATH.type- (Optional, String) Specifies the request parameter type. The valid values areSTRINGandNUMBER, defaults toSTRING.maximum- (Optional, Int) Specifies the maximum value or size of the request parameter.minimum- (Optional, Int) Specifies the minimum value or size of the request parameter.
-> For string type, The maximum and minimum means size. For number type, they means value.
sample- (Optional, String) Specifies the example value of the request parameter. The example contains a maximum of255characters and the angle brackets (< and >) are not allowed.default- (Optional, String) Specifies the default value of the request parameter. The value contains a maximum of255characters and the angle brackets (< and >) are not allowed.description- (Optional, String) Specifies the description of the request parameter. The description contains a maximum of255characters and the angle brackets (< and >) are not allowed.
The backend_params block supports:
type- (Required, String) Specifies the backend parameter type. The valid values areREQUEST,CONSTANTandSYSTEM.name- (Required, String) Specifies the backend parameter name, which contain of 1 to 32 characters and start with a letter. Only letters, digits, hyphens (-), underscores (_) and periods (.) are allowed. The parameter name is not case-sensitive. It cannot start withx-apig-orx-sdk-and cannot bex-stage. If the location is specified asHEADER, the name cannot contain underscores.location- (Required, String) Specifies the location of the backend parameter. The valid values arePATH,QUERYandHEADER.value- (Required, String) Specifies the request parameter name corresponding to the back-end request parameter.description- (Optional, String) Specifies the description of the constant or system parameter. The description contains a maximum of255characters and the angle brackets (< and >) are not allowed.system_param_type- (Optional, String) Specifies the type of the system parameter. The valid values arefrontend,backendandinternal, defaults tointernal.
response- (Required, String) Specifies the response of the backend policy. The description contains a maximum of2,048characters and the angle brackets (< and >) are not allowed.-> NOTE: Mock enables APIG to return a response without sending the request to the backend. This is useful for testing APIs when the backend is not available.
authorizer_id- (Optional, String) Specifies the ID of the backend custom authorization.description- (Optional, String) Specifies the description of the constant or system parameter. The description contains a maximum of255characters and the angle brackets (< and >) are not allowed.version- (Optional, String) Specifies the mock version. It cannot exceed 64 characters.
The func_graph block supports:
function_urn- (Required, String) Specifies the URN of the FunctionGraph function.version- (Required, String) Specifies the function version.timeout- (Optional, Int) Specifies the timeout for API requests to backend service. The valid value is range form1to600,000, defaults to5,000.invocation_type- (Optional, String) Specifies the invocation type. The valid values areasyncandsync, defaults tosync.network_type- (Optional, String) Function network architecture. The valid values areVPCandNON-VPC, defaults toNON-VPC.authorizer_id- (Optional, String) Specifies the ID of the backend custom authorization.description- (Optional, String) Specifies the description of the constant or system parameter. The description contains a maximum of255characters and the angle brackets (< and >) are not allowed.
authorizer_id- (Optional, String) Specifies the ID of the backend custom authorization.url_domain- (Optional, String) Backend service address. A backend service address consists of a domain name or IP address and a port number, with not more than255characters. It must be in the formatHost name:Port number, for example,apig.example.com:7443. If the port number is not specified, the defaultHTTPSport443or the defaultHTTPport80is used.request_protocol- (Optional, String) Specifies the backend request protocol. The valid values areHTTPandHTTPS, defaults toHTTPS.description- (Optional, String) Specifies the description of the constant or system parameter. The description contains a maximum of255characters and the angle brackets (< and >) are not allowed.version- (Required, String) Specifies the function version.request_method- (Optional, String) Specifies the backend request method of the API. The valid values areGET,POST,PUT,DELETE,HEAD,PATCH,OPTIONSandANY.request_uri- (Required, String) Specifies the backend request address, which can contain a maximum of512characters and must comply with URI specifications.The address can contain request parameters enclosed with brackets ({}).
The address can contain special characters, such as asterisks (*), percent signs (%), hyphens (-) and underscores (_) and must comply with URI specifications.
The address can contain environment variables, each starting with a letter and consisting of
3to32characters. Only letters, digits, hyphens (-), and underscores (_) are allowed in environment variables.
timeout- (Optional, Int) Specifies the timeout for API requests to backend service, the unit is ms. The valid value ranges from1to600,000, defaults to5,000.ssl_enable- (Optional, Bool) Specifies whether to enable two-way authentication, defaults to false.retry_count- (Optional, Int) Specifies the number of retry attempts to request the backend service. The valid value ranges from-1to10, defaults to-1.-1indicates that idempotent APIs will retry once and non-idempotent APIs will not retry.POSTandPATCHare not-idempotent.GET,HEAD,PUT,OPTIONSandDELETEare idempotent.-> When the (web) backend uses the channel, the
retry_countmust be less than the number of available backend servers in the channel.vpc_channel_proxy_host- (Optional, String) Specifies the proxy host header. The host header can be customized for requests to be forwarded to cloud servers through the VPC channel. By default, the original host header of the request is used.vpc_channel_id- (Optional, String) Specifies the VPC channel ID. This parameter andurl_domainare alternative.
The mock_policy block supports:
effective_mode- (Optional, String) Specifies the effective mode of the backend policy. The valid values areALLandANY, defaults toANY.response- (Optional, String) Specifies the response of the backend policy. The description contains a maximum of2,048characters and the angle brackets (< and >) are not allowed.name- (Required, String) Specifies the backend policy name. The valid length is limited from can contain3to64, only letters, digits and underscores (_) are allowed.conditions- (Required, List) Specifies an array of one or more policy conditions. Up to five conditions can be set. The object structure is documented below.backend_params- (Optional, List) Specifies an array of one or more backend parameters. The maximum of request parameters is50. The object structure is documented above.authorizer_id- (Optional, String) Specifies the ID of the backend custom authorization.
The func_graph_policy block supports:
function_urn- (Required, String) Specifies the URN of the FunctionGraph function.invocation_mode- (Optional, String) Specifies the invocation mode of the FunctionGraph function. The valid values areasyncandsync, defaults tosync.network_type- (Optional, String) Function network architecture. The valid values areVPCandNON-VPC, defaults toNON-VPC.version- (Optional, String) Specifies the version of the FunctionGraph function.timeout- (Optional, Int) Specifies the timeout for API requests to backend service, the unit isms. The valid value ranges from1to600,000, defaults to5,000.effective_mode- (Optional, String) Specifies the effective mode of the backend policy. The valid values areALLandANY, defaults toANY.name- (Required, String) Specifies the backend policy name. The valid length is limited from can contain3to64, only letters, digits and underscores (_) are allowed.conditions- (Required, List) Specifies an array of one or more policy conditions. Up to five conditions can be set. The object structure is documented below.backend_params- (Optional, List) Specifies the configuration list of the backend parameters. The maximum of request parameters is50. The object structure is documented above.authorizer_id- (Optional, String) Specifies the ID of the backend custom authorization.
The http_policy block supports:
url_domain- (Optional, String) Specifies the backend service address. The value which consists of a domain name or IP address, and a port number, with not more than255characters. The backend service address must be in the format "{host name}:{Port number}", for example,apig.example.com:7443. If the port number is not specified, the default HTTPS port443, or the default HTTP port80is used. The backend service address can contain environment variables, each starting with a letter and consisting of3to32characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.request_protocol- (Optional, String) Specifies the backend request protocol. The valid values areHTTPandHTTPS, defaults toHTTPS.request_method- (Optional, String) Specifies the backend request method of the API. The valid values areGET,POST,PUT,DELETE,HEAD,PATCH,OPTIONSandANY.request_uri- (Required, String) Specifies the backend request address, which can contain a maximum of512characters and must comply with URI specifications.The address can contain request parameters enclosed with brackets ({}).
The address can contain special characters, such as asterisks (*), percent signs (%), hyphens (-) and underscores (_) and must comply with URI specifications.
The address can contain environment variables, each starting with a letter and consisting of
3to32characters. Only letters, digits, hyphens (-), and underscores (_) are allowed in environment variables.
timeout- (Optional, Int) Specifies the timeout, in ms, which allowed for APIGW to request the backend service. The valid value is range from1to600,000, defaults to5,000.retry_count- (Optional, Int) Specifies the number of retry attempts to request the backend service. The valid value ranges from-1to10, defaults to-1.-1indicates that idempotent APIs will retry once and non-idempotent APIs will not retry.POSTandPATCHare not-idempotent.GET,HEAD,PUT,OPTIONSandDELETEare idempotent.-> When the (web) backend uses the channel, the
retry_countmust be less than the number of available backend servers in the channel.effective_mode- (Optional, String) Specifies the effective mode of the backend policy. The valid values areALLandANY, defaults toANY.name- (Required, String) Specifies the backend policy name. The valid length is limited from can contain3to64, only letters, digits and underscores (_) are allowed.backend_params- (Optional, List) Specifies an array of one or more backend parameters. The maximum of request parameters is 50. The object structure is documented above.conditions- (Required, List) Specifies an array of one or more policy conditions. Up to five conditions can be set. The object structure is documented below.vpc_channel_proxy_host- (Optional, String) Specifies the proxy host header. The host header can be customized for requests to be forwarded to cloud servers through the VPC channel. By default, the original host header of the request is used.vpc_channel_id- (Optional, String) Specifies the VPC channel ID. This parameter andurl_domainare alternative.authorizer_id- (Optional, String) Specifies the ID of the backend custom authorization.
The conditions block supports:
param_name- (Optional, String) Specifies the request parameter name. This parameter is required if the policy type isparam. The valid values areuser_ageandX-TEST-ENUM.type- (Optional, String) Specifies the condition type of the backend policy. The valid values areEXACT,ENUMandPATTERN, defaults toEXACT.origin- (Optional, String) Specifies the backend policy type. The valid values areparam,source, defaults tosource.value- (Required, String) Specifies the value of the backend policy. For a condition with the input parameter source:If the condition type is
ENUM, separate condition values with commas.If the condition type is
PATTERN, enter a regular expression compatible with PERL.
For a condition with the Source IP address source, enter IPv4 addresses and separate them with commas. The CIDR address format is supported.
Attribute Reference¶
In addition to all arguments above, the following attributes are exported:
id- The ID of the API.registered_at- Time when the API is registered.updated_at- Time when the API was last modified.
Import¶
API can be imported using the id, e.g.
$ terraform import opentelekomcloud_apigw_api_v2.api "774438a28a574ac8a496325d1bf51807"