Alicloud ApiGateway Terraform Module terraform-alicloud-api-gateway
This Terraform module will first creates a Apigateway Api Group , then create an Apigateway Api basing on this group.
These types of resources are supported:
You can use this in your terraform template with the following steps.
-
Adding a module resource to your template, e.g. main.tf
module "apigateway" { source = "terraform-alicloud-modules/api-gateway/alicloud" # ApiGateway api group variables api_group_name = "TerraformApiGatewayGroup" api_group_description = "Module of APi gateway Group" # ApiGateway api variables api_name = "TerraformApiGatewayApi" api_description = "description" api_auth_type = "APP" api_request_config = [ { protocol = "HTTP" method = "GET" path = "/test/path1" mode = "MAPPING" } ] api_service_type = "HTTP" api_http_service_config = [ { address = "http://apigateway-backend.alicloudapi.com:8080" method = "GET" path = "/web/cloudapi" timeout = 12 aone_name = "cloudapi-openapi" } ] api_request_parameters = [ { name = "test" type = "STRING" required = "REQUIRED" in = "QUERY" in_service = "QUERY" name_service = "testparams" } ] api_stage_name = [ "RELEASE", "PRE", "TEST" ]
-
Setting values for the following variables:
through environment variables
- ALICLOUD_ACCESS_KEY
- ALICLOUD_SECRET_KEY
- ALICLOUD_REGION
Name Description Type Default Required api_name The name of the api gateway api. string "" yes api_description The description of the api. string "" no api_auth_type The authorization Type including APP and ANONYMOUS. string "" yes api_request_config Request_config defines how users can send requests to your API. list "" yes api_service_type The type of backend service. Type including HTTP,VPC and MOCK. list "" yes api_http_service_config http_service_config defines the config list "" yes api_request_parameters Request_parameters defines . list "" no api_stage_names Stages that the api need to be deployed. Valid value: RELEASE,PRE and TEST. list "" no api_group_name The name of the api gateway group. string "" yes api_group_description The description of the api group. string "" no Name Description this_api_id the ID of api-gateway API this_api_group_id the ID of api-gateway API Group
From the version v1.2.0, the module has removed the following provider
setting:
provider "alicloud" {
version = ">=1.56.0"
region = var.region != "" ? var.region : null
configuration_source = "terraform-alicloud-modules/api-gateway"
}
If you still want to use the provider
setting to apply this module, you can specify a supported version, like 1.1.0:
module "apigateway" {
source = "terraform-alicloud-modules/api-gateway/alicloud"
version = "1.1.0"
region = "cn-beijing"
api_group_name = "TerraformApiGatewayGroup"
api_group_description = "Module of APi gateway Group"
// ...
}
If you want to upgrade the module to 1.2.0 or higher in-place, you can define a provider which same region with previous region:
provider "alicloud" {
region = "cn-beijing"
}
module "apigateway" {
source = "terraform-alicloud-modules/api-gateway/alicloud"
api_group_name = "TerraformApiGatewayGroup"
api_group_description = "Module of APi gateway Group"
// ...
}
or specify an alias provider with a defined region to the module using providers
:
provider "alicloud" {
region = "cn-beijing"
alias = "bj"
}
module "apigateway" {
source = "terraform-alicloud-modules/api-gateway/alicloud"
providers = {
alicloud = alicloud.bj
}
api_group_name = "TerraformApiGatewayGroup"
api_group_description = "Module of APi gateway Group"
// ...
}
and then run terraform init
and terraform apply
to make the defined provider effect to the existing module state.
More details see How to use provider in the module
Name | Version |
---|---|
terraform | >= 0.13.0 |
alicloud | >= 1.56.0 |
Created and maintained by Alibaba Cloud Terraform Team([email protected])