Skip to content

Commit

Permalink
feat(apig):import apig resource and add unit test and document
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhukun-Huawei committed Oct 26, 2023
1 parent 02543dd commit 223e2c5
Show file tree
Hide file tree
Showing 18 changed files with 2,942 additions and 1 deletion.
47 changes: 47 additions & 0 deletions docs/resources/api_gateway_environment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
subcategory: "API Gateway (Shared APIG)"
---

# huaweicloud_api_gateway_environment

Manages a shared APIG environment resource within HuaweiCloud.

## Example Usage

```hcl
resource "huaweicloud_api_gateway_environment" "test_env" {
name = "test"
description = "test env"
}
```

## Argument Reference

The following arguments are supported:

* `region` - (Optional, String, ForceNew) Specifies the region where the shared APIG environment is located.
If omitted, the provider-level region will be used. Changing this will create a new resource.

* `name` - (Required, String) Specifies the environment name.
The valid length is limited from `3` to `64`, only letters, digits and underscores (_) are allowed.
The name must start with a letter.

* `description` - (Optional, String) Specifies the environment description.
The value can contain a maximum of `255` characters.
Chinese characters must be in **UTF-8** or **Unicode** format.

## Attribute Reference

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

* `id` - The environment ID.

* `created_at` - The time when the shared APIG environment was created.

## Import

APIG environments can be imported using the `id`, e.g.

```
$ terraform import huaweicloud_api_gateway_environment.test_env 774438a28a574ac8a496325d1bf51807
```
91 changes: 91 additions & 0 deletions docs/resources/apig_acl_policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
subcategory: "API Gateway (Dedicated APIG)"
---

# flexibleengine_apig_acl_policy

Manages an ACL policy resource within HuaweiCloud.

## Example Usage

### Create an ACL policy with IP control

```hcl
variable "instance_id" {}
variable "policy_name" {}
variable "ip_addresses" {
type = list(stirng)
}
resource "flexibleengine_apig_acl_policy" "ip_rule" {
instance_id = var.instance_id
name = var.policy_name
type = "PERMIT"
entity_type = "IP"
value = join(var.ip_addresses, ",")
}
```

### Create an ACL policy with account control (via domain names)

```hcl
variable "instance_id" {}
variable "policy_name" {}
variable "domain_names" {
type = list(stirng)
}
resource "flexibleengine_apig_acl_policy" "domain_rule" {
instance_id = var.instance_id
name = var.policy_name
type = "PERMIT"
entity_type = "DOMAIN"
value = join(var.domain_names, ",")
}
```

## Argument Reference

The following arguments are supported:

* `region` - (Optional, String, ForceNew) Specifies the region where the ACL policy is located.
If omitted, the provider-level region will be used. Changing this will create a new resource.

* `instance_id` - (Required, String, ForceNew) Specifies the ID of the dedicated instance to which the ACL
policy belongs.
Changing this will create a new resource.

* `name` - (Required, String) Specifies the name of the ACL policy.
The valid length is limited from `3` to `64`, only English letters, Chinese characters, digits and underscores (_) are
allowed. The name must start with an English letter or Chinese character.

* `type` - (Required, String) Specifies the type of the ACL policy.
The valid values are as follows:
+ **PERMIT**: Allow specific IPs or accounts to access API.
+ **DENY**: Forbid specific IPs or accounts to access API.

* `entity_type` - (Required, String, ForceNew) Specifies the entity type of the ACL policy.
The valid values are as follows:
+ **IP**: This rule is specified to control access to the API for specific IPs.
+ **DOMAIN**: This rule is specified to control access to the API for specific accounts (specified by domain name).

Changing this will create a new resource.

* `value` - (Required, String) Specifies one or more objects from which the access will be controlled.
Separate multiple objects with commas (,).

## Attribute Reference

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

* `id` - The ID of the ACL policy.

* `updated_at` - The latest update time of the ACL policy.

## Import

ACL Policies can be imported using their `id` and related dedicated instance ID, separated by a slash, e.g.

```bash
$ terraform import flexibleengine_apig_acl_policy.test <instance_id>/<id>
```
56 changes: 56 additions & 0 deletions docs/resources/apig_acl_policy_associate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
subcategory: "API Gateway (Dedicated APIG)"
---

# flexibleengine_apig_acl_policy_associate

Use this resource to bind the APIs to the ACL policy within Flexibleengine.

-> An ACL policy can only create one `flexibleengine_apig_acl_policy_associate` resource.

## Example Usage

```hcl
variable "instance_id" {}
variable "policy_id" {}
variable "api_publish_ids" {
type = list(string)
}
resource "flexibleengine_apig_acl_policy_associate" "test" {
instance_id = var.instance_id
policy_id = var.policy_id
publish_ids = var.api_publish_ids
}
```

## Argument Reference

The following arguments are supported:

