Skip to content

Commit 2bc9b20

Browse files
committed
fix: fixing TGW parameters the wrong way around and acceptance tests for TGW
1 parent 7b6ae8b commit 2bc9b20

7 files changed

+224
-1
lines changed

.github/workflows/terraform_provider_pr.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ jobs:
124124
go-version-file: go.mod
125125
- run: EXECUTE_TESTS=true make testacc TESTARGS='-run="TestAccResourceRedisCloudActiveActiveDatabase_enableDefaultUser"'
126126

127+
go_test_smoke_aa_tgw_attachment:
128+
name: go test smoke aa tgw attachment
129+
needs: [go_build]
130+
runs-on: ubuntu-latest
131+
steps:
132+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
133+
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
134+
with:
135+
go-version-file: go.mod
136+
- run: EXECUTE_TESTS=true make testacc TESTARGS='-run="TestAccResourceRedisCloudActiveActiveTransitGatewayAttachment_CRUDI"'
137+
127138
go_test_smoke_essentials_sub:
128139
name: go test smoke essentials sub
129140
needs: [go_build]

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
88

99
## Fixed
1010
- `rediscloud_active_active_subscription_database`: Fixed issue where regional `enable_default_user` would incorrectly default to `false` instead of inheriting from `global_enable_default_user` when not explicitly specified in the region configuration.
11+
- `rediscloud_active_active_transit_gateway_attachment`: Fixed parameter order bug in update operation where `region_id` and `tgw_id` were swapped, causing "SUBSCRIPTION_INVALID_REGION_ID" errors when updating CIDRs.
1112

1213
## Testing
1314
- Added acceptance tests covering `enable_default_user` inheritance and override scenarios
15+
- Added acceptance test for `rediscloud_active_active_transit_gateway_attachment` resource lifecycle (Create/Read/Update/Delete/Import)
16+
- Added dedicated smoke test jobs in GitHub Actions for both `enable_default_user` and Transit Gateway attachment tests
1417

1518

