Giter Site home page Giter Site logo

mrwolong / terraform-alicloud-api-gateway Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alibabacloud-automation/terraform-alicloud-api-gateway

0.0 0.0 0.0 5.11 MB

A terraform module supports to create API Gateway on Alibaba Cloud.

License: Mozilla Public License 2.0

HCL 66.81% Go 33.19%

terraform-alicloud-api-gateway's Introduction

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:

Usage

You can use this in your terraform template with the following steps.

  1. 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"
         ]
    
  2. Setting values for the following variables:

    through environment variables

    • ALICLOUD_ACCESS_KEY
    • ALICLOUD_SECRET_KEY
    • ALICLOUD_REGION

    Inputs

    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

    Outputs

    Name Description
    this_api_id the ID of api-gateway API
    this_api_group_id the ID of api-gateway API Group

Notes

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

Terraform versions

Name Version
terraform >= 0.13.0
alicloud >= 1.56.0

Authors

Created and maintained by Alibaba Cloud Terraform Team([email protected])

Reference

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.