Skip to content

Commit

Permalink
feat(CSS): import apig_signature resource, 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 a9ee445
Show file tree
Hide file tree
Showing 7 changed files with 917 additions and 1 deletion.
122 changes: 122 additions & 0 deletions docs/resources/apig_signature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
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

Changing this will create a new resource.

* `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.
Changing this will create a new resource.

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

* `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**

Changing this will create a new resource.

## 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
2 changes: 1 addition & 1 deletion flexibleengine/acceptance/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ data "flexibleengine_compute_flavors_v2" "test" {
memory_size = 4
}
data "flexibleengine_images_image" "test" {
data "flexibleengine_images_image_v2" "test" {
name = "OBS Ubuntu 18.04"
}
`, testBaseNetwork(name))
Expand Down
Loading

0 comments on commit a9ee445

Please sign in to comment.