Skip to content

Commit

Permalink
Tgw attachments (#549)
Browse files Browse the repository at this point in the history
* WIP

* Added a datasource

* Added a datasource and resource for active-active

* Bugfixing the update endpoint

* Added documentation including maintenance windows

* Doc changes and better checks for needed env variables when running tests

* Added a (skipped) test over AA/transit gateway attachment functionality

* Bugfixes to AA TGW attachments

* removing skip on AA TGW test

* adding AWS_TEST_AA_TGW_ID env var for TGW test

* Revert "adding AWS_TEST_AA_TGW_ID env var for TGW test"

This reverts commit 8626d05.

* remove AA TGW test

---------

Co-authored-by: gregnuttall <[email protected]>
  • Loading branch information
JohnSharpe and greg-oc authored Jul 24, 2024
1 parent 8f158d3 commit 9a9a01c
Show file tree
Hide file tree
Showing 22 changed files with 1,205 additions and 36 deletions.
1 change: 1 addition & 0 deletions .github/workflows/terraform_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ jobs:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_VPC_CIDR: ${{ secrets.AWS_VPC_CIDR }}
AWS_VPC_ID: ${{ secrets.AWS_VPC_ID }}
AWS_TEST_TGW_ID: ${{ secrets.AWS_TEST_TGW_ID_STAGING }}
TF_ACC: true
TF_LOG: debug
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUD_ACCOUNT_KEY }}
Expand Down
13 changes: 12 additions & 1 deletion docs/data-sources/rediscloud_active_active_subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,20 @@ output "rediscloud_active_active_subscription" {
* `cloud_provider` - The cloud provider used with the subscription, (either `AWS` or `GCP`).
* `number_of_databases` - The number of databases that are linked to this subscription.
* `status` - Current status of the subscription

* `maintenance_windows` - Details about the subscription's maintenance window specification, documented below
* `pricing` - A list of pricing objects, documented below

The `maintenance_windows` object has these attributes:

* `mode` - Either `automatic` (Redis specified) or `manual` (User specified)
* `window` - A list of windows (if manual mode)

The `window` object has these attributes:

* `start_hour` - What hour in the day (0-23) the window opens
* `duration_in_hours` - How long the window is open
* `days` - A list of weekdays on which the window is open ('Monday', 'Tuesday' etc)

The `pricing` object has these attributes:

* `database_name` - The database this pricing entry applies to.
Expand Down
40 changes: 40 additions & 0 deletions docs/data-sources/rediscloud_active_active_transit_gateway.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
layout: "rediscloud"
page_title: "Redis Cloud: rediscloud_transit_gateway"
description: |-
Active Active Transit Gateway data source in the Redis Cloud Terraform provider.
---

# Data Source: rediscloud_transit_gateway

The Active Active Transit Gateway data source allows access to an available Transit Gateway within your Redis Enterprise Cloud Account.

## Example Usage

```hcl
data "rediscloud_active_active_transit_gateway" "example" {
subscription_id = "113991"
region_id = 1
aws_tgw_id = "tgw-1c55bfdoe20pdsad2"
}
output "rediscloud_transit_gateway" {
value = data.rediscloud_active_active_transit_gateway.example.tgw_id
}
```

## Argument Reference

* `subscription_id` - (Required) The id of an Active Active subscription
* `region_id` - (Required) The id of the AWS region
* `tgw_id` - (Optional) The id of the Transit Gateway relative to the associated subscription. You would likely
reference this value when creating a `rediscloud_active_active_transit_gateway_attachment`.
* `aws_tgw_id` - (Optional) The id of the Transit Gateway as known to AWS

## Attribute Reference

* `attachment_uid` - A unique identifier for the Subscription/Transit Gateway attachment, if any
* `status` - The status of the Transit Gateway
* `attachment_status` - The status of the Subscription/Transit Gateway attachment, if any
* `aws_account_id` - The Transit Gateway's AWS account id
* `cidrs` - A list of consumer Cidr blocks, if an attachment exists
26 changes: 25 additions & 1 deletion docs/data-sources/rediscloud_subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ output "rediscloud_subscription" {
* `cloud_provider` - A cloud provider object, documented below
* `number_of_databases` - The number of databases that are linked to this subscription.
* `status` - Current status of the subscription
* `maintenance_windows` - Details about the subscription's maintenance window specification, documented below
* `pricing` - A list of pricing objects, documented below

The `cloud_provider` block supports:

Expand All @@ -50,11 +52,33 @@ The cloud_provider `region` block supports:
* `multiple_availability_zones` - Support deployment on multiple availability zones within the selected region
* `networking_vpc_id` - The ID of the VPC where the Redis Cloud subscription is deployed.
* `preferred_availability_zones` - List of availability zones used

* `networks` - List of generated network configuration

The `networks` block has these attributes:

* `networking_subnet_id` - The subnet that the subscription deploys into
* `networking_deployment_cidr` - Deployment CIDR mask for the generated
* `networking_vpc_id` - VPC id for the generated network

The `maintenance_windows` object has these attributes:

* `mode` - Either `automatic` (Redis specified) or `manual` (User specified)
* `window` - A list of windows (if manual mode)

The `window` object has these attributes:

* `start_hour` - What hour in the day (0-23) the window opens
* `duration_in_hours` - How long the window is open
* `days` - A list of weekdays on which the window is open ('Monday', 'Tuesday' etc)

The `pricing` object has these attributes:

* `database_name` - The database this pricing entry applies to.
* `type` - The type of cost e.g. 'Shards'.
* `typeDetails` - Further detail e.g. 'micro'.
* `quantity` - Self-explanatory.
* `quantityMeasurement` - Self-explanatory.
* `pricePerUnit` - Self-explanatory.
* `priceCurrency` - Self-explanatory e.g. 'USD'.
* `pricePeriod` - Self-explanatory e.g. 'hour'.
* `region` - Self-explanatory, if the cost is associated with a particular region.
38 changes: 38 additions & 0 deletions docs/data-sources/rediscloud_transit_gateway.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
layout: "rediscloud"
page_title: "Redis Cloud: rediscloud_transit_gateway"
description: |-
Transit Gateway data source in the Redis Cloud Terraform provider.
---

# Data Source: rediscloud_transit_gateway

The Transit Gateway data source allows access to an available Transit Gateway within your Redis Enterprise Cloud Account.

## Example Usage

```hcl
data "rediscloud_transit_gateway" "example" {
subscription_id = "113991"
aws_tgw_id = "tgw-1c55bfdoe20pdsad2"
}
output "rediscloud_transit_gateway" {
value = data.rediscloud_transit_gateway.example.tgw_id
}
```

## Argument Reference

* `subscription_id` - (Required) The id of a Pro/Flexible subscription
* `tgw_id` - (Optional) The id of the Transit Gateway relative to the associated subscription. You would likely
reference this value when creating a `rediscloud_transit_gateway_attachment`.
* `aws_tgw_id` - (Optional) The id of the Transit Gateway as known to AWS

## Attribute Reference

* `attachment_uid` - A unique identifier for the Subscription/Transit Gateway attachment, if any
* `status` - The status of the Transit Gateway
* `attachment_status` - The status of the Subscription/Transit Gateway attachment, if any
* `aws_account_id` - The Transit Gateway's AWS account id
* `cidrs` - A list of consumer Cidr blocks, if an attachment exists
12 changes: 12 additions & 0 deletions docs/resources/rediscloud_active_active_subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The following arguments are supported:
* `cloud_provider` - (Optional) The cloud provider to use with the subscription, (either `AWS` or `GCP`). Default: ‘AWS’. **Modifying this attribute will force creation of a new resource.**
* `redis_version` - (Optional) The Redis version of the databases in the subscription. If omitted, the Redis version will be the default. **Modifying this attribute will force creation of a new resource.**
* `creation_plan` - (Required) A creation plan object, documented below. Ignored after creation.
* `maintenance_windows` - (Optional) The subscription's maintenance window specification, documented below.

The `creation_plan` block supports:

Expand All @@ -76,6 +77,17 @@ The creation_plan `region` block supports:
* `write_operations_per_second` - (Required) Throughput measurement for an active-active subscription
* `read_operations_per_second` - (Required) Throughput measurement for an active-active subscription

The `maintenance_windows` object has these attributes:

* `mode` - Either `automatic` (Redis specified) or `manual` (User specified)
* `window` - A list of windows (if manual mode)

The `window` object has these attributes:

* `start_hour` - What hour in the day (0-23) the window opens
* `duration_in_hours` - How long the window is open
* `days` - A list of weekdays on which the window is open ('Monday', 'Tuesday' etc)

~> **Note:** If changes are made to attributes in the subscription which require the subscription to be recreated (such as `cloud_provider`), the creation_plan will need to be defined in order to change these attributes. This is because the creation_plan is always required when a subscription is created.

## Attribute reference
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
layout: "rediscloud"
page_title: "Redis Cloud: rediscloud_transit_gateway_attachment"
description: |-
Transit Gateway Attachment resource in the Redis Cloud Terraform provider.
---

# Resource: rediscloud_transit_gateway_attachment

Manages a Transit Gateway Attachment to an Active Active Subscription in your Redis Enterprise Cloud Account.

```hcl
data "rediscloud_transit_gateway" "gateway" {
subscription_id = "113492"
aws_tgw_id = "tgw-1c55bfdoe20pdsad2"
}
resource "rediscloud_active_active_transit_gateway_attachment" "attachment" {
subscription_id = "113492"
region_id = 1
tgw_id = data.rediscloud_transit_gateway.gateway.tgw_id
}
```

## Argument Reference

* `subscription_id` - (Required) The id of the Pro/Flexible subscription to attach
* `region_id` - (Required) The id of the AWS region
* `tgw_id` - (Required) The id of the Transit Gateway to attach to
* `cidrs` - (Optional) A list of consumer Cidr blocks. **May only be added once the Attachment has been accepted**

## Attribute Reference

* `aws_tgw_uid` - The id of the Transit Gateway as known to AWS
* `attachment_uid` - A unique identifier for the Subscription/Transit Gateway attachment, if established
* `status` - The status of the Transit Gateway
* `attachment_status` - The status of the Subscription/Transit Gateway attachment, if established
* `aws_account_id` - The Transit Gateway's AWS account id

## Import
`rediscloud_active_active_transit_gateway_attachment` can be imported using the ID of the Active-Active subscription and the ID of the Transit Gateway in the format {subscription ID}/{tgw ID}, e.g.

```
$ terraform import rediscloud_active_active_transit_gateway_attachment.tgwa-resource 123456/47
```
23 changes: 22 additions & 1 deletion docs/resources/rediscloud_subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ resource "rediscloud_subscription" "subscription-resource" {
throughput_measurement_value = 20000
modules = ["RedisJSON"]
}
maintenance_windows {
mode = "manual"
window {
start_hour = 22
duration_in_hours = 8
days = ["Tuesday", "Friday"]
}
}
}
```

Expand All @@ -69,7 +78,8 @@ The following arguments are supported:
* `redis_version` - (Optional) The Redis version of the databases in the subscription. If omitted, the Redis version will be the default. **Modifying this attribute will force creation of a new resource.**
* `allowlist` - (Optional) An allowlist object, documented below
* `cloud_provider` - (Required) A cloud provider object, documented below. **Modifying this attribute will force creation of a new resource.**
* `creation_plan` - (Required) A creation plan object, documented below
* `creation_plan` - (Required) A creation plan object, documented below.
* `maintenance_windows` - (Optional) The subscription's maintenance window specification, documented below.

The `allowlist` block supports:

Expand Down Expand Up @@ -117,6 +127,17 @@ The cloud_provider `region` block supports:
~> **Note:** The preferred_availability_zones parameter is required for Terraform, but is optional within the Redis Enterprise Cloud UI.
This difference in behaviour is to guarantee that a plan after an apply does not generate differences. In AWS Redis internal cloud account, please set the zone IDs (for example: `["use-az2", "use-az3", "use-az5"]`).

The `maintenance_windows` object has these attributes:

* `mode` - Either `automatic` (Redis specified) or `manual` (User specified)
* `window` - A list of windows (if manual mode)

The `window` object has these attributes:

* `start_hour` - What hour in the day (0-23) the window opens
* `duration_in_hours` - How long the window is open
* `days` - A list of weekdays on which the window is open ('Monday', 'Tuesday' etc)

### Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:
Expand Down
43 changes: 43 additions & 0 deletions docs/resources/rediscloud_transit_gateway_attachment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
layout: "rediscloud"
page_title: "Redis Cloud: rediscloud_transit_gateway_attachment"
description: |-
Transit Gateway Attachment resource in the Redis Cloud Terraform provider.
---

# Resource: rediscloud_transit_gateway_attachment

Manages a Transit Gateway Attachment to a Pro/Flexible Subscription in your Redis Enterprise Cloud Account.

```hcl
data "rediscloud_transit_gateway" "gateway" {
subscription_id = "113491"
aws_tgw_id = "tgw-1c55bfdoe20pdsad2"
}
resource "rediscloud_transit_gateway_attachment" "attachment" {
subscription_id = "113491"
tgw_id = data.rediscloud_transit_gateway.gateway.tgw_id
}
```

## Argument Reference

* `subscription_id` - (Required) The id of the Pro/Flexible subscription to attach
* `tgw_id` - (Required) The id of the Transit Gateway to attach to
* `cidrs` - (Optional) A list of consumer Cidr blocks. **May only be added once the Attachment has been accepted**

## Attribute Reference

* `aws_tgw_uid` - The id of the Transit Gateway as known to AWS
* `attachment_uid` - A unique identifier for the Subscription/Transit Gateway attachment, if established
* `status` - The status of the Transit Gateway
* `attachment_status` - The status of the Subscription/Transit Gateway attachment, if established
* `aws_account_id` - The Transit Gateway's AWS account id

## Import
`rediscloud_transit_gateway_attachment` can be imported using the ID of the Pro/Flexible subscription and the ID of the Transit Gateway in the format {subscription ID}/{tgw ID}, e.g.

```
$ terraform import rediscloud_transit_gateway_attachment.tgwa-resource 123456/47
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/RedisLabs/terraform-provider-rediscloud
go 1.22.4

require (
github.com/RedisLabs/rediscloud-go-api v0.18.0
github.com/RedisLabs/rediscloud-go-api v0.19.0
github.com/bflad/tfproviderlint v0.30.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg=
github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/RedisLabs/rediscloud-go-api v0.18.0 h1:1nyrD0SFU8ILRNvJJUpq8vRyzBUkO0Flf43yPV9CQCs=
github.com/RedisLabs/rediscloud-go-api v0.18.0/go.mod h1:Euh81mfkoCDTH2gQT+rNnvI7rwCDe05zdvkxp9oKQsM=
github.com/RedisLabs/rediscloud-go-api v0.19.0 h1:ItgQzOwKT1kF+1buLS80kWLZsilW4DscB/WeuNQ8rbY=
github.com/RedisLabs/rediscloud-go-api v0.19.0/go.mod h1:Euh81mfkoCDTH2gQT+rNnvI7rwCDe05zdvkxp9oKQsM=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
Expand Down
12 changes: 6 additions & 6 deletions provider/datasource_rediscloud_active_active_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,34 @@ func dataSourceRedisCloudActiveActiveSubscription() *schema.Resource {
Computed: true,
},
"maintenance_windows": {
Description: "",
Description: "Details about the subscription's maintenance window specification",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"mode": {
Description: "",
Description: "Either automatic (Redis specified) or manual (User specified)",
Type: schema.TypeString,
Computed: true,
},
"window": {
Description: "",
Description: "A list of maintenance windows for manual-mode",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"start_hour": {
Description: "",
Description: "What hour in the day (0-23) the window opens",
Type: schema.TypeInt,
Computed: true,
},
"duration_in_hours": {
Description: "",
Description: "How long the window is open",
Type: schema.TypeInt,
Computed: true,
},
"days": {
Description: "",
Description: "A list of weekdays on which the window is open ('Monday', 'Tuesday' etc)",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Expand Down
Loading

0 comments on commit 9a9a01c

Please sign in to comment.