Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New dedicated instance resource of APIG service #1221

Merged
merged 4 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions docs/resources/apig_instance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
subcategory: "API Gateway (APIG)"
---

# huaweicloud_apig_instance

Manages an APIG dedicated instance resource within HuaweiCloud.

## Example Usage

```hcl
variable "instance_name" {}
variable "vpc_id" {}
variable "subnet_id" {}
variable "security_group_id" {}
variable "eip_id" {}
variable "enterprise_project_id" {}

data "huaweicloud_availability_zones" "test" {}

resource "huaweicloud_apig_instance" "test" {
name = var.instance_name
edition = "BASIC"
vpc_id = var.vpc_id
subnet_id = var.subnet_id
security_group_id = var.security_group_id
enterprise_project_id = var.enterprise_project_id
maintain_begin = "06:00:00"
description = "Created by script"
bandwidth_size = 3
eip_id = var.eip_id

available_zones = [
data.huaweicloud_availability_zones.test.names[0],
data.huaweicloud_availability_zones.test.names[1],
]
}
```

## Argument Reference

The following arguments are supported:

* `region` - (Optional, String, ForceNew) Specifies the region in which to create the APIG dedicated instance resource.
If omitted, the provider-level region will be used.
Changing this will create a new APIG dedicated instance resource.

* `name` - (Required, String) Specifies the name of the API dedicated instance.
The API group name consists of 3 to 64 characters, starting with a letter.
Only letters, digits, and underscores (_) are allowed.

* `edition` - (Required, String, ForceNew) Specifies the edition of the APIG dedicated instance.
The supported editions are as follows:
BASIC, PROFESSIONAL, ENTERPRISE, PLATINUM.
Changing this will create a new APIG dedicated instance resource.

* `vpc_id` - (Required, String, ForceNew) Specifies an ID of the VPC used to create the APIG dedicated instance.
Changing this will create a new APIG dedicated instance resource.

* `subnet_id` - (Required, String, ForceNew) Specifies an ID of the VPC subnet used to create the APIG dedicated
instance.
Changing this will create a new APIG dedicated instance resource.

* `security_group_id` - (Required, String) Specifies an ID of the security group to which the APIG dedicated instance
belongs to.