1619
# 2.7.2 (3rd November 2025)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
data "rediscloud_payment_method" "card" {
2+
card_type = "Visa"
3+
last_four_numbers = "5556"
4+
}
5+
6+
data "rediscloud_cloud_account" "account" {
7+
exclude_internal_account = true
8+
provider_type = "AWS"
9+
name = "%s"
10+
}
11+
12+
resource "rediscloud_active_active_subscription" "test" {
13+
name = "%s"
14+
payment_method_id = data.rediscloud_payment_method.card.id
15+
cloud_provider = "AWS"
16+
17+
creation_plan {
18+
dataset_size_in_gb = 1
19+
quantity = 1
20+
region {
21+
region = "us-east-1"
22+
networking_deployment_cidr = "192.168.0.0/24"
23+
write_operations_per_second = 1000
24+
read_operations_per_second = 1000
25+
}
26+
region {
27+
region = "us-east-2"
28+
networking_deployment_cidr = "10.0.1.0/24"
29+
write_operations_per_second = 1000
30+
read_operations_per_second = 1000
31+
}
32+
}
33+
}
34+
35+
data "rediscloud_active_active_transit_gateway" "test" {
36+
subscription_id = rediscloud_active_active_subscription.test.id
37+
region_id = tolist(rediscloud_active_active_subscription.test.regions)[0].region_id
38+
aws_tgw_uid = "%s"
39+
}
40+
41+
resource "rediscloud_active_active_transit_gateway_attachment" "test" {
42+
subscription_id = rediscloud_active_active_subscription.test.id
43+
region_id = tolist(rediscloud_active_active_subscription.test.regions)[0].region_id
44+
tgw_id = data.rediscloud_active_active_transit_gateway.test.tgw_id
45+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
data "rediscloud_payment_method" "card" {
2+
card_type = "Visa"
3+
last_four_numbers = "5556"
4+
}
5+
6+
data "rediscloud_cloud_account" "account" {
7+
exclude_internal_account = true
8+
provider_type = "AWS"
9+
name = "%s"
10+
}
11+
12+
resource "rediscloud_active_active_subscription" "test" {
13+
name = "%s"
14+
payment_method_id = data.rediscloud_payment_method.card.id
15+
cloud_provider = "AWS"
16+
17+
creation_plan {
18+
dataset_size_in_gb = 1
19+
quantity = 1
20+
region {
21+
region = "us-east-1"
22+
networking_deployment_cidr = "192.168.0.0/24"
23+
write_operations_per_second = 1000
24+
read_operations_per_second = 1000
25+
}
26+
region {
27+
region = "us-east-2"
28+
networking_deployment_cidr = "10.0.1.0/24"
29+
write_operations_per_second = 1000
30+
read_operations_per_second = 1000
31+
}
32+
}
33+
}
34+
35+
data "rediscloud_active_active_transit_gateway" "test" {
36+
subscription_id = rediscloud_active_active_subscription.test.id
37+
region_id = tolist(rediscloud_active_active_subscription.test.regions)[0].region_id
38+
aws_tgw_uid = "%s"
39+
}
40+
41+
resource "rediscloud_active_active_transit_gateway_attachment" "test" {
42+
subscription_id = rediscloud_active_active_subscription.test.id
43+
region_id = tolist(rediscloud_active_active_subscription.test.regions)[0].region_id
44+
tgw_id = data.rediscloud_active_active_transit_gateway.test.tgw_id
45+
cidrs = ["10.10.20.0/24"]
46+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
data "rediscloud_payment_method" "card" {
2+
card_type = "Visa"
3+
last_four_numbers = "5556"
4+
}
5+
6+
data "rediscloud_cloud_account" "account" {
7+
exclude_internal_account = true
8+
provider_type = "AWS"
9+
name = "%s"
10+
}
11+
12+
resource "rediscloud_active_active_subscription" "test" {
13+
name = "%s"
14+
payment_method_id = data.rediscloud_payment_method.card.id
15+
cloud_provider = "AWS"
16+
17+
creation_plan {
18+
dataset_size_in_gb = 1
19+
quantity = 1
20+
region {
21+
region = "us-east-1"
22+
networking_deployment_cidr = "192.168.0.0/24"
23+
write_operations_per_second = 1000
24+
read_operations_per_second = 1000
25+
}
26+
region {
27+
region = "us-east-2"
28+
networking_deployment_cidr = "10.0.1.0/24"
29+
write_operations_per_second = 1000
30+
read_operations_per_second = 1000
31+
}
32+
}
33+
}
34+
35+
data "rediscloud_active_active_transit_gateway" "test" {
36+
subscription_id = rediscloud_active_active_subscription.test.id
37+
region_id = tolist(rediscloud_active_active_subscription.test.regions)[0].region_id
38+
aws_tgw_uid = "%s"
39+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package provider
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"regexp"
7+
"testing"
8+
9+
"github.com/RedisLabs/terraform-provider-rediscloud/provider/utils"
10+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
11+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
12+
)
13+
14+
// TestAccResourceRedisCloudActiveActiveTransitGatewayAttachment_CRUDI tests the basic lifecycle of an Active-Active TGW attachment.
15+
// Note: This test cannot verify successful CIDR updates because that requires manual acceptance of the attachment in the AWS console.
16+
func TestAccResourceRedisCloudActiveActiveTransitGatewayAttachment_CRUDI(t *testing.T) {
17+
utils.AccRequiresEnvVar(t, "EXECUTE_TESTS")
18+
19+
testCloudAccountName := os.Getenv("AWS_TEST_CLOUD_ACCOUNT_NAME")
20+
testTgwId := os.Getenv("AWS_TEST_TGW_ID")
21+
subscriptionName := acctest.RandomWithPrefix(testResourcePrefix) + "-aa-tgwa"
22+
23+
const resourceName = "rediscloud_active_active_transit_gateway_attachment.test"
24+
const datasourceName = "data.rediscloud_active_active_transit_gateway.test"
25+
26+
resource.ParallelTest(t, resource.TestCase{
27+
PreCheck: func() { testAccPreCheck(t); testAccAwsPreExistingTgwCheck(t) },
28+
ProviderFactories: providerFactories,
29+
CheckDestroy: testAccCheckActiveActiveSubscriptionDestroy,
30+
Steps: []resource.TestStep{
31+
// Step 1: Read TGW datasource before attachment
32+
{
33+
Config: fmt.Sprintf(
34+
utils.GetTestConfig(t, "./activeactive/testdata/transit_gateway_datasource.tf"),
35+
testCloudAccountName, subscriptionName, testTgwId),
36+
Check: resource.ComposeAggregateTestCheckFunc(
37+
resource.TestCheckResourceAttrSet(datasourceName, "id"),
38+
resource.TestCheckResourceAttr(datasourceName, "aws_tgw_uid", testTgwId),
39+
resource.TestCheckResourceAttr(datasourceName, "attachment_uid", ""),
40+
resource.TestCheckResourceAttr(datasourceName, "status", "available"),
41+
resource.TestCheckResourceAttr(datasourceName, "attachment_status", ""),
42+
resource.TestCheckResourceAttrSet(datasourceName, "aws_account_id"),
43+
resource.TestCheckResourceAttr(datasourceName, "cidrs.#", "0"),
44+
),
45+
},
46+
// Step 2: Create TGW attachment (will be pending-acceptance)
47+
{
48+
Config: fmt.Sprintf(
49+
utils.GetTestConfig(t, "./activeactive/testdata/transit_gateway_attachment.tf"),
50+
testCloudAccountName, subscriptionName, testTgwId),
51+
Check: resource.ComposeAggregateTestCheckFunc(
52+
resource.TestCheckResourceAttrSet(resourceName, "id"),
53+
resource.TestCheckResourceAttr(resourceName, "aws_tgw_uid", testTgwId),
54+
resource.TestCheckResourceAttrSet(resourceName, "attachment_uid"),
55+
resource.TestCheckResourceAttr(resourceName, "status", "available"),
56+
resource.TestCheckResourceAttr(resourceName, "attachment_status", "pending-acceptance"),
57+
resource.TestCheckResourceAttrSet(resourceName, "aws_account_id"),
58+
resource.TestCheckResourceAttrSet(resourceName, "region_id"),
59+
resource.TestCheckResourceAttrSet(resourceName, "tgw_id"),
60+
resource.TestCheckResourceAttr(resourceName, "cidrs.#", "0"),
61+
),
62+
},
63+
// Step 3: Test import
64+
{
65+
ResourceName: resourceName,
66+
ImportState: true,
67+
ImportStateVerify: true,
68+
},
69+
// Step 4: Verify CIDRs cannot be added while pending-acceptance
70+
// This is expected behaviour - attachment must be accepted first
71+
{
72+
Config: fmt.Sprintf(
73+
utils.GetTestConfig(t, "./activeactive/testdata/transit_gateway_attachment_with_cidrs.tf"),
74+
testCloudAccountName, subscriptionName, testTgwId),
75+
ExpectError: regexp.MustCompile("Transit Gateway attachment is not active|SUBSCRIPTION_INVALID_REGION_ID"),
76+
},
77+
},
78+
})
79+
}

provider/resource_rediscloud_active_active_transit_gateway_attachment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func resourceRedisCloudActiveActiveTransitGatewayAttachmentUpdate(ctx context.Co
182182
cidrs = make([]*string, 0)
183183
}
184184

185-
err = api.Client.TransitGatewayAttachments.UpdateActiveActive(ctx, subId, tgwId, regionId, cidrs)
185+
err = api.Client.TransitGatewayAttachments.UpdateActiveActive(ctx, subId, regionId, tgwId, cidrs)
186186
if err != nil {
187187
return diag.FromErr(err)
188188
}

0 commit comments

Comments
 (0)