Skip to content

Commit

Permalink
feat(apig_signature): import apig_signature resource, unit test and d…
Browse files Browse the repository at this point in the history
…ocument.
  • Loading branch information
Zhukun-Huawei committed Nov 20, 2023
1 parent 71662e8 commit 43f2401
Show file tree
Hide file tree
Showing 6 changed files with 910 additions and 0 deletions.
117 changes: 117 additions & 0 deletions docs/resources/apig_signature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
subcategory: "API Gateway (Dedicated APIG)"
---

# flexibleengine_apig_signature

Manages a signature resource within FlexibleEngine.

## Example Usage

### Create a signature of the HMAC type

```hcl
variable "instance_id" {}
variable "signature_name" {}
variable "signature_key" {}
variable "signature_secret" {}
resource "flexibleengine_apig_signature" "test" {
instance_id = var.instance_id
name = var.signature_name
type = "hmac"
key = var.signature_key
secret = var.signature_secret
}
```

### Create a signature and automatically generate key and secret

```hcl
variable "instance_id" {}
variable "signature_name" {}
resource "flexibleengine_apig_signature" "test" {
instance_id = var.instance_id
name = var.signature_name
type = "hmac"
}
```

### Create a signature of the AES type

```hcl
variable "instance_id" {}
variable "signature_name" {}
variable "signature_key" {}
variable "signature_secret" {}
resource "flexibleengine_apig_signature" "test" {
instance_id = var.instance_id
name = var.signature_name
type = "aes"
algorithm = "aes-128-cfb"
key = var.signature_key
secret = var.signature_secret
}
```

## Argument Reference

The following arguments are supported:

* `region` - (Optional, String, ForceNew) Specifies the region where the signature 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 signature
belongs.
Changing this will create a new resource.

* `name` - (Required, String) Specifies the signature name.
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 signature.
The valid values are as follows:
+ **basic**: Basic auth type.
+ **hmac**: HMAC type.
+ **aes**: AES type

* `key` - (Optional, String) Specifies the signature key.
+ For `basic` type: The value contains `4` to `32` characters, including letters, digits, underscores (_) and
hyphens (-). It must start with a letter.
+ For `hmac` type: The value contains `8` to `32` characters, including letters, digits, underscores (_) and
hyphens (-). It must start with a letter or digit.
+ For `aes` type: The value contains `16` characters if the `aes-128-cfb` algorithm is used, or `32` characters if the
`aes-256-cfb` algorithm is used. Only letters, digits, and special characters (`_-!@#$%+/=`) are allowed.
It must start with a letter, digit, plus sign (+), or slash (/).

If not specified, the key will automatically generated. The auto-generation is only supported on first creation.

* `secret` - (Optional, String) Specifies the signature secret.
If not specified, the secret will automatically generated. The auto-generation is only supported on first creation.

* `algorithm` - (Optional, String) Specifies the signature algorithm.
This parameter is required and only available when signature `type` is `aes`.
The valid values are as follows:
+ **aes-128-cfb**
+ **aes-256-cfb**

## Attribute Reference

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

* `id` - The ID of the signature.

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

* `updated_at` - The latest update time of the signature.

## Import

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

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

# flexibleengine_apig_signature_associate

Use this resource to bind the APIs to the signature within FlexibleEngine.

-> A signature can only create one `flexibleengine_apig_signature_associate` resource.
And a published ID for API can only bind a signature.

## Example Usage

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

## Argument Reference

The following arguments are supported:

* `region` - (Optional, String, ForceNew) Specifies the region where the signature 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
signature belong.
Changing this will create a new resource.

* `signature_id` - (Required, String, ForceNew) Specifies the signature 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 signature.

## Attribute Reference

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

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

## Import

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

```bash
$ terraform import flexibleengine_apig_signature_associate.test <instance_id>/<signature_id>
```
1 change: 1 addition & 0 deletions flexibleengine/acceptance/acceptance.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
OS_ACCESS_KEY = os.Getenv("OS_ACCESS_KEY")
OS_SECRET_KEY = os.Getenv("OS_SECRET_KEY")
OS_PROJECT_ID = os.Getenv("OS_PROJECT_ID")
OS_USER_ID = os.Getenv("OS_USER_ID")

OS_VPC_ID = os.Getenv("OS_VPC_ID")
OS_NETWORK_ID = os.Getenv("OS_NETWORK_ID")
Expand Down
Loading

0 comments on commit 43f2401

Please sign in to comment.