Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving test account to staging #477

Merged
merged 6 commits into from
Apr 11, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/terraform_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ jobs:
- run: make testacc
if: steps.filter.outputs.code-changes == 'true'
env:
REDISCLOUD_ACCESS_KEY: ${{ secrets.REDISCLOUD_ACCESS_KEY_QA }}
REDISCLOUD_SECRET_KEY: ${{ secrets.REDISCLOUD_SECRET_KEY_QA }}
REDISCLOUD_URL: https://api-k8s-cloudapi.qa.redislabs.com/v1
AWS_TEST_CLOUD_ACCOUNT_NAME: "${{ secrets.AWS_TEST_CLOUD_ACCOUNT_NAME }}"
REDISCLOUD_ACCESS_KEY: ${{ secrets.REDISCLOUD_ACCESS_KEY_STAGING }}
REDISCLOUD_SECRET_KEY: ${{ secrets.REDISCLOUD_SECRET_KEY_STAGING }}
REDISCLOUD_URL: ${{ secrets.REDISCLOUD_URL_STAGING }}
AWS_TEST_CLOUD_ACCOUNT_NAME: "${{ secrets.AWS_TEST_CLOUD_ACCOUNT_NAME_STAGING }}"
AWS_PEERING_REGION: ${{ secrets.AWS_PEERING_REGION }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_VPC_CIDR: ${{ secrets.AWS_VPC_CIDR }}
Expand Down
10 changes: 6 additions & 4 deletions docs/resources/rediscloud_active_active_subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ description: |-
Creates an Active-Active Subscription within your Redis Enterprise Cloud Account.
This resource is responsible for creating and managing subscriptions.

~> **Note:** The creation_plan block allows the API server to create a well-optimised infrastructure for your databases in the cluster.
> **Note:** The payment_method property is ignored after Subscription creation.

> **Note:** The creation_plan block allows the API server to create a well-optimised infrastructure for your databases in the cluster.
The attributes inside the block are used by the provider to create initial
databases. Those databases will be deleted after provisioning a new
subscription, then the databases defined as separate resources will be attached to
Expand Down Expand Up @@ -71,7 +73,7 @@ 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

~> **Note:** If changes are made to attributes in the subscription which require the subscription to be recreated (such as `cloud_provider` or `payment_method`), 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.
> **Note:** If changes are made to attributes in the subscription which require the subscription to be recreated (such as `cloud_provider` or `payment_method`), 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.


### Timeouts
Expand All @@ -90,8 +92,8 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d
$ terraform import rediscloud_active_active_subscription.subscription-resource 12345678
```

~> **Note:** the creation_plan block will be ignored during imports.
> **Note:** the payment_method property and creation_plan block will be ignored during imports.

~> **Note:** when importing an existing Subscription, upon providing a `redis_version`, Terraform will always try to
> **Note:** when importing an existing Subscription, upon providing a `redis_version`, Terraform will always try to
recreatethe resource. The API doesn't return this value, so we can't detect changes between states.

44 changes: 23 additions & 21 deletions docs/resources/rediscloud_subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ description: |-
Creates a Flexible Subscription within your Redis Enterprise Cloud Account.
This resource is responsible for creating and managing subscriptions.

~> **Note:** The creation_plan block allows the API server to create a well-optimised infrastructure for your databases in the cluster.
> **Note:** The payment_method property is ignored after Subscription creation.

> **Note:** The creation_plan block allows the API server to create a well-optimised infrastructure for your databases in the cluster.
The attributes inside the block are used by the provider to create initial
databases. Those databases will be deleted after provisioning a new
subscription, then the databases defined as separate resources will be attached to
Expand All @@ -26,31 +28,31 @@ data "rediscloud_payment_method" "card" {

resource "rediscloud_subscription" "subscription-resource" {

name = "subscription-name"
payment_method = "credit-card"
name = "subscription-name"
payment_method = "credit-card"
payment_method_id = data.rediscloud_payment_method.card.id
memory_storage = "ram"
redis_version = "latest"
memory_storage = "ram"
redis_version = "latest"

cloud_provider {
provider = data.rediscloud_cloud_account.account.provider_type
region {
region = "eu-west-1"
multiple_availability_zones = true
networking_deployment_cidr = "10.0.0.0/24"
region = "eu-west-1"
multiple_availability_zones = true
networking_deployment_cidr = "10.0.0.0/24"
preferred_availability_zones = ["euw1-az1", "euw1-az2", "euw1-az3"]
}
}

// This block needs to be defined for provisioning a new subscription.
// This allows creation of a well-optimized hardware specification for databases in the cluster
creation_plan {
memory_limit_in_gb = 15
quantity = 1
replication= true
throughput_measurement_by = "operations-per-second"
memory_limit_in_gb = 15
quantity = 1
replication = true
throughput_measurement_by = "operations-per-second"
throughput_measurement_value = 20000
modules = ["RedisJSON"]
modules = ["RedisJSON"]
}
}
```
Expand All @@ -73,7 +75,7 @@ The `allowlist` block supports:
* `security_group_ids` - (Required) Set of security groups that are allowed to access the databases associated with this subscription
* `cidrs` - (Optional) Set of CIDR ranges that are allowed to access the databases associated with this subscription

~> **Note:** `allowlist` is only available when you run on your own cloud account, and not one that Redis provided (i.e `cloud_account_id` != 1)
> **Note:** `allowlist` is only available when you run on your own cloud account, and not one that Redis provided (i.e `cloud_account_id` != 1)

The `cloud_provider` block supports:

Expand All @@ -86,8 +88,8 @@ only with Redis Labs internal cloud account
The `creation_plan` block supports:

* `memory_limit_in_gb` - (Required) Maximum memory usage that will be used for your largest planned database.
* `modules` - (Optional) a list of modules that will be used by the databases in this subscription. Not currently compatible with ‘ram-and-flash’ memory storage.
Example: `modules = ["RedisJSON", RedisBloom"]`
* `modules` - (Optional) a list of modules that will be used by the databases in this subscription. Not currently compatible with ‘ram-and-flash’ memory storage.
Example: `modules = ["RedisJSON", "RediSearch", "RedisTimeSeries", "RedisBloom"]`
* `support_oss_cluster_api` - (Optional) Support Redis open-source (OSS) Cluster API. Default: ‘false’
* `replication` - (Optional) Databases replication. Default: ‘true’
* `quantity` - (Required) The planned number of databases in the subscription
Expand All @@ -97,9 +99,9 @@ Example: `modules = ["RedisJSON", RedisBloom"]`
Estimated average size (measured in bytes) of the items stored in the database. The value needs to
be the maximum average item size defined in one of your databases. Default: 1000

~>**Note:** If the number of modules exceeds the `quantity` then additional creation-plan databases will be created with the modules defined in the `modules` block.
> **Note:** If the number of modules exceeds the `quantity` then additional creation-plan databases will be created with the modules defined in the `modules` block.

~> **Note:** If changes are made to attributes in the subscription which require the subscription to be recreated (such as `memory_storage`, `cloud_provider` or `payment_method`), 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.
> **Note:** If changes are made to attributes in the subscription which require the subscription to be recreated (such as `memory_storage`, `cloud_provider` or `payment_method`), 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.

The cloud_provider `region` block supports:

Expand All @@ -111,7 +113,7 @@ The cloud_provider `region` block supports:
within the hosting account. **Modifying this attribute will force creation of a new resource.**
* `preferred_availability_zones` - (Optional) Availability zones deployment preferences (for the selected provider & region). If multiple_availability_zones is set to 'true', select three availability zones from the list. If you don't want to specify preferred availability zones, set this attribute to an empty list ('[]'). **Modifying this attribute will force creation of a new resource.**

~> **Note:** The preferred_availability_zones parameter is required for Terraform, but is optional within the Redis Enterprise Cloud UI.
> **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"]`).

### Timeouts
Expand Down Expand Up @@ -141,7 +143,7 @@ The `networks` block has these attributes:
```
$ terraform import rediscloud_subscription.subscription-resource 12345678
```
~> **Note:** the creation_plan block will be ignored during imports.
> **Note:** the payment_method property and creation_plan block will be ignored during imports.

~> **Note:** when importing an existing Subscription, upon providing a `redis_version`, Terraform will always try to
> **Note:** when importing an existing Subscription, upon providing a `redis_version`, Terraform will always try to
recreate the resource. The API doesn't return this value, so we can't detect changes between states.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/bflad/tfproviderlint v0.29.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.28.0
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
)