* `region` - (Optional, String, ForceNew) Specifies the region where the ACL policy and the APIs are located.
If omitted, the provider-level region will be used. Changing this will create a new resource.

* `instance_id` - (Required, String, ForceNew) Specifies the ID of the dedicated instance to which the APIs and the
ACL policy belong.
Changing this will create a new resource.

* `policy_id` - (Required, String, ForceNew) Specifies the ACL Policy ID for APIs binding.
Changing this will create a new resource.

* `publish_ids` - (Required, List) Specifies the publish IDs corresponding to the APIs bound by the ACL policy.

## Attribute Reference

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

* `id` - Resource ID. The format is `<instance_id>/<policy_id>`.

## Import

Associate resources can be imported using their `policy_id` and the APIG dedicated instance ID to which the policy
belongs, separated by a slash, e.g.

```bash
$ terraform import flexibleengine_apig_acl_policy_associate.test <instance_id>/<policy_id>
```
71 changes: 71 additions & 0 deletions docs/resources/apig_appcode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
subcategory: "API Gateway (Dedicated APIG)"
---

# flexibleengine_apig_appcode

Manages an APPCODE in application resource within FlexibleEngine.

## Example Usage

### Auto generate APPCODE

```hcl
variable "instance_id" {}
variable "application_id" {}
resource "flexibleengine_apig_appcode" "test" {
instance_id = var.instance_id
application_id = var.application_id
}
```

### Manually configure APPCODE

```hcl
variable "instance_id" {}
variable "application_id" {}
variable "app_code" {}
resource "flexibleengine_apig_appcode" "test" {
instance_id = var.instance_id
application_id = var.application_id
value = var.app_code
}
```

## Argument Reference

The following arguments are supported:

* `region` - (Optional, String, ForceNew) Specifies the region where the application and APPCODE are located.
If omitted, the provider-level region will be used. Changing this will create a new resource.

* `instance_id` - (Required, String, ForceNew) Specifies the ID of the dedicated instance to which the application
and APPCODE belong.
Changing this will create a new resource.

* `application_id` - (Required, String, ForceNew) Specifies the ID of application to which the APPCODE belongs.
Changing this will create a new resource.

* `value` - (Optional, String, ForceNew) Specifies the APPCODE value (content).
The value can contain `64` to `180` characters, starting with a letter, plus sign (+), or slash (/). Only letters and
the following special characters are allowed: `+_!@#$%/=`.
If omitted, a random value will be generated.
Changing this will create a new resource.

## Attribute Reference

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

* `id` - The APPCODE ID.

* `created_at` - The creation time of the APPCODE.

## Import

APPCODEs can be imported using related `instance_id`, `application_id` and their `id`, separated by slashes, e.g.

```bash
$ terraform import flexibleengine_apig_appcode.test <instance_id>/<application_id>/<id>
```
70 changes: 70 additions & 0 deletions docs/resources/apig_application_authorization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
subcategory: "API Gateway (Dedicated APIG)"
---

# flexibleengine_apig_application_authorization

Using this resoruce to authorize APIs for application, allowing it to access the published APIs within Flexibleengine.

-> For an application, an environment can only create one `flexibleengine_apig_application_authorization` resource (all
published APIs must belong to an environment).

## Example Usage

```hcl
variable "instance_id" {}
variable "application_id" {}
variable "published_env_id" {}
variable "published_api_ids" {
type = list(string)
}
resource "flexibleengine_apig_application_authorization" "test" {
instance_id = var.instance_id
application_id = var.application_id
env_id = var.published_env_id
api_ids = var.published_api_ids
}
```

## Argument Reference

The following arguments are supported:

* `region` - (Optional, String, ForceNew) Specifies the region where the application and APIs are located.
If omitted, the provider-level region will be used. Changing this will create a new resource.

* `instance_id` - (Required, String, ForceNew) Specifies the ID of the dedicated instance to which the application
and APIs belong.
Changing this will create a new resource.

* `application_id` - (Required, String, ForceNew) Specifies the ID of the application authorized to access the APIs.
Changing this will create a new resource.

* `env_id` - (Required, String, ForceNew) Specifies the environment ID where the APIs were published.
Changing this will create a new resource.

* `api_ids` - (Required, List) Specifies the authorized API IDs.

## Attribute Reference

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

* `id` - The resource ID, also `<env_id>/<application_id>`.

## Timeouts

This resource provides the following timeouts configuration options:

* `create` - Default is 3 minutes.
* `update` - Default is 3 minutes.
* `delete` - Default is 3 minutes.

## Import

Authorize relationships of application can be imported using related `instance_id` and their `id` (also consists of
`env_id` and `application_id`), separated by the slashes, e.g.

```bash
$ terraform import flexibleengine_apig_application_authorization.test <instance_id>/<env_id>/<application_id>
```
Loading

0 comments on commit 223e2c5

Please sign in to comment.