* `available_zones` - (Optional, List, ForceNew) Specifies an array of available zone names for the APIG dedicated
instance. Please following [reference](https://developer.huaweicloud.com/intl/en-us/endpoint?APIG) for list elements.
Changing this will create a new APIG dedicated instance resource.

* `description` - (Optional, String) Specifies the description about the APIG dedicated instance.
The description contain a maximum of 255 characters and the angle brackets (< and >) are not allowed.

* `enterprise_project_id` - (Optional, String, ForceNew) Specifies an enterprise project ID.
This parameter is required for enterprise users.
Changing this will create a new APIG dedicated instance resource.

* `maintain_begin` - (Optional, String) Specifies a start time of the maintenance time window in the format 'xx:00:00'.
The value of xx can be 02, 06, 10, 14, 18 or 22.

* `bandwidth_size` - (Optional, Int) Specifies the egress bandwidth size of the APIG dedicated instance.
The range of valid value is from 1 to 2000.

* `eip_id` - (Optional, String) Specifies the eip ID associated with the APIG dedicated instance.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `id` - ID of the APIG dedicated instance.
* `maintain_end` - End time of the maintenance time window, 4-hour difference between the start time and end time.
* `create_time` - Time when the APIG instance is created, in RFC-3339 format.
* `status` - Status of the APIG dedicated instance.
* `supported_features` - The supported features of the APIG dedicated instance.
* `egress_address` - The egress (nat) public ip address.
* `ingress_address` - The ingress eip address.
* `vpc_ingress_address` - The ingress private ip address of vpc.

## Timeouts

This resource provides the following timeouts configuration options:
- `create` - Default is 40 minute.
- `update` - Default is 10 minute.
- `delete` - Default is 10 minute.

## Import

APIG Dedicated Instances can be imported by their `id`, e.g.
```
$ terraform import huaweicloud_apig_instance.test de379eed30aa4d31a84f426ea3c7ef4e
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/terraform-plugin-sdk v1.16.0
github.com/huaweicloud/golangsdk v0.0.0-20210621093751-3dd439dd31e3
github.com/huaweicloud/golangsdk v0.0.0-20210621115823-3cecb9fc9172
github.com/jen20/awspolicyequivalence v1.1.0
github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa // indirect
github.com/stretchr/testify v1.4.0
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,12 @@ github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596/go.mod
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/huaweicloud/golangsdk v0.0.0-20210621093751-3dd439dd31e3 h1:RF1TuFSkplWinbZpl6BfVJ+r394k4xOkVKXUt09IjJo=
github.com/huaweicloud/golangsdk v0.0.0-20210621093751-3dd439dd31e3/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0=
github.com/huaweicloud/golangsdk v0.0.0-20210608085437-ebb866377c9f h1:uvvd7F4iujOwAP0E0W7H91IrgBt5KI0xE7A6HCwGTj0=
github.com/huaweicloud/golangsdk v0.0.0-20210608085437-ebb866377c9f/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0=
github.com/huaweicloud/golangsdk v0.0.0-20210618111817-9c67059b7682 h1:BdVmP7j7kdtRau+JV6QjAMg2sMgsQIbYg9uAqOlt+j8=
github.com/huaweicloud/golangsdk v0.0.0-20210618111817-9c67059b7682/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0=
github.com/huaweicloud/golangsdk v0.0.0-20210621115823-3cecb9fc9172 h1:6OLBFIxdht5gTP3AVkKM4CngryJSwRrFGX43xqAPAu4=
github.com/huaweicloud/golangsdk v0.0.0-20210621115823-3cecb9fc9172/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
Expand Down
4 changes: 4 additions & 0 deletions huaweicloud/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,10 @@ func (c *Config) ApiGatewayV1Client(region string) (*golangsdk.ServiceClient, er
return c.NewServiceClient("apig", region)
}

func (c *Config) ApigV2Client(region string) (*golangsdk.ServiceClient, error) {
return c.NewServiceClient("apig_v2", region)
}

func (c *Config) BcsV2Client(region string) (*golangsdk.ServiceClient, error) {
return c.NewServiceClient("bcs", region)
}
Expand Down
5 changes: 5 additions & 0 deletions huaweicloud/config/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ var allServiceCatalog = map[string]ServiceCatalog{
ResourceBase: "apigw",
WithOutProjectID: true,
},
"apig_v2": {
Name: "apig",
Version: "v2",
ResourceBase: "apigw",
},
"bcs": {
Name: "bcs",
Version: "v2",
Expand Down
12 changes: 12 additions & 0 deletions huaweicloud/endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,18 @@ func TestAccServiceEndpoints_Application(t *testing.T) {
}
t.Logf("API-GW endpoint:\t %s", actualURL)

// test the endpoint of API-GW v2 service
serviceClient, err = config.ApigV2Client(HW_REGION_NAME)
if err != nil {
t.Fatalf("Error creating HuaweiCloud API-GW v2 client: %s", err)
}
expectedURL = fmt.Sprintf("https://apig.%s.%s/v2/apigw/", HW_REGION_NAME, config.Cloud)
actualURL = serviceClient.ResourceBaseURL()
if actualURL != expectedURL {
t.Fatalf("API-GW v2 endpoint: expected %s but got %s", green(expectedURL), yellow(actualURL))
}
t.Logf("API-GW v2 endpoint:\t %s", actualURL)

// test the endpoint of BCS v2 service
serviceClient, err = config.BcsV2Client(HW_REGION_NAME)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions huaweicloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ func Provider() terraform.ResourceProvider {
ResourcesMap: map[string]*schema.Resource{
"huaweicloud_api_gateway_api": ResourceAPIGatewayAPI(),
"huaweicloud_api_gateway_group": ResourceAPIGatewayGroup(),
"huaweicloud_apig_instance": ResourceApigInstanceV2(),
"huaweicloud_as_configuration": ResourceASConfiguration(),
"huaweicloud_as_group": ResourceASGroup(),
"huaweicloud_as_lifecycle_hook": ResourceASLifecycleHook(),
Expand Down
Loading