require (
Expand Down
6 changes: 3 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
Expand Down
10 changes: 8 additions & 2 deletions provider/resource_rediscloud_active_active_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,18 @@ func resourceRedisCloudActiveActiveSubscription() *schema.Resource {
Optional: true,
},
"payment_method": {
Description: "Payment method for the requested subscription. If credit card is specified, the payment method Id must be defined.",
Description: "Payment method for the requested subscription. If credit card is specified, the payment method id must be defined. This information is only used when creating a new subscription and any changes will be ignored after this.",
Type: schema.TypeString,
ForceNew: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringMatch(regexp.MustCompile("^(credit-card|marketplace)$"), "must be 'credit-card' or 'marketplace'")),
Optional: true,
Default: "credit-card",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
if d.Id() == "" {
// We don't want to ignore the block if the resource is about to be created.
return false
}
return true
},
},
"payment_method_id": {
Computed: true,
Expand Down
44 changes: 43 additions & 1 deletion provider/resource_rediscloud_active_active_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestAccResourceRedisCloudActiveActiveSubscription_CRUDI(t *testing.T) {
Config: fmt.Sprintf(testAccResourceRedisCloudActiveActiveSubscription, name),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "payment_method", "credit-card"),
resource.TestCheckResourceAttr(resourceName, "cloud_provider", "AWS"),
resource.TestCheckResourceAttr(resourceName, "creation_plan.#", "1"),
resource.TestCheckResourceAttr(resourceName, "creation_plan.0.memory_limit_in_gb", "1"),
Expand Down Expand Up @@ -86,10 +87,21 @@ func TestAccResourceRedisCloudActiveActiveSubscription_CRUDI(t *testing.T) {
),
},
{
// Checks if the creation_plan block is ignored after the IMPORT operation.
// Checks if the changes to the payment_method are ignored.
Config: fmt.Sprintf(testAccResourceRedisCloudActiveActiveSubscriptionChangedPaymentMethod, name),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "payment_method", "credit-card"),
),
},
{
// Checks if the payment_method and creation_plan block are ignored after the IMPORT operation.
ResourceName: resourceName,
ImportState: true,
ImportStateCheck: func(states []*terraform.InstanceState) error {
paymentMethod, ok := states[0].Attributes["payment_method"]
if ok && paymentMethod != "credit-card" {
return fmt.Errorf("Unexpected payment_method block. Should be 'credit-card', instead of %s", paymentMethod)
}
creationPlan, ok := states[0].Attributes["creation_plan.#"]
if ok && creationPlan != "0" {
return fmt.Errorf("Unexpected creation_plan block. Should be 0, instead of %s", creationPlan)
Expand Down Expand Up @@ -255,6 +267,36 @@ const testAccResourceRedisCloudActiveActiveSubscriptionNoCreationPlan = `
}
`

const testAccResourceRedisCloudActiveActiveSubscriptionChangedPaymentMethod = `
data "rediscloud_payment_method" "card" {
card_type = "Visa"
}

resource "rediscloud_active_active_subscription" "example" {
name = "%s"
payment_method = "marketplace"
payment_method_id = data.rediscloud_payment_method.card.id
cloud_provider = "AWS"

creation_plan {
memory_limit_in_gb = 1
quantity = 1
region {
region = "us-east-1"
networking_deployment_cidr = "192.168.0.0/24"
write_operations_per_second = 1000
read_operations_per_second = 1000
}
region {
region = "us-east-2"
networking_deployment_cidr = "10.0.1.0/24"
write_operations_per_second = 1000
read_operations_per_second = 1000
}
}
}
`

const testAccResourceRedisCloudActiveActiveSubscriptionContractPayment = `

resource "rediscloud_active_active_subscription" "example" {
Expand Down
10 changes: 8 additions & 2 deletions provider/resource_rediscloud_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,18 @@ func resourceRedisCloudSubscription() *schema.Resource {
Optional: true,
},
"payment_method": {
Description: "Payment method for the requested subscription. If credit card is specified, the payment method Id must be defined.",
Description: "Payment method for the requested subscription. If credit card is specified, the payment method id must be defined. This information is only used when creating a new subscription and any changes will be ignored after this.",
Type: schema.TypeString,
ForceNew: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringMatch(regexp.MustCompile("^(credit-card|marketplace)$"), "must be 'credit-card' or 'marketplace'")),
Optional: true,
Default: "credit-card",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
if d.Id() == "" {
// We don't want to ignore the block if the resource is about to be created.
return false
}
return true
},
},
"payment_method_id": {
Computed: true,
Expand Down
55 changes: 54 additions & 1 deletion provider/resource_rediscloud_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestAccResourceRedisCloudSubscription_CRUDI(t *testing.T) {
Config: fmt.Sprintf(testAccResourceRedisCloudSubscription, testCloudAccountName, name),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "payment_method", "credit-card"),
resource.TestCheckResourceAttr(resourceName, "cloud_provider.0.provider", "AWS"),
resource.TestCheckResourceAttr(resourceName, "cloud_provider.0.region.0.preferred_availability_zones.#", "1"),
resource.TestCheckResourceAttrSet(resourceName, "cloud_provider.0.region.0.networks.0.networking_subnet_id"),
Expand Down Expand Up @@ -93,10 +94,21 @@ func TestAccResourceRedisCloudSubscription_CRUDI(t *testing.T) {
),
},
{
// Checks if the creation_plan block is ignored after the IMPORT operation.
// Checks if the changes to the payment_method are ignored.
Config: fmt.Sprintf(testAccResourceRedisCloudSubscriptionChangedPaymentMethod, testCloudAccountName, name),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "payment_method", "credit-card"),
),
},
{
// Checks if the payment_method and creation_plan block are ignored after the IMPORT operation.
ResourceName: resourceName,
ImportState: true,
ImportStateCheck: func(states []*terraform.InstanceState) error {
paymentMethod, ok := states[0].Attributes["payment_method"]
if ok && paymentMethod != "credit-card" {
return fmt.Errorf("Unexpected payment_method block. Should be 'credit-card', instead of %s", paymentMethod)
}
creationPlan, ok := states[0].Attributes["creation_plan.#"]
if ok && creationPlan != "0" {
return fmt.Errorf("Unexpected creation_plan block. Should be 0, instead of %s", creationPlan)
Expand Down Expand Up @@ -560,6 +572,7 @@ data "rediscloud_cloud_account" "account" {
resource "rediscloud_subscription" "example" {

name = "%s"
payment_method = "credit-card"
payment_method_id = data.rediscloud_payment_method.card.id
memory_storage = "ram"

Expand Down Expand Up @@ -757,6 +770,46 @@ resource "rediscloud_subscription" "example" {
}
`

const testAccResourceRedisCloudSubscriptionChangedPaymentMethod = `
data "rediscloud_cloud_account" "account" {
exclude_internal_account = true
provider_type = "AWS"
name = "%s"
}

resource "rediscloud_subscription" "example" {

name = "%s"
payment_method = "marketplace"
memory_storage = "ram"

allowlist {
cidrs = ["192.168.0.0/16"]
security_group_ids = []
}

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 {
memory_limit_in_gb = 1
quantity = 1
replication=false
support_oss_cluster_api=false
throughput_measurement_by = "operations-per-second"
throughput_measurement_value = 10000
modules = ["RedisJSON", "RedisBloom"]
}
}
`

const testAccResourceRedisCloudSubscriptionContractPayment = `

data "rediscloud_cloud_account" "account" {
Expand Down
Loading