Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/terraform_provider_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ jobs:
go-version-file: go.mod
- run: EXECUTE_TESTS=true make testacc TESTARGS='-run="TestAcc(DataSource|Resource)RedisCloud(TransitGatewayAttachment|PaymentMethod).*"'

go_unit_test:
name: go unit test
needs: [go_build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
- run: go test ./... -run="^TestUnit" # Runs tests starting with TestUnit

tfproviderlint:
name: tfproviderlint
needs: [go_build]
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/terraform_provider_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ jobs:
- run: EXECUTE_TESTS=true make testacc TESTARGS='-run="TestAccResourceRedisCloudPrivateLink_CRUDI"'


go_unit_test:
name: go unit test
needs: [go_build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
- run: go test ./... -run="^TestUnit" # Runs tests starting with TestUnit

tfproviderlint:
name: tfproviderlint
needs: [go_build]
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file.
See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)


# 2.4.4 (3rd October 2025)

## Changed:
- Fixed AA endpoint script calling wrong method
- Fixed connection flattening not aligning to schema

# 2.4.3 (1st October 2025)

## Added:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func DataSourceActiveActivePrivateLinkEndpointScript() *schema.Resource {
return &schema.Resource{
Description: "The Active Active PrivateLink Endpoint Script data source allows users to request an endpoint script for an Active Active Subscription PrivateLink",
ReadContext: dataSourcePrivateLinkRead,
ReadContext: dataSourceActiveActivePrivateLinkScriptRead,

Schema: map[string]*schema.Schema{
"subscription_id": {
Expand Down
60 changes: 60 additions & 0 deletions provider/privatelink/testdata/private_link_update.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
locals {
rediscloud_subscription_name = "%s"
rediscloud_cloud_account = "%s"
rediscloud_private_link_share_name = "%s"
}

data "rediscloud_payment_method" "card" {
card_type = "Visa"
last_four_numbers = "5556"
}

data "rediscloud_cloud_account" "account" {
exclude_internal_account = true
provider_type = "AWS"
name = local.rediscloud_cloud_account
}

resource "rediscloud_subscription" "pro_subscription" {
name = local.rediscloud_subscription_name
payment_method_id = data.rediscloud_payment_method.card.id

cloud_provider {
provider = data.rediscloud_cloud_account.account.provider_type
cloud_account_id = data.rediscloud_cloud_account.account.id
region {
region = "eu-west-1"
networking_deployment_cidr = "10.0.0.0/24"
preferred_availability_zones = ["eu-west-1a"]
}
}

creation_plan {
dataset_size_in_gb = 15
quantity = 1
replication = true
throughput_measurement_by = "operations-per-second"
throughput_measurement_value = 20000
}
}

resource "rediscloud_private_link" "private_link" {
subscription_id = rediscloud_subscription.pro_subscription.id
share_name = local.rediscloud_private_link_share_name

# principal {
# principal = local.rediscloud_principal_1
# principal_type = "aws_account"
# principal_alias = "terraform test aws account"
# }

principal {
principal = "234567890123"
principal_type = "aws_account"
principal_alias = "terraform test aws account 2"
}
}

data "rediscloud_private_link" "private_link" {
subscription_id = rediscloud_private_link.private_link.subscription_id
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ locals {
rediscloud_subscription_name = "%s"
rediscloud_cloud_account = "%s"
rediscloud_private_link_share_name = "%s"
rediscloud_database_password = "%s"
}

data "rediscloud_payment_method" "card" {
Expand Down Expand Up @@ -38,6 +39,19 @@ resource "rediscloud_subscription" "pro_subscription" {
}
}

## this will give some connections and databases in the output
resource "rediscloud_subscription_database" "pro_database" {
subscription_id = rediscloud_subscription.pro_subscription.id
name = "db"
memory_limit_in_gb = 1
password = local.rediscloud_database_password
protocol = "redis"
data_persistence = "none"
throughput_measurement_by = "operations-per-second"
throughput_measurement_value = 10000
}


resource "rediscloud_private_link" "pro_private_link" {
subscription_id = rediscloud_subscription.pro_subscription.id
share_name = local.rediscloud_private_link_share_name
Expand Down
66 changes: 0 additions & 66 deletions provider/privatelink/testdata/testPrivateLinkUpdate.tf

This file was deleted.

2 changes: 1 addition & 1 deletion provider/privatelink/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func flattenConnections(connections []*pl.PrivateLinkConnection) []map[string]in
tf := map[string]interface{}{
"association_id": redis.StringValue(connection.AssociationId),
"connection_id": redis.StringValue(connection.ConnectionId),
"type": redis.StringValue(connection.Type),
"connection_type": redis.StringValue(connection.Type),
"owner_id": redis.StringValue(connection.OwnerId),
"association_date": redis.StringValue(connection.AssociationDate),
}
Expand Down
97 changes: 97 additions & 0 deletions provider/privatelink/utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package privatelink

import (
"testing"

"github.com/RedisLabs/rediscloud-go-api/redis"
pl "github.com/RedisLabs/rediscloud-go-api/service/privatelink"
"github.com/stretchr/testify/assert"
)

func TestUnitFlattenConnections(t *testing.T) {
// Test that flattenConnections produces keys that match the schema
connections := []*pl.PrivateLinkConnection{
{
AssociationId: redis.String("assoc-123"),
ConnectionId: redis.String("conn-456"),
Type: redis.String("vpc-endpoint"),
OwnerId: redis.String("owner-789"),
AssociationDate: redis.String("2024-01-01"),
},
}

result := flattenConnections(connections)

assert.Len(t, result, 1)

conn := result[0]
assert.Contains(t, conn, "association_id")
assert.Contains(t, conn, "connection_id")
assert.Contains(t, conn, "connection_type")
assert.Contains(t, conn, "owner_id")
assert.Contains(t, conn, "association_date")

assert.Equal(t, "assoc-123", conn["association_id"])
assert.Equal(t, "conn-456", conn["connection_id"])
assert.Equal(t, "vpc-endpoint", conn["connection_type"])
assert.Equal(t, "owner-789", conn["owner_id"])
assert.Equal(t, "2024-01-01", conn["association_date"])
}

func TestUnitFlattenConnectionsEmpty(t *testing.T) {
result := flattenConnections([]*pl.PrivateLinkConnection{})
assert.Len(t, result, 0)
}

func TestUnitFlattenDatabases(t *testing.T) {
databases := []*pl.PrivateLinkDatabase{
{
DatabaseId: redis.Int(12345),
Port: redis.Int(16379),
ResourceLinkEndpoint: redis.String("endpoint.example.com"),
},
}

result := flattenDatabases(databases)

assert.Len(t, result, 1)

db := result[0]
assert.Contains(t, db, "database_id")
assert.Contains(t, db, "port")
assert.Contains(t, db, "resource_link_endpoint")

assert.Equal(t, 12345, db["database_id"])
assert.Equal(t, 16379, db["port"])
assert.Equal(t, "endpoint.example.com", db["resource_link_endpoint"])
}

func TestUnitFlattenPrincipals(t *testing.T) {
principals := []*pl.PrivateLinkPrincipal{
{
Principal: redis.String("arn:aws:iam::123456789012:root"),
Type: redis.String("aws_account"),
Alias: redis.String("my-account"),
},
{
Principal: redis.String("arn:aws:iam::987654321098:root"),
Type: redis.String("aws_account"),
Alias: redis.String("another-account"),
},
}

result := flattenPrincipals(principals)

assert.Len(t, result, 2)

// Verify keys
for _, p := range result {
assert.Contains(t, p, "principal")
assert.Contains(t, p, "principal_type")
assert.Contains(t, p, "principal_alias")
}

// Results should be sorted by principal
assert.Equal(t, "arn:aws:iam::123456789012:root", result[0]["principal"])
assert.Equal(t, "arn:aws:iam::987654321098:root", result[1]["principal"])
}
10 changes: 5 additions & 5 deletions provider/rediscloud_active_active_private_link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

const testActiveActivePrivateLinkConfigFile = "./privatelink/testdata/testActiveActivePrivateLink.tf"
const testActiveActivePrivateLinkConfigFile = "../privatelink/testdata/active_active_private_link.tf"

func TestAccResourceRedisCloudActiveActivePrivateLink_CRUDI(t *testing.T) {

Expand Down Expand Up @@ -38,8 +38,8 @@ func TestAccResourceRedisCloudActiveActivePrivateLink_CRUDI(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "resource_configuration_id"),
resource.TestCheckResourceAttrSet(resourceName, "resource_configuration_arn"),
resource.TestCheckResourceAttrSet(resourceName, "share_arn"),
resource.TestCheckResourceAttr(resourceName, "connections.#", "0"),
resource.TestCheckResourceAttr(resourceName, "databases.#", "1"),
resource.TestCheckResourceAttrSet(resourceName, "connections.#"),
resource.TestCheckResourceAttrSet(resourceName, "databases.#"),

resource.TestCheckResourceAttrSet(datasourceName, "id"),
resource.TestCheckResourceAttrSet(datasourceName, "subscription_id"),
Expand All @@ -49,8 +49,8 @@ func TestAccResourceRedisCloudActiveActivePrivateLink_CRUDI(t *testing.T) {
resource.TestCheckResourceAttrSet(datasourceName, "resource_configuration_id"),
resource.TestCheckResourceAttrSet(datasourceName, "resource_configuration_arn"),
resource.TestCheckResourceAttrSet(datasourceName, "share_arn"),
resource.TestCheckResourceAttr(datasourceName, "connections.#", "0"),
resource.TestCheckResourceAttr(datasourceName, "databases.#", "1"),
resource.TestCheckResourceAttrSet(datasourceName, "connections.#"),
resource.TestCheckResourceAttrSet(datasourceName, "databases.#"),
),
},
{
Expand Down
14 changes: 8 additions & 6 deletions provider/rediscloud_private_link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

const testPrivateLinkConfigFile = "./privatelink/testdata/testPrivateLink.tf"
const testPrivateLinkConfigFile = "./privatelink/testdata/pro_private_link.tf"

func TestAccResourceRedisCloudPrivateLink_CRUDI(t *testing.T) {

Expand Down Expand Up @@ -39,8 +39,8 @@ func TestAccResourceRedisCloudPrivateLink_CRUDI(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "resource_configuration_id"),
resource.TestCheckResourceAttrSet(resourceName, "resource_configuration_arn"),
resource.TestCheckResourceAttrSet(resourceName, "share_arn"),
resource.TestCheckResourceAttr(resourceName, "connections.#", "0"),
resource.TestCheckResourceAttr(resourceName, "databases.#", "0"),
resource.TestCheckResourceAttrSet(resourceName, "connections.#"),
resource.TestCheckResourceAttr(resourceName, "databases.#", "1"),

resource.TestCheckResourceAttrSet(datasourceName, "id"),
resource.TestCheckResourceAttrSet(datasourceName, "subscription_id"),
Expand All @@ -49,8 +49,8 @@ func TestAccResourceRedisCloudPrivateLink_CRUDI(t *testing.T) {
resource.TestCheckResourceAttrSet(datasourceName, "resource_configuration_id"),
resource.TestCheckResourceAttrSet(datasourceName, "resource_configuration_arn"),
resource.TestCheckResourceAttrSet(datasourceName, "share_arn"),
resource.TestCheckResourceAttr(datasourceName, "connections.#", "0"),
resource.TestCheckResourceAttr(datasourceName, "databases.#", "0"),
resource.TestCheckResourceAttrSet(datasourceName, "connections.#"),
resource.TestCheckResourceAttr(datasourceName, "databases.#", "1"),

//resource.TestCheckResourceAttrSet(datasourceScriptName, "id"),
//resource.TestCheckResourceAttrSet(datasourceScriptName, "subscription_id"),
Expand All @@ -71,5 +71,7 @@ func getRedisPrivateLinkConfig(t *testing.T, shareName string) string {
exampleCloudAccountName := os.Getenv("AWS_TEST_CLOUD_ACCOUNT_NAME")

content := getTestConfig(t, testPrivateLinkConfigFile)
return fmt.Sprintf(content, subName, exampleCloudAccountName, shareName)
password := acctest.RandString(20)

return fmt.Sprintf(content, subName, exampleCloudAccountName, shareName, password)
}
Loading