Skip to content

Commit

Permalink
[APIGW] acl policy (#2495)
Browse files Browse the repository at this point in the history
[APIGW] acl policy

Summary of the Pull Request
PR Checklist

 Refers to: #xxx
 Tests added/passed.
 Documentation updated.
 Schema updated.
 Release notes added.

Acceptance Steps Performed
=== RUN   TestAccAclPolicy_basic
=== PAUSE TestAccAclPolicy_basic
=== CONT  TestAccAclPolicy_basic
--- PASS: TestAccAclPolicy_basic (521.02s)
PASS

Process finished with the exit code 0

Reviewed-by: Aloento
Reviewed-by: Vladimir Vshivkov
  • Loading branch information
anton-sidelnikov committed May 1, 2024
1 parent 5f9da27 commit 1c47cb0
Show file tree
Hide file tree
Showing 16 changed files with 517 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/data-sources/apigw_api_history_v2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "APIG"
subcategory: "APIGW"
---

# opentelekomcloud_apigw_api_history_v2
Expand Down Expand Up @@ -49,7 +49,7 @@ In addition to all arguments above, the following attributes are exported:
* `id` - Data source ID.

* `history` - List of APIGW history details.
The [object](#history) structure is documented below.
The [object](#publishment_history) structure is documented below.

* `region` - The region in which to APIs was published.

Expand Down
107 changes: 107 additions & 0 deletions docs/resources/apigw_acl_policy_v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
subcategory: "APIGW"
---

# opentelekomcloud_apigw_acl_policy_v2

Manages an ACL policy resource within OpenTelekomCloud.

## Example Usage

### Create an ACL policy with IP control

```hcl
variable "gateway_id" {}
variable "policy_name" {}
variable "ip_addresses" {
type = list(string)
}
resource "opentelekomcloud_apigw_acl_policy_v2" "ip_rule" {
gateway_id = var.gateway_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 "gateway_id" {}
variable "policy_name" {}
variable "domain_names" {
type = list(string)
}
resource "opentelekomcloud_apigw_acl_policy_v2" "domain_rule" {
gateway_id = var.gateway_id
name = var.policy_name
type = "PERMIT"
entity_type = "DOMAIN"
value = join(",", var.domain_names)
}
```

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

```hcl
variable "gateway_id" {}
variable "policy_name" {}
variable "domain_ids" {
type = list(string)
}
resource "opentelekomcloud_apigw_acl_policy_v2" "domain_id_rule" {
gateway_id = var.gateway_id
name = var.policy_name
type = "PERMIT"
entity_type = "DOMAIN_ID"
value = join(",", var.domain_ids)
}
```

## Argument Reference

The following arguments are supported:
* `gateway_id` - (Required, String, ForceNew) Specifies the ID of the dedicated gateway 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 letter.

* `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).
+ `DOMAIN_ID`: This rule is specified to control access to the API for specific accounts (specified by domain ID).
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.

* `region` - The region where the ACL policy is located.

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

## Import

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

```bash
$ terraform import opentelekomcloud_apigw_acl_policy_v2.test <gateway_id>/<id>
```
2 changes: 1 addition & 1 deletion docs/resources/apigw_api_publishment_v2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "APIG"
subcategory: "APIGW"
---

# opentelekomcloud_apigw_api_publishment_v2
Expand Down
10 changes: 5 additions & 5 deletions docs/resources/apigw_api_v2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "APIG"
subcategory: "APIGW"
---

Up-to-date reference of API arguments for API Gateway API service you can get at
Expand Down Expand Up @@ -214,19 +214,19 @@ The following arguments are supported:
Changing this will create a new API resource.

* `http` - (Optional, List, ForceNew) Specifies the web backend details.
The [object](#apig_api_http) structure is documented below. Changing this will create a new API resource.
The [object](#apigw_api_http) structure is documented below. Changing this will create a new API resource.

* `mock_policy` - (Optional, List) Specifies the Mock policy backends.
The maximum blocks of the policy is 5.
The [object](#apig_api_mock_policy) structure is documented below.
The [object](#apigw_api_mock_policy) structure is documented below.

* `func_graph_policy` - (Optional, List) Specifies the Mock policy backends.
The maximum blocks of the policy is 5.
The [object](#apig_api_func_graph_policy) structure is documented below.
The [object](#apigw_api_func_graph_policy) structure is documented below.

* `http_policy` - (Optional, List) Specifies the example response for a failed request.
The maximum blocks of the policy is 5.
The [object](#apig_api_http_policy) structure is documented below.
The [object](#apigw_api_http_policy) structure is documented below.

<a name="apigw_api_request_params"></a>
The `request_params` block supports:
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/apigw_environment_v2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "APIG"
subcategory: "APIGW"
---

Up-to-date reference of API arguments for API Gateway service you can get at
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/apigw_gateway_v2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "APIG"
subcategory: "APIGW"
---

Up-to-date reference of API arguments for API Gateway service you can get at
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/apigw_group_v2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "APIG"
subcategory: "APIGW"
---

Up-to-date reference of API arguments for API Gateway service you can get at
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/apigw_throttling_policy_associate_v2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "APIG"
subcategory: "APIGW"
---

# opentelekomcloud_apigw_throttling_policy_associate_v2
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/apigw_throttling_policy_v2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "APIG"
subcategory: "APIGW"
---

Up-to-date reference of API arguments for API Gateway service you can get at
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/jmespath/go-jmespath v0.4.0
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
github.com/mitchellh/go-homedir v1.1.0
github.com/opentelekomcloud/gophertelekomcloud v0.9.3
github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20240429100828-a7c13cb1d90e
github.com/unknwon/com v1.0.1
golang.org/x/crypto v0.21.0
golang.org/x/sync v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/opentelekomcloud/gophertelekomcloud v0.9.3 h1:zdttgRAWc4uHgJ3PX5hP8ulhT1VYBh2JeRsItNPp8dg=
github.com/opentelekomcloud/gophertelekomcloud v0.9.3/go.mod h1:M1F6OfSRZRzAmAFKQqSLClX952at5hx5rHe4UTEykgg=
github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20240429100828-a7c13cb1d90e h1:53LQ3cHXO76eyUDWSsZEsZ3c8BtFhnyS81My3DwA8Y4=
github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20240429100828-a7c13cb1d90e/go.mod h1:M1F6OfSRZRzAmAFKQqSLClX952at5hx5rHe4UTEykgg=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
Loading

0 comments on commit 1c47cb0

Please sign in to comment.