├── tools └── tools.go ├── .github ├── CODE_OF_CONDUCT.md ├── dependabot.yml ├── actions │ └── run-testacc │ │ └── action.yml ├── workflows │ ├── release.yml │ └── codeql-analysis.yml └── ISSUE_TEMPLATE.md ├── .editorconfig ├── provider ├── utils │ ├── test_utils.go │ ├── utils_test.go │ ├── mutex.go │ └── get_set.go ├── client │ └── client.go ├── activeactive │ └── testdata │ │ ├── subscription_changed_payment_method_redis7.tf │ │ ├── auto_minor_version_upgrade.tf │ │ ├── public_endpoint_enabled_default_source_ips.tf │ │ ├── public_endpoint_disabled_default_source_ips.tf │ │ ├── subscription_update.tf │ │ ├── subscription_import_redis8.tf │ │ ├── subscription_import_redis7.tf │ │ ├── subscription_update_redis7.tf │ │ ├── public_endpoint_disabled.tf │ │ ├── public_endpoint_enabled.tf │ │ ├── subscription_update_redis8.tf │ │ ├── active_active_sub.tf │ │ ├── active_active_sub_redis8.tf │ │ └── active_active_sub_redis7.tf ├── essentials │ └── testdata │ │ ├── essentials_database_basic.tf │ │ ├── essentials_database_updated_version.tf │ │ └── essentials_database_redis_version.tf ├── psc │ └── testdata │ │ └── testPrivateServiceConnect1.tf ├── pro │ ├── testdata │ │ ├── pro_subscription_boilerplate.tf │ │ ├── pro_database_no_password.tf │ │ ├── pro_subscription_redis8.tf │ │ ├── pro_database_optional_attributes.tf │ │ ├── pro_database_resp_versions.tf │ │ ├── pro_subscription_redis7.tf │ │ ├── pro_database_invalid_time_utc.tf │ │ ├── pro_database_redis_8_with_modules.tf │ │ ├── pro_database_update_destroy_alerts.tf │ │ ├── pro_subscription_data_source.tf │ │ ├── pro_database_update.tf │ │ ├── pro_database_auto_minor_version_upgrade.tf │ │ ├── pro_subscription_public_endpoint_disabled.tf │ │ ├── pro_database.tf │ │ ├── pro_database_upgrade.tf │ │ ├── pro_subscription_public_endpoint_enabled.tf │ │ ├── pro_database_multi_modules.tf │ │ ├── pro_database_redis_7.tf │ │ ├── pro_database_redis_8.tf │ │ ├── active_active_database_with_pro_data_source.tf │ │ ├── pro_database_with_replica.tf │ │ └── pro_database_data_source.tf │ └── utils.go ├── datasource_rediscloud_payment_method_test.go ├── datasource_rediscloud_acl_rule_test.go ├── datasource_rediscloud_data_persistence_test.go ├── datasource_rediscloud_database_modules_test.go ├── datasource_rediscloud_cloud_account_test.go ├── privatelink │ ├── testdata │ │ ├── private_link_update.tf │ │ ├── pro_private_link.tf │ │ └── active_active_private_link.tf │ ├── datasource_rediscloud_active_active_endpoint_script.go │ ├── datasource_rediscloud_endpoint_script.go │ └── utils_test.go ├── transitgateway │ ├── helpers.go │ └── datasource_rediscloud_active_active_transit_gateway_invitations.go ├── datasource_rediscloud_database_modules.go ├── provider_test.go ├── datasource_rediscloud_data_persistence.go ├── datasource_rediscloud_private_service_connect.go ├── datasource_rediscloud_acl_user.go ├── datasource_rediscloud_active_active_private_service_connect.go ├── datasource_rediscloud_acl_rule.go └── resource_rediscloud_cloud_account_test.go ├── scripts └── generate-dev-overrides.sh ├── .gitignore ├── docs ├── data-sources │ ├── rediscloud_acl_user.md │ ├── rediscloud_acl_rule.md │ ├── rediscloud_database_modules.md │ ├── rediscloud_private_service_connect.md │ ├── rediscloud_data_persistence.md │ ├── rediscloud_acl_role.md │ ├── rediscloud_active_active_private_service_connect.md │ ├── rediscloud_transit_gateway.md │ ├── rediscloud_transit_gateway_invitations.md │ ├── rediscloud_regions.md │ ├── rediscloud_active_active_transit_gateway.md │ ├── rediscloud_essentials_subscription.md │ ├── rediscloud_active_active_transit_gateway_invitations.md │ ├── rediscloud_payment_method.md │ ├── rediscloud_active_active_subscription_regions.md │ ├── rediscloud_cloud_account.md │ ├── rediscloud_private_service_connect_endpoints.md │ ├── rediscloud_private_link.md │ ├── rediscloud_subscription_peerings.md │ ├── rediscloud_active_active_private_service_connect_endpoints.md │ ├── rediscloud_active_active_private_link.md │ └── rediscloud_active_active_subscription.md ├── resources │ ├── rediscloud_private_service_connect.md │ ├── rediscloud_private_service_connect_endpoint_accepter.md │ ├── rediscloud_active_active_private_service_connect.md │ ├── rediscloud_active_active_private_service_connect_endpoint_accepter.md │ ├── rediscloud_acl_rule.md │ ├── rediscloud_acl_user.md │ ├── rediscloud_transit_gateway_attachment.md │ ├── rediscloud_active_active_transit_gateway_attachment.md │ ├── rediscloud_transit_gateway_invitation_acceptor.md │ ├── rediscloud_essentials_subscription.md │ ├── rediscloud_active_active_transit_gateway_invitation_acceptor.md │ ├── rediscloud_acl_role.md │ └── rediscloud_cloud_account.md └── index.md ├── main.go ├── .goreleaser.yml ├── GNUmakefile └── RELEASE_PROCESS.md /tools/tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | // +build tools 3 | 4 | package tools 5 | 6 | import ( 7 | // linter specifically for TF plugins 8 | _ "github.com/bflad/tfproviderlint/cmd/tfproviderlint" 9 | _ "github.com/bflad/tfproviderlint/cmd/tfproviderlintx" 10 | ) 11 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | Redis Labs Community Guidelines apply to you when interacting with the community here on GitHub and contributing code. 4 | 5 | Please read the full text at https://redislabs.com/community/community-guidelines-code-of-conduct/ 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | # Unix-style newlines with a newline ending every file 4 | [*] 5 | indent_style = space 6 | end_of_line = lf 7 | insert_final_newline = true 8 | charset = utf-8 9 | indent_size = 2 10 | 11 | [*.go] 12 | indent_style = tab 13 | indent_size = 4 14 | 15 | [Makefile] 16 | indent_style = tab -------------------------------------------------------------------------------- /provider/utils/test_utils.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | ) 7 | 8 | func AccRequiresEnvVar(t *testing.T, envVarName string) string { 9 | envVarValue := os.Getenv(envVarName) 10 | if envVarValue == "" || envVarValue == "false" { 11 | t.Skipf("Skipping test because %s is not set.", envVarName) 12 | } 13 | return envVarValue 14 | } 15 | 16 | func GetTestConfig(t *testing.T, testFile string) string { 17 | content, err := os.ReadFile(testFile) 18 | if err != nil { 19 | t.Fatalf("failed to read file: %v", err) 20 | } 21 | 22 | return string(content) 23 | } 24 | -------------------------------------------------------------------------------- /scripts/generate-dev-overrides.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BIN_DIR=$PWD/bin 4 | OVERRIDES_FILENAME=developer_overrides.tfrc 5 | 6 | cat << EOF > $BIN_DIR/$OVERRIDES_FILENAME 7 | provider_installation { 8 | 9 | dev_overrides { 10 | "RedisLabs/rediscloud" = "$BIN_DIR" 11 | } 12 | 13 | direct {} 14 | } 15 | EOF 16 | 17 | echo "" 18 | echo "A development overrides file has been generated at ./bin/$OVERRIDES_FILENAME." 19 | echo "To make Terraform temporarily use your locally built version of the provider, set TF_CLI_CONFIG_FILE within your terminal" 20 | echo "" 21 | printf '\texport TF_CLI_CONFIG_FILE=%s' "$BIN_DIR/$OVERRIDES_FILENAME" 22 | echo "" 23 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # See GitHub's docs for more information on this file: 2 | # https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates 3 | version: 2 4 | updates: 5 | # Maintain dependencies for GitHub Actions 6 | - package-ecosystem: "github-actions" 7 | directory: "/" 8 | schedule: 9 | # Check for updates to GitHub Actions every weekday 10 | interval: "daily" 11 | 12 | # Maintain dependencies for Go modules 13 | - package-ecosystem: "gomod" 14 | directory: "/" 15 | schedule: 16 | # Check for updates to Go modules every weekday 17 | interval: "daily" 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.dll 2 | *.exe 3 | .DS_Store 4 | example.tf 5 | terraform.tfplan 6 | terraform.tfstate 7 | bin/ 8 | dist/ 9 | terraform-plugin-dir/ 10 | .envrc 11 | modules-dev/ 12 | /pkg/ 13 | playground/ 14 | website/.vagrant 15 | website/.bundle 16 | website/build 17 | website/node_modules 18 | .vagrant/ 19 | *.backup 20 | ./*.tfstate 21 | .terraform/ 22 | *.log 23 | *.bak 24 | *~ 25 | .*.swp 26 | .idea 27 | *.iml 28 | *.test 29 | *.iml 30 | 31 | website/vendor 32 | vendor 33 | .vscode/ 34 | .claude/ 35 | CLAUDE.md 36 | 37 | # Test exclusions 38 | !command/test-fixtures/**/*.tfstate 39 | !command/test-fixtures/**/.terraform/ 40 | 41 | # Keep windows files with windows line endings 42 | *.winfile eol=crlf 43 | .claude 44 | -------------------------------------------------------------------------------- /provider/utils/utils_test.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestIsTime(t *testing.T) { 9 | tests := []struct { 10 | input string 11 | errors bool 12 | }{ 13 | {"0:00", false}, 14 | {"09:00", false}, 15 | {"12:00", false}, 16 | {"24:00", true}, // '24' isn't a valid hour 17 | {"12:00:00", true}, // seconds are invalid 18 | {"blah", true}, // Not a valid time 19 | {"", true}, // Nothing 20 | } 21 | 22 | for _, test := range tests { 23 | t.Run(test.input, func(t *testing.T) { 24 | actual := IsTime()(test.input, nil) 25 | assert.Equal(t, test.errors, actual.HasError(), "%+v", actual) 26 | }) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /.github/actions/run-testacc/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Run Acceptance Tests' 2 | description: 'Run acceptance tests with validation that tests actually ran' 3 | inputs: 4 | test_pattern: 5 | description: 'Test pattern to pass to -run flag' 6 | required: true 7 | runs: 8 | using: 'composite' 9 | steps: 10 | - name: Run tests 11 | shell: bash 12 | env: 13 | TEST_PATTERN: ${{ inputs.test_pattern }} 14 | run: | 15 | set -o pipefail 16 | EXECUTE_TESTS=true make testacc TESTARGS="-run=\"$TEST_PATTERN\"" 2>&1 | tee test_output.txt 17 | if ! grep -q "=== RUN" test_output.txt; then 18 | echo "ERROR: No tests matched the pattern. Please check the -run argument." 19 | exit 1 20 | fi 21 | -------------------------------------------------------------------------------- /provider/client/client.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "os" 5 | 6 | rediscloudApi "github.com/RedisLabs/rediscloud-go-api" 7 | ) 8 | 9 | type ApiClient struct { 10 | Client *rediscloudApi.Client 11 | } 12 | 13 | // NewClient creates a new ApiClient using environment variables for configuration. 14 | // This is useful for tests that need to create a client before the provider is configured. 15 | func NewClient() (*ApiClient, error) { 16 | var config []rediscloudApi.Option 17 | 18 | url := os.Getenv("REDISCLOUD_URL") 19 | if url != "" { 20 | config = append(config, rediscloudApi.BaseURL(url)) 21 | } 22 | 23 | client, err := rediscloudApi.NewClient(config...) 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | return &ApiClient{ 29 | Client: client, 30 | }, nil 31 | } 32 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_acl_user.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_acl_user" 4 | description: |- 5 | ACL User data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_acl_user 9 | 10 | The User data source allows access to an existing Rule within your Redis Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_acl_user" "example" { 16 | name = "fast-admin-john" 17 | } 18 | 19 | output "rediscloud_acl_user" { 20 | value = data.rediscloud_acl_user.example.id 21 | } 22 | ``` 23 | 24 | ## Argument Reference 25 | 26 | * `name` - (Required) The name of the User to filter returned subscriptions 27 | 28 | ## Attribute reference 29 | 30 | * `id` - Identifier of the found User. 31 | * `name` - The User's name. 32 | * `role` - The name of the User's Role. 33 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "log" 6 | 7 | "github.com/RedisLabs/terraform-provider-rediscloud/provider" 8 | "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" 9 | ) 10 | 11 | var ( 12 | // Provided by goreleaser configuration for each binary 13 | // Allows goreleaser to pass version details 14 | version = "dev" 15 | ) 16 | 17 | func main() { 18 | var debugMode bool 19 | 20 | flag.BoolVar(&debugMode, "debug", false, "set to true to run the provider with support for debuggers like delve") 21 | flag.Parse() 22 | 23 | opts := &plugin.ServeOpts{ProviderFunc: provider.New(version)} 24 | 25 | // Prevent logger from prepending date/time to logs, which breaks log-level parsing/filtering 26 | log.SetFlags(0) 27 | 28 | if debugMode { 29 | opts.Debug = true 30 | opts.ProviderAddr = "RedisLabs/rediscloud" 31 | } 32 | 33 | plugin.Serve(opts) 34 | } 35 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/subscription_changed_payment_method_redis7.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | subscription_name = "%s" 3 | } 4 | 5 | resource "rediscloud_active_active_subscription" "example" { 6 | name = local.subscription_name 7 | payment_method = "marketplace" 8 | cloud_provider = "AWS" 9 | redis_version = "7.4" 10 | 11 | creation_plan { 12 | memory_limit_in_gb = 1 13 | quantity = 1 14 | region { 15 | region = "us-east-1" 16 | networking_deployment_cidr = "192.168.0.0/24" 17 | write_operations_per_second = 1000 18 | read_operations_per_second = 1000 19 | } 20 | region { 21 | region = "us-east-2" 22 | networking_deployment_cidr = "10.0.1.0/24" 23 | write_operations_per_second = 1000 24 | read_operations_per_second = 1000 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /provider/utils/mutex.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import "sync" 4 | 5 | // Lock that must be acquired when modifying something related to a subscription as only one _thing_ can modify a subscription and all sub-resources at any time 6 | var SubscriptionMutex = newPerIdLock() 7 | 8 | func newPerIdLock() *perIdLock { 9 | return &perIdLock{ 10 | store: map[int]*sync.Mutex{}, 11 | } 12 | } 13 | 14 | type perIdLock struct { 15 | lock sync.Mutex 16 | store map[int]*sync.Mutex 17 | } 18 | 19 | func (m *perIdLock) Lock(id int) { 20 | m.get(id).Lock() 21 | } 22 | 23 | func (m *perIdLock) Unlock(id int) { 24 | m.get(id).Unlock() 25 | } 26 | 27 | func (m *perIdLock) get(id int) *sync.Mutex { 28 | m.lock.Lock() 29 | defer m.lock.Unlock() 30 | 31 | if v, ok := m.store[id]; ok { 32 | return v 33 | } 34 | 35 | mutex := &sync.Mutex{} 36 | m.store[id] = mutex 37 | return mutex 38 | } 39 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_acl_rule.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_acl_rule" 4 | description: |- 5 | ACL Rule data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_acl_rule 9 | 10 | The Rule (a.k.a Redis Rule, Redis ACL) data source allows access to an existing Rule within your Redis Enterprise Cloud 11 | Account. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | data "rediscloud_acl_rule" "example" { 17 | name = "cache-reader-rule" 18 | } 19 | 20 | output "rediscloud_acl_rule" { 21 | value = data.rediscloud_acl_rule.example.id 22 | } 23 | ``` 24 | 25 | ## Argument Reference 26 | 27 | * `name` - (Required) The name of the Rule to filter returned subscriptions 28 | 29 | ## Attribute reference 30 | 31 | * `id` - Identifier of the found Rule. 32 | * `name` - The Rule's name. 33 | * `rule` - The ACL Rule itself. 34 | -------------------------------------------------------------------------------- /provider/essentials/testdata/essentials_database_basic.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | subscription_name = "%s" 3 | database_name = "%s" 4 | redis_version = "%s" 5 | password = "%s" 6 | } 7 | 8 | data "rediscloud_payment_method" "card" { 9 | card_type = "Visa" 10 | last_four_numbers = "5556" 11 | } 12 | 13 | data "rediscloud_essentials_plan" "example" { 14 | name = "Single-Zone_1GB" 15 | cloud_provider = "AWS" 16 | region = "us-east-1" 17 | } 18 | 19 | resource "rediscloud_essentials_subscription" "example" { 20 | name = local.subscription_name 21 | plan_id = data.rediscloud_essentials_plan.example.id 22 | payment_method_id = data.rediscloud_payment_method.card.id 23 | } 24 | 25 | resource "rediscloud_essentials_database" "example" { 26 | subscription_id = rediscloud_essentials_subscription.example.id 27 | name = local.database_name 28 | protocol = "redis" 29 | redis_version = local.redis_version 30 | replication = false 31 | data_persistence = "none" 32 | 33 | password = local.password 34 | 35 | alert { 36 | name = "throughput-higher-than" 37 | value = 80 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /provider/essentials/testdata/essentials_database_updated_version.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | subscription_name = "%s" 3 | database_name = "%s" 4 | redis_version = "%s" 5 | password = "%s" 6 | } 7 | 8 | data "rediscloud_payment_method" "card" { 9 | card_type = "Visa" 10 | last_four_numbers = "5556" 11 | } 12 | 13 | data "rediscloud_essentials_plan" "example" { 14 | name = "Single-Zone_1GB" 15 | cloud_provider = "AWS" 16 | region = "us-east-1" 17 | } 18 | 19 | resource "rediscloud_essentials_subscription" "example" { 20 | name = local.subscription_name 21 | plan_id = data.rediscloud_essentials_plan.example.id 22 | payment_method_id = data.rediscloud_payment_method.card.id 23 | } 24 | 25 | resource "rediscloud_essentials_database" "example" { 26 | subscription_id = rediscloud_essentials_subscription.example.id 27 | name = local.database_name 28 | protocol = "redis" 29 | redis_version = local.redis_version 30 | replication = false 31 | data_persistence = "aof-every-write" 32 | 33 | password = local.password 34 | 35 | alert { 36 | name = "throughput-higher-than" 37 | value = 85 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_database_modules.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_database_modules" 4 | description: |- 5 | Database Modules data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | 9 | # Data Source: rediscloud_database_modules 10 | 11 | The database modules data source allows access to a list of supported [Redis Enterprise Cloud modules](https://redislabs.com/redis-enterprise/modules). 12 | Each module represents an enrichment that can be applied to a Redis database. 13 | 14 | ## Example Usage 15 | 16 | The following example returns a list of all modules available within your Redis Enterprise Cloud account. 17 | 18 | ```hcl-terraform 19 | data "rediscloud_database_modules" "example" { 20 | } 21 | 22 | output "rediscloud_database_modules" { 23 | value = data.rediscloud_database_modules.example.modules 24 | } 25 | ``` 26 | 27 | ## Attributes Reference 28 | 29 | * `modules` A list of database modules. 30 | 31 | Each module entry provides the following attributes 32 | 33 | * `name` The identifier assigned by the database module 34 | 35 | * `description` A meaningful description of the database module 36 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_private_service_connect.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_private_service_connect" 4 | description: |- 5 | Private Service Connect data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_private_service_connect 9 | 10 | The Private Service Connect data source allows access to an available the Private Service Connect Service within your Redis Enterprise Subscription. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_private_service_connect" "example" { 16 | subscription_id = "1234" 17 | } 18 | 19 | output "rediscloud_psc_status" { 20 | value = data.rediscloud_private_service_connect.example.status 21 | } 22 | ``` 23 | 24 | ## Argument Reference 25 | 26 | * `subscription_id` - (Required) The ID of a Pro subscription 27 | 28 | ## Attribute Reference 29 | 30 | * `private_service_connect_service_id` - The ID of the Private Service Connect Service relative to the associated subscription 31 | * `connection_host_name` - The connection hostname 32 | * `service_attachment_name` - The service attachment name 33 | * `status` - The Private Service Connect status 34 | -------------------------------------------------------------------------------- /provider/psc/testdata/testPrivateServiceConnect1.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | } 4 | 5 | data "rediscloud_payment_method" "card" { 6 | card_type = "Visa" 7 | last_four_numbers = "5556" 8 | } 9 | 10 | resource "rediscloud_subscription" "subscription_resource" { 11 | name = local.rediscloud_subscription_name 12 | payment_method_id = data.rediscloud_payment_method.card.id 13 | 14 | cloud_provider { 15 | provider = "GCP" 16 | region { 17 | region = "us-central1" 18 | networking_deployment_cidr = "10.0.0.0/24" 19 | } 20 | } 21 | 22 | creation_plan { 23 | dataset_size_in_gb = 1 24 | quantity = 1 25 | replication = true 26 | throughput_measurement_by = "operations-per-second" 27 | throughput_measurement_value = 20000 28 | } 29 | } 30 | 31 | resource "rediscloud_private_service_connect" "psc" { 32 | subscription_id = rediscloud_subscription.subscription_resource.id 33 | } 34 | 35 | data "rediscloud_private_service_connect" "psc" { 36 | subscription_id = rediscloud_subscription.subscription_resource.id 37 | } 38 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_data_persistence.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_data_persistence" 4 | description: |- 5 | Data Persistence data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_data_persistence 9 | 10 | The data persistence data source allows access to a list of supported data persistence options. 11 | Each option represents the rate at which a database will persist its data to storage. 12 | 13 | ## Example Usage 14 | 15 | The following example returns all of the data persistence options available within your Redis Enterprise Cloud account. 16 | 17 | ```hcl-terraform 18 | data "rediscloud_data_persistence" "example" { 19 | } 20 | 21 | output "data_persistence_options" { 22 | value = data.rediscloud_data_persistence.example.data_persistence 23 | } 24 | ``` 25 | 26 | ## Attributes Reference 27 | 28 | * `data_persistence` A list of data persistence option that can be applied to subscription databases 29 | 30 | Each data persistence option provides the following attributes 31 | 32 | * `name` - The identifier of the data persistence option. 33 | 34 | * `description` - A meaningful description of the data persistence option. 35 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_private_service_connect.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_private_service_connect" 4 | description: |- 5 | Private Service Connect resource for Pro Subscription in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_private_service_connect 9 | 10 | Manages a Private Service Connect to a Pro Subscription in your Redis Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | [Full example in the `rediscloud_private_service_connect_endpoint` resource](./rediscloud_private_service_connect_endpoint.md) 15 | 16 | ## Argument Reference 17 | 18 | * `subscription_id` - (Required) The ID of the Pro subscription to attach **Modifying this attribute will force creation of a new resource.** 19 | 20 | ## Attribute Reference 21 | 22 | * `private_service_connect_service_id` - The ID of the Private Service Connect Service relative to the associated subscription 23 | 24 | ## Import 25 | `rediscloud_private_service_connect` can be imported using the ID of the subscription and the ID of the Private Service Connect in the format {subscription ID/private service connect ID}, e.g. 26 | 27 | ``` 28 | $ terraform import rediscloud_private_service_connect.id 1000/123456 29 | ``` 30 | -------------------------------------------------------------------------------- /provider/essentials/testdata/essentials_database_redis_version.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | subscription_name = "%s" 3 | database_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | data "rediscloud_essentials_plan" "example" { 12 | name = "Single-Zone_1GB" 13 | cloud_provider = "AWS" 14 | region = "us-east-1" 15 | } 16 | 17 | data "rediscloud_essentials_database" "example" { 18 | subscription_id = rediscloud_essentials_subscription.example.id 19 | name = rediscloud_essentials_database.example.name 20 | } 21 | 22 | resource "rediscloud_essentials_subscription" "example" { 23 | name = local.subscription_name 24 | plan_id = data.rediscloud_essentials_plan.example.id 25 | payment_method_id = data.rediscloud_payment_method.card.id 26 | } 27 | 28 | resource "rediscloud_essentials_database" "example" { 29 | subscription_id = rediscloud_essentials_subscription.example.id 30 | name = local.database_name 31 | enable_default_user = true 32 | password = "j43589rhe39f" 33 | 34 | data_persistence = "none" 35 | replication = false 36 | 37 | alert { 38 | name = "throughput-higher-than" 39 | value = 80 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_acl_role.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_acl_role" 4 | description: |- 5 | ACL Role data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_acl_role 9 | 10 | The Role data source allows access to an existing Role within your Redis Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_acl_role" "example" { 16 | name = "fast-admin" 17 | } 18 | 19 | output "rediscloud_acl_role" { 20 | value = data.rediscloud_acl_role.example.id 21 | } 22 | ``` 23 | 24 | ## Argument Reference 25 | 26 | * `name` - (Required) The name of the Role to filter returned subscriptions 27 | 28 | ## Attribute reference 29 | 30 | * `id` - Identifier of the found Role. 31 | * `name` - The Role's name. 32 | * `rule` - The Rules associated with the Role. 33 | 34 | The `rule` block supports: 35 | 36 | * `name` - Name of the Rule. 37 | * `database` - a set of database association objects, documented below. 38 | 39 | The `database` block supports: 40 | 41 | * `subscription` ID of the subscription containing the database. 42 | * `database` ID of the database to which the Rule should apply. 43 | * `regions` The regions to which the Rule should apply, if appropriate to the database. 44 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_subscription_boilerplate.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | } 4 | 5 | 6 | resource "rediscloud_subscription_database" "example" { 7 | subscription_id = rediscloud_subscription.example.id 8 | name = local.rediscloud_subscription_name 9 | protocol = "redis" 10 | dataset_size_in_gb = 1 11 | data_persistence = "none" 12 | data_eviction = "allkeys-random" 13 | throughput_measurement_by = "operations-per-second" 14 | throughput_measurement_value = 1000 15 | password = "%s" 16 | support_oss_cluster_api = false 17 | external_endpoint_for_oss_cluster_api = false 18 | replication = false 19 | average_item_size_in_bytes = 0 20 | client_ssl_certificate = "" 21 | periodic_backup_path = "" 22 | enable_default_user = true 23 | redis_version = 7.2 24 | 25 | alert { 26 | name = "dataset-size" 27 | value = 1 28 | } 29 | 30 | tags = { 31 | "market" = "emea" 32 | "material" = "cardboard" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_active_active_private_service_connect.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_active_active_private_service_connect" 4 | description: |- 5 | Active-Active Private Service Connect data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_active_active_private_service_connect 9 | 10 | The Active-Active Private Service Connect data source allows access to an available the Private Service Connect Service within your Redis Enterprise Subscription. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_active_active_private_service_connect" "example" { 16 | subscription_id = "1234" 17 | region_id = 1 18 | } 19 | 20 | output "rediscloud_psc_status" { 21 | value = data.rediscloud_active_active_private_service_connect.example.status 22 | } 23 | ``` 24 | 25 | ## Argument Reference 26 | 27 | * `subscription_id` - (Required) The ID of an Active-Active subscription 28 | * `region_id` - (Required) The ID of the GCP region 29 | 30 | ## Attribute Reference 31 | 32 | * `private_service_connect_service_id` - The ID of the Private Service Connect Service relative to the associated subscription 33 | * `connection_host_name` - The connection hostname 34 | * `service_attachment_name` - The service attachment name 35 | * `status` - The Private Service Connect status 36 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_private_service_connect_endpoint_accepter.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_private_service_connect_endpoint_accepter" 4 | description: |- 5 | Private Service Connect Endpoint Accepter resource for a Pro Subscription in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: # Resource: rediscloud_private_service_connect_endpoint_accepter 9 | 10 | Manages a Private Service Connect Endpoint state in your Redis Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | [Full example in the `rediscloud_private_service_connect_endpoint` resource](./rediscloud_private_service_connect_endpoint.md) 15 | 16 | ## Argument Reference 17 | 18 | * `subscription_id` - (Required) The ID of the Pro subscription to attach **Modifying this attribute will force creation of a new resource.** 19 | * `private_service_connect_service_id` - (Required) The ID of the Private Service Connect Service relative to the associated subscription **Modifying this attribute will force creation of a new resource.** 20 | * `private_service_connect_endpoint_id` - (Required) The ID of the Private Service Connect Service relative to the associated subscription **Modifying this attribute will force creation of a new resource.** 21 | * `action` - (Required) Accept or reject the endpoint (accepted values are `accept` and `reject`) 22 | -------------------------------------------------------------------------------- /provider/datasource_rediscloud_payment_method_test.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/utils" 5 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 6 | "regexp" 7 | "testing" 8 | ) 9 | 10 | func TestAccDataSourceRedisCloudPaymentMethod_basic(t *testing.T) { 11 | 12 | utils.AccRequiresEnvVar(t, "EXECUTE_TESTS") 13 | 14 | resource.ParallelTest(t, resource.TestCase{ 15 | PreCheck: func() { testAccPreCheck(t) }, 16 | ProviderFactories: providerFactories, 17 | CheckDestroy: nil, // payment method isn't managed by this provider 18 | Steps: []resource.TestStep{ 19 | { 20 | Config: testAccDataSourceRedisCloudPaymentMethod, 21 | Check: resource.ComposeAggregateTestCheckFunc( 22 | resource.TestMatchResourceAttr( 23 | "data.rediscloud_payment_method.foo", "id", regexp.MustCompile("^\\d*$")), 24 | resource.TestMatchResourceAttr( 25 | "data.rediscloud_payment_method.foo", "card_type", regexp.MustCompile("^\\w*$")), 26 | resource.TestMatchResourceAttr( 27 | "data.rediscloud_payment_method.foo", "last_four_numbers", regexp.MustCompile("^\\d*$")), 28 | ), 29 | }, 30 | }, 31 | }) 32 | } 33 | 34 | const testAccDataSourceRedisCloudPaymentMethod = ` 35 | data "rediscloud_payment_method" "card" { 36 | card_type = "Visa" 37 | last_four_numbers = "5556" 38 | } 39 | ` 40 | -------------------------------------------------------------------------------- /provider/datasource_rediscloud_acl_rule_test.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "fmt" 5 | "regexp" 6 | "testing" 7 | 8 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/utils" 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 10 | ) 11 | 12 | func TestAccDataSourceRedisCloudAclRule_ForDefaultRule(t *testing.T) { 13 | 14 | utils.AccRequiresEnvVar(t, "EXECUTE_TESTS") 15 | 16 | // This rule already exists 17 | const testName = "Read-Write" 18 | const testRule = "+@all -@dangerous ~*" 19 | getRuleTerraform := fmt.Sprintf(getDefaultDatasourceAclRuleDataSource, testName) 20 | 21 | const AclRuleTest = "data.rediscloud_acl_rule.test" 22 | resource.ParallelTest(t, resource.TestCase{ 23 | PreCheck: func() { testAccPreCheck(t) }, 24 | ProviderFactories: providerFactories, 25 | CheckDestroy: nil, // test doesn't create a resource, so don't need to check anything 26 | Steps: []resource.TestStep{ 27 | { 28 | Config: getRuleTerraform, 29 | Check: resource.ComposeAggregateTestCheckFunc( 30 | resource.TestMatchResourceAttr( 31 | AclRuleTest, "id", regexp.MustCompile("^\\d*$")), 32 | resource.TestCheckResourceAttr(AclRuleTest, "name", testName), 33 | resource.TestCheckResourceAttr(AclRuleTest, "rule", testRule), 34 | ), 35 | }, 36 | }, 37 | }) 38 | } 39 | 40 | const getDefaultDatasourceAclRuleDataSource = ` 41 | data "rediscloud_acl_rule" "test" { 42 | name = "%s" 43 | } 44 | ` 45 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_transit_gateway.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_transit_gateway" 4 | description: |- 5 | Transit Gateway data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_transit_gateway 9 | 10 | The Transit Gateway data source allows access to an available Transit Gateway within your Redis Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_transit_gateway" "example" { 16 | subscription_id = "113991" 17 | aws_tgw_id = "tgw-1c55bfdoe20pdsad2" 18 | } 19 | 20 | output "rediscloud_transit_gateway" { 21 | value = data.rediscloud_transit_gateway.example.tgw_id 22 | } 23 | ``` 24 | 25 | ## Argument Reference 26 | 27 | * `subscription_id` - (Required) The id of a Pro/Flexible subscription 28 | * `tgw_id` - (Optional) The id of the Transit Gateway relative to the associated subscription. You would likely 29 | reference this value when creating a `rediscloud_transit_gateway_attachment`. 30 | * `aws_tgw_id` - (Optional) The id of the Transit Gateway as known to AWS 31 | 32 | ## Attribute Reference 33 | 34 | * `attachment_uid` - A unique identifier for the Subscription/Transit Gateway attachment, if any 35 | * `status` - The status of the Transit Gateway 36 | * `attachment_status` - The status of the Subscription/Transit Gateway attachment, if any 37 | * `aws_account_id` - The Transit Gateway's AWS account id 38 | * `cidrs` - A list of consumer Cidr blocks, if an attachment exists 39 | -------------------------------------------------------------------------------- /provider/datasource_rediscloud_data_persistence_test.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/utils" 5 | "testing" 6 | 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 8 | ) 9 | 10 | func TestAccDataSourceRedisCloudDataPersistence_basic(t *testing.T) { 11 | 12 | utils.AccRequiresEnvVar(t, "EXECUTE_TESTS") 13 | 14 | const dataPersistenceFoo = "data.rediscloud_data_persistence.foo" 15 | resource.ParallelTest(t, resource.TestCase{ 16 | PreCheck: func() { testAccPreCheck(t) }, 17 | ProviderFactories: providerFactories, 18 | CheckDestroy: nil, // data persistence isn't a 'real' resource 19 | Steps: []resource.TestStep{ 20 | { 21 | Config: testAccDataSourceRedisCloudDataPersistence, 22 | Check: resource.ComposeAggregateTestCheckFunc( 23 | resource.TestCheckTypeSetElemNestedAttrs(dataPersistenceFoo, "data_persistence.*", map[string]string{ 24 | "name": "snapshot-every-12-hours", 25 | }), 26 | resource.TestCheckTypeSetElemNestedAttrs(dataPersistenceFoo, "data_persistence.*", map[string]string{ 27 | "name": "snapshot-every-6-hours", 28 | }), 29 | resource.TestCheckTypeSetElemNestedAttrs(dataPersistenceFoo, "data_persistence.*", map[string]string{ 30 | "name": "snapshot-every-1-hour", 31 | }), 32 | ), 33 | }, 34 | }, 35 | }) 36 | } 37 | 38 | const testAccDataSourceRedisCloudDataPersistence = ` 39 | data "rediscloud_data_persistence" "foo" { 40 | } 41 | ` 42 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_transit_gateway_invitations.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_transit_gateway_invitations" 4 | description: |- 5 | Transit Gateway Invitations data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_transit_gateway_invitations 9 | 10 | The Transit Gateway Invitations data source allows access to pending Transit Gateway invitations within your Redis Enterprise Cloud Subscription. These invitations are created when an AWS Resource Share shares a Transit Gateway with your subscription. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_transit_gateway_invitations" "example" { 16 | subscription_id = "113991" 17 | } 18 | 19 | output "pending_invitations" { 20 | value = data.rediscloud_transit_gateway_invitations.example.invitations 21 | } 22 | ``` 23 | 24 | ## Argument Reference 25 | 26 | * `subscription_id` - (Required) The ID of a Pro subscription 27 | 28 | ## Attribute Reference 29 | 30 | * `invitations` - List of Transit Gateway invitations, documented below 31 | 32 | The `invitations` object has these attributes: 33 | 34 | * `id` - The ID of the Transit Gateway invitation 35 | * `name` - The name of the resource share 36 | * `resource_share_uid` - The AWS Resource Share ARN 37 | * `aws_account_id` - The AWS account ID that shared the Transit Gateway 38 | * `status` - The status of the invitation (e.g., `pending`, `accepted`, `rejected`) 39 | * `shared_date` - The date the resource was shared 40 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_no_password.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | data "rediscloud_cloud_account" "account" { 12 | exclude_internal_account = true 13 | provider_type = "AWS" 14 | name = local.rediscloud_cloud_account 15 | } 16 | 17 | resource "rediscloud_subscription" "example" { 18 | name = local.rediscloud_subscription_name 19 | payment_method_id = data.rediscloud_payment_method.card.id 20 | cloud_provider { 21 | provider = data.rediscloud_cloud_account.account.provider_type 22 | cloud_account_id = data.rediscloud_cloud_account.account.id 23 | region { 24 | region = "eu-west-1" 25 | networking_deployment_cidr = "10.0.0.0/24" 26 | preferred_availability_zones = ["eu-west-1a"] 27 | } 28 | } 29 | 30 | creation_plan { 31 | dataset_size_in_gb = 1 32 | quantity = 1 33 | replication = false 34 | throughput_measurement_by = "operations-per-second" 35 | throughput_measurement_value = 1000 36 | } 37 | } 38 | 39 | resource "rediscloud_subscription_database" "no_password_database" { 40 | subscription_id = rediscloud_subscription.example.id 41 | name = "example-no-password" 42 | protocol = "redis" 43 | dataset_size_in_gb = 1 44 | data_persistence = "none" 45 | throughput_measurement_by = "operations-per-second" 46 | throughput_measurement_value = 1000 47 | } 48 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_subscription_redis8.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | cloud_account_name = "%s" 3 | subscription_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | data "rediscloud_cloud_account" "account" { 12 | exclude_internal_account = true 13 | provider_type = "AWS" 14 | name = local.cloud_account_name 15 | } 16 | 17 | resource "rediscloud_subscription" "example" { 18 | 19 | name = local.subscription_name 20 | payment_method = "credit-card" 21 | payment_method_id = data.rediscloud_payment_method.card.id 22 | memory_storage = "ram" 23 | 24 | allowlist { 25 | cidrs = ["192.168.0.0/16"] 26 | security_group_ids = [] 27 | } 28 | 29 | cloud_provider { 30 | provider = data.rediscloud_cloud_account.account.provider_type 31 | cloud_account_id = data.rediscloud_cloud_account.account.id 32 | region { 33 | region = "eu-west-1" 34 | networking_deployment_cidr = "10.0.0.0/24" 35 | preferred_availability_zones = ["eu-west-1a"] 36 | } 37 | } 38 | 39 | creation_plan { 40 | dataset_size_in_gb = 1 41 | quantity = 1 42 | replication = false 43 | support_oss_cluster_api = false 44 | query_performance_factor = "4x" 45 | throughput_measurement_by = "operations-per-second" 46 | throughput_measurement_value = 10000 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_active_active_private_service_connect.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_active_active_private_service_connect" 4 | description: |- 5 | Private Service Connect resource for Active-Active Subscription in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_active_active_private_service_connect 9 | 10 | Manages a Private Service Connect to an Active-Active Subscription in your Redis Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | [Full example in the `rediscloud_active_active_private_service_connect_endpoint` resource](./rediscloud_active_active_private_service_connect_endpoint.md) 15 | 16 | ## Argument Reference 17 | 18 | * `subscription_id` - (Required) The ID of the Pro subscription to attach **Modifying this attribute will force creation of a new resource.** 19 | * `region_id` - (Required) The ID of the region, as created by the API **Modifying this attribute will force creation of a new resource.** 20 | 21 | ## Attribute Reference 22 | 23 | * `private_service_connect_service_id` - The ID of the Private Service Connect Service relative to the associated subscription 24 | 25 | ## Import 26 | 27 | `rediscloud_active_active_private_service_connect` can be imported using the ID of the Active-Active subscription, the region ID and the ID of the Private Service Connect in the format {subscription ID/region ID/private service connect ID}, e.g. 28 | 29 | ``` 30 | $ terraform import rediscloud_active_active_private_service_connect.id 1000/1/123456 31 | ``` 32 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_active_active_private_service_connect_endpoint_accepter.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_active_active_private_service_connect_endpoint_accepter" 4 | description: |- 5 | Private Service Connect Endpoint Accepter resource for Active-Active Subscription in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_active_active_private_service_connect_endpoint_accepter 9 | 10 | Manages a Private Service Connect Endpoint state in your Redis Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | [Full example in the `rediscloud_active_active_private_service_connect_endpoint` resource](./rediscloud_active_active_private_service_connect_endpoint.md) 15 | 16 | ## Argument Reference 17 | 18 | * `subscription_id` - (Required) The ID of the Pro subscription to attach **Modifying this attribute will force creation of a new resource.** 19 | * `region_id` - (Required) The ID of the region, as created by the API **Modifying this attribute will force creation of a new resource.** 20 | * `private_service_connect_service_id` - (Required) The ID of the Private Service Connect Service relative to the associated subscription **Modifying this attribute will force creation of a new resource.** 21 | * `private_service_connect_endpoint_id` - (Required) The ID of the Private Service Connect Service relative to the associated subscription **Modifying this attribute will force creation of a new resource.** 22 | * `action` - (Required) Accept or reject the endpoint (accepted values are `accept` and `reject`) 23 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_optional_attributes.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | port_number = %d 5 | } 6 | 7 | data "rediscloud_payment_method" "card" { 8 | card_type = "Visa" 9 | last_four_numbers = "5556" 10 | } 11 | 12 | data "rediscloud_cloud_account" "account" { 13 | exclude_internal_account = true 14 | provider_type = "AWS" 15 | name = local.rediscloud_cloud_account 16 | } 17 | 18 | resource "rediscloud_subscription" "example" { 19 | name = local.rediscloud_subscription_name 20 | payment_method_id = data.rediscloud_payment_method.card.id 21 | cloud_provider { 22 | provider = data.rediscloud_cloud_account.account.provider_type 23 | cloud_account_id = data.rediscloud_cloud_account.account.id 24 | region { 25 | region = "eu-west-1" 26 | networking_deployment_cidr = "10.0.0.0/24" 27 | preferred_availability_zones = ["eu-west-1a"] 28 | } 29 | } 30 | 31 | creation_plan { 32 | dataset_size_in_gb = 1 33 | quantity = 1 34 | replication = false 35 | throughput_measurement_by = "operations-per-second" 36 | throughput_measurement_value = 1000 37 | } 38 | } 39 | 40 | resource "rediscloud_subscription_database" "example" { 41 | subscription_id = rediscloud_subscription.example.id 42 | name = "example-no-protocol" 43 | dataset_size_in_gb = 1 44 | data_persistence = "none" 45 | throughput_measurement_by = "operations-per-second" 46 | throughput_measurement_value = 1000 47 | port = local.port_number 48 | } 49 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/auto_minor_version_upgrade.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | data "rediscloud_cloud_account" "account" { 12 | exclude_internal_account = true 13 | provider_type = "AWS" 14 | name = local.rediscloud_cloud_account 15 | } 16 | 17 | resource "rediscloud_active_active_subscription" "example" { 18 | name = local.rediscloud_subscription_name 19 | payment_method_id = data.rediscloud_payment_method.card.id 20 | storage_encryption = true 21 | 22 | region { 23 | region = "eu-west-1" 24 | networking_deployment_cidr = "10.0.0.0/24" 25 | preferred_availability_zones = ["eu-west-1a"] 26 | } 27 | 28 | region { 29 | region = "us-east-1" 30 | networking_deployment_cidr = "10.1.0.0/24" 31 | preferred_availability_zones = ["us-east-1a"] 32 | } 33 | } 34 | 35 | resource "rediscloud_active_active_subscription_database" "example" { 36 | subscription_id = rediscloud_active_active_subscription.example.id 37 | name = "auto-minor-version-upgrade-test" 38 | protocol = "redis" 39 | dataset_size_in_gb = 1 40 | data_eviction = "allkeys-random" 41 | throughput_measurement_by = "operations-per-second" 42 | throughput_measurement_value = 1000 43 | auto_minor_version_upgrade = %s 44 | } 45 | -------------------------------------------------------------------------------- /provider/datasource_rediscloud_database_modules_test.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/utils" 5 | "testing" 6 | 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 8 | ) 9 | 10 | func TestAccDataSourceRedisCloudDatabaseModules_basic(t *testing.T) { 11 | 12 | utils.AccRequiresEnvVar(t, "EXECUTE_TESTS") 13 | 14 | resource.ParallelTest(t, resource.TestCase{ 15 | PreCheck: func() { testAccPreCheck(t) }, 16 | ProviderFactories: providerFactories, 17 | CheckDestroy: nil, // database modules isn't a 'real' resource 18 | Steps: []resource.TestStep{ 19 | { 20 | Config: testAccDataSourceRedisCloudDatabaseModules, 21 | Check: resource.ComposeAggregateTestCheckFunc( 22 | resource.TestCheckTypeSetElemNestedAttrs("data.rediscloud_database_modules.foo", "modules.*", map[string]string{ 23 | "name": "RedisBloom", 24 | }), 25 | resource.TestCheckTypeSetElemNestedAttrs("data.rediscloud_database_modules.foo", "modules.*", map[string]string{ 26 | "name": "RediSearch", 27 | }), 28 | resource.TestCheckTypeSetElemNestedAttrs("data.rediscloud_database_modules.foo", "modules.*", map[string]string{ 29 | "name": "RedisJSON", 30 | }), 31 | resource.TestCheckTypeSetElemNestedAttrs("data.rediscloud_database_modules.foo", "modules.*", map[string]string{ 32 | "name": "RedisTimeSeries", 33 | }), 34 | ), 35 | }, 36 | }, 37 | }) 38 | } 39 | 40 | const testAccDataSourceRedisCloudDatabaseModules = ` 41 | data "rediscloud_database_modules" "foo" { 42 | } 43 | ` 44 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_resp_versions.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | port_number = %d 5 | resp_version = "%s" 6 | } 7 | 8 | data "rediscloud_payment_method" "card" { 9 | card_type = "Visa" 10 | last_four_numbers = "5556" 11 | } 12 | 13 | data "rediscloud_cloud_account" "account" { 14 | exclude_internal_account = true 15 | provider_type = "AWS" 16 | name = local.rediscloud_cloud_account 17 | } 18 | 19 | resource "rediscloud_subscription" "example" { 20 | name = local.rediscloud_subscription_name 21 | payment_method_id = data.rediscloud_payment_method.card.id 22 | cloud_provider { 23 | provider = data.rediscloud_cloud_account.account.provider_type 24 | cloud_account_id = data.rediscloud_cloud_account.account.id 25 | region { 26 | region = "eu-west-1" 27 | networking_deployment_cidr = "10.0.0.0/24" 28 | preferred_availability_zones = ["eu-west-1a"] 29 | } 30 | } 31 | 32 | creation_plan { 33 | dataset_size_in_gb = 1 34 | quantity = 1 35 | replication = false 36 | throughput_measurement_by = "operations-per-second" 37 | throughput_measurement_value = 1000 38 | } 39 | } 40 | 41 | resource "rediscloud_subscription_database" "example" { 42 | subscription_id = rediscloud_subscription.example.id 43 | name = "example" 44 | dataset_size_in_gb = 1 45 | data_persistence = "none" 46 | throughput_measurement_by = "operations-per-second" 47 | throughput_measurement_value = 1000 48 | port = local.port_number 49 | resp_version = local.resp_version 50 | } 51 | -------------------------------------------------------------------------------- /provider/datasource_rediscloud_cloud_account_test.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "fmt" 5 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/utils" 6 | "os" 7 | "regexp" 8 | "testing" 9 | 10 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 11 | ) 12 | 13 | func TestAccDataSourceRedisCloudCloudAccount_basic(t *testing.T) { 14 | 15 | utils.AccRequiresEnvVar(t, "EXECUTE_TESTS") 16 | 17 | name := os.Getenv("AWS_TEST_CLOUD_ACCOUNT_NAME") 18 | 19 | const testCloudAccount = "data.rediscloud_cloud_account.test" 20 | 21 | resource.ParallelTest(t, resource.TestCase{ 22 | PreCheck: func() { testAccPreCheck(t); testAccAwsPreExistingCloudAccountPreCheck(t) }, 23 | ProviderFactories: providerFactories, 24 | CheckDestroy: nil, // test doesn't create a resource at the moment, so don't need to check anything 25 | Steps: []resource.TestStep{ 26 | { 27 | Config: fmt.Sprintf(testAccDatasourceRedisCloudCloudAccountDataSource, name), 28 | Check: resource.ComposeAggregateTestCheckFunc( 29 | resource.TestMatchResourceAttr(testCloudAccount, "id", regexp.MustCompile("^\\d*$")), 30 | resource.TestCheckResourceAttr(testCloudAccount, "provider_type", "AWS"), 31 | resource.TestCheckResourceAttr(testCloudAccount, "name", name), 32 | resource.TestCheckResourceAttrSet(testCloudAccount, "access_key_id"), 33 | ), 34 | }, 35 | }, 36 | }) 37 | } 38 | 39 | const testAccDatasourceRedisCloudCloudAccountDataSource = ` 40 | data "rediscloud_cloud_account" "test" { 41 | exclude_internal_account = true 42 | provider_type = "AWS" 43 | name = "%s" 44 | } 45 | ` 46 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_acl_rule.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_acl_rule" 4 | description: |- 5 | ACL Rule resource in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_acl_rule 9 | 10 | Creates a Rule (a.k.a Redis Rule, Redis ACL) in your Redis Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | resource "rediscloud_acl_rule" "rule-resource" { 16 | name = "my-rule" 17 | rule = "+@read ~cache:*" 18 | } 19 | ``` 20 | 21 | ## Argument Reference 22 | 23 | The following arguments are supported: 24 | 25 | * `name` - (Required) A meaningful name for the rule. Must be unique. 26 | * `rule` - (Required) The ACL rule itself, built up as permissions/restrictions written in 27 | the [ACL Syntax](https://docs.redis.com/latest/rc/security/access-control/data-access-control/configure-acls/#define-permissions-with-acl-syntax). 28 | 29 | ### Timeouts 30 | 31 | The `timeouts` block allows you to 32 | specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: 33 | 34 | * `create` - (Defaults to 5 mins) Used when creating the Rule. 35 | * `update` - (Defaults to 5 mins) Used when updating the Rule. 36 | * `delete` - (Defaults to 5 mins) Used when destroying the Rule. 37 | 38 | ## Attribute reference 39 | 40 | * `id` - Identifier of the Rule created. 41 | * `name` - The Rule's name. 42 | * `rule` - The ACL Rule itself. 43 | 44 | ## Import 45 | 46 | `rediscloud_acl_rule` can be imported using the Identifier of the Rule, e.g. 47 | 48 | ``` 49 | $ terraform import rediscloud_acl_rule.rule-resource 123456 50 | ``` 51 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_regions.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_regions" 4 | description: |- 5 | Regions data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_regions 9 | 10 | The Regions data source allows access to a list of supported cloud provider regions. These regions can be used with the subscription resource. 11 | 12 | ## Example Usage 13 | 14 | The following example returns all of the supported regions available within your Redis Enterprise Cloud account. 15 | 16 | ```hcl-terraform 17 | data "rediscloud_regions" "example" { 18 | } 19 | 20 | output "all_regions" { 21 | value = data.rediscloud_regions.example.regions 22 | } 23 | ``` 24 | 25 | The following example show how the list of regions can be filtered by cloud provider, (`AWS` or `GCP`). 26 | 27 | ```hcl-terraform 28 | data "rediscloud_regions" "example_aws" { 29 | provider_name = "AWS" 30 | } 31 | 32 | data "rediscloud_regions" "example_gcp" { 33 | provider_name = "GCP" 34 | } 35 | ``` 36 | 37 | ## Argument Reference 38 | 39 | * `provider_name` - (Optional) The name of the cloud provider to filter returned regions, (accepted values are `AWS` or `GCP`). 40 | 41 | ## Attributes Reference 42 | 43 | * `regions` A list of regions from either a single or multiple cloud providers. 44 | 45 | Each region entry provides the following attributes 46 | 47 | * `region_id` The unique identifier of the region 48 | 49 | * `name` The identifier assigned by the cloud provider, (for example `eu-west-1` for `AWS`) 50 | 51 | * `provider_name` The identifier of the owning cloud provider, (either `AWS` or `GCP`) 52 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_subscription_redis7.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | cloud_account_name = "%s" 3 | subscription_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | data "rediscloud_cloud_account" "account" { 12 | exclude_internal_account = true 13 | provider_type = "AWS" 14 | name = local.cloud_account_name 15 | } 16 | 17 | resource "rediscloud_subscription" "example" { 18 | 19 | name = local.subscription_name 20 | payment_method = "credit-card" 21 | payment_method_id = data.rediscloud_payment_method.card.id 22 | memory_storage = "ram" 23 | redis_version = "7.4" 24 | 25 | allowlist { 26 | cidrs = ["192.168.0.0/16"] 27 | security_group_ids = [] 28 | } 29 | 30 | cloud_provider { 31 | provider = data.rediscloud_cloud_account.account.provider_type 32 | cloud_account_id = data.rediscloud_cloud_account.account.id 33 | region { 34 | region = "eu-west-1" 35 | networking_deployment_cidr = "10.0.0.0/24" 36 | preferred_availability_zones = ["eu-west-1a"] 37 | } 38 | } 39 | 40 | creation_plan { 41 | dataset_size_in_gb = 1 42 | quantity = 1 43 | replication = false 44 | support_oss_cluster_api = false 45 | query_performance_factor = "4x" 46 | throughput_measurement_by = "operations-per-second" 47 | throughput_measurement_value = 10000 48 | modules = ["RedisJSON", "RedisBloom", "RediSearch"] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_active_active_transit_gateway.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_transit_gateway" 4 | description: |- 5 | Active Active Transit Gateway data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_transit_gateway 9 | 10 | The Active Active Transit Gateway data source allows access to an available Transit Gateway within your Redis Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_active_active_transit_gateway" "example" { 16 | subscription_id = "113991" 17 | region_id = 1 18 | aws_tgw_id = "tgw-1c55bfdoe20pdsad2" 19 | } 20 | 21 | output "rediscloud_transit_gateway" { 22 | value = data.rediscloud_active_active_transit_gateway.example.tgw_id 23 | } 24 | ``` 25 | 26 | ## Argument Reference 27 | 28 | * `subscription_id` - (Required) The id of an Active Active subscription 29 | * `region_id` - (Required) The id of the AWS region 30 | * `tgw_id` - (Optional) The id of the Transit Gateway relative to the associated subscription. You would likely 31 | reference this value when creating a `rediscloud_active_active_transit_gateway_attachment`. 32 | * `aws_tgw_id` - (Optional) The id of the Transit Gateway as known to AWS 33 | 34 | ## Attribute Reference 35 | 36 | * `attachment_uid` - A unique identifier for the Subscription/Transit Gateway attachment, if any 37 | * `status` - The status of the Transit Gateway 38 | * `attachment_status` - The status of the Subscription/Transit Gateway attachment, if any 39 | * `aws_account_id` - The Transit Gateway's AWS account id 40 | * `cidrs` - A list of consumer Cidr blocks, if an attachment exists 41 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_essentials_subscription.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_essentials_subscription" 4 | description: |- 5 | Essentials Subscription data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_essentials_subscription 9 | 10 | This data source allows access to the details of an existing subscription within your Redis Enterprise Cloud account. 11 | 12 | -> **Note:** This is referring to Essentials Subscriptions only. See also `rediscloud_subscription` (Pro) and `rediscloud_active_active_subscription`. 13 | 14 | ## Example Usage 15 | 16 | The following example shows how to use the name attribute to locate an essentials subscription within your Redis Enterprise Cloud account. 17 | 18 | ```hcl 19 | data "rediscloud_essentials_subscription" "example" { 20 | name = "My Example Subscription" 21 | } 22 | output "rediscloud_essentials_subscription" { 23 | value = data.rediscloud_essentials_subscription.example.id 24 | } 25 | ``` 26 | 27 | ## Argument Reference 28 | 29 | * `id` - (Optional) The subscription's id 30 | * `name` - (Optional) A convenient name for the plan. 31 | 32 | ## Attributes Reference 33 | 34 | * `status` - The current status of the subscription 35 | * `plan_id` - The plan to which this subscription belongs 36 | * `payment_method` - 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. 37 | * `payment_method_id` - A valid payment method pre-defined in the current account 38 | * `creation_date` - When the subscription was created 39 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_acl_user.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_acl_user" 4 | description: |- 5 | ACL User resource in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_acl_user 9 | 10 | Creates a User in your Redis Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | resource "rediscloud_acl_user" "user-resource" { 16 | name = "my-user" 17 | role = rediscloud_acl_role.role-resource.name 18 | password = "mY.passw0rd" 19 | } 20 | ``` 21 | 22 | ## Argument Reference 23 | 24 | The following arguments are supported: 25 | 26 | * `name` - (Required, change forces recreation) A meaningful name for the User. Must be unique. 27 | * `role` - (Required) The name of the Role held by the User. 28 | * `password` - (Required, change forces recreation) The password for this ACL User. Must contain a lower-case letter, a 29 | upper-case letter, a 30 | number and a special character. 31 | 32 | ### Timeouts 33 | 34 | The `timeouts` block allows you to 35 | specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: 36 | 37 | * `create` - (Defaults to 5 mins) Used when creating the User. 38 | * `update` - (Defaults to 5 mins) Used when updating the User. 39 | * `delete` - (Defaults to 5 mins) Used when destroying the User. 40 | 41 | ## Attribute reference 42 | 43 | * `id` - Identifier of the User created. 44 | * `name` - The User's name. 45 | * `role` - The User's role name. 46 | 47 | ## Import 48 | 49 | `rediscloud_acl_user` can be imported using the Identifier of the User, e.g. 50 | 51 | ``` 52 | $ terraform import rediscloud_acl_user.user-resource 123456 53 | ``` 54 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_invalid_time_utc.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | data "rediscloud_cloud_account" "account" { 12 | exclude_internal_account = true 13 | provider_type = "AWS" 14 | name = local.rediscloud_cloud_account 15 | } 16 | 17 | resource "rediscloud_subscription" "example" { 18 | name = local.rediscloud_subscription_name 19 | payment_method_id = data.rediscloud_payment_method.card.id 20 | cloud_provider { 21 | provider = data.rediscloud_cloud_account.account.provider_type 22 | cloud_account_id = data.rediscloud_cloud_account.account.id 23 | region { 24 | region = "eu-west-1" 25 | networking_deployment_cidr = "10.0.0.0/24" 26 | preferred_availability_zones = ["eu-west-1a"] 27 | } 28 | } 29 | 30 | creation_plan { 31 | dataset_size_in_gb = 1 32 | quantity = 1 33 | replication = false 34 | throughput_measurement_by = "operations-per-second" 35 | throughput_measurement_value = 1000 36 | } 37 | } 38 | 39 | resource "rediscloud_subscription_database" "example" { 40 | subscription_id = rediscloud_subscription.example.id 41 | name = "example-no-protocol" 42 | dataset_size_in_gb = 1 43 | data_persistence = "none" 44 | throughput_measurement_by = "operations-per-second" 45 | throughput_measurement_value = 1000 46 | remote_backup { 47 | interval = "every-6-hours" 48 | time_utc = "16:00" 49 | storage_type = "aws-s3" 50 | storage_path = "uri://interval.not.12.or.24.hours.test" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_redis_8_with_modules.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | rediscloud_database_password = "%s" 5 | } 6 | 7 | data "rediscloud_payment_method" "card" { 8 | card_type = "Visa" 9 | last_four_numbers = "5556" 10 | } 11 | 12 | data "rediscloud_cloud_account" "account" { 13 | exclude_internal_account = true 14 | provider_type = "AWS" 15 | name = local.rediscloud_cloud_account 16 | } 17 | 18 | resource "rediscloud_subscription" "example" { 19 | name = local.rediscloud_subscription_name 20 | payment_method_id = data.rediscloud_payment_method.card.id 21 | cloud_provider { 22 | provider = data.rediscloud_cloud_account.account.provider_type 23 | cloud_account_id = data.rediscloud_cloud_account.account.id 24 | region { 25 | region = "eu-west-1" 26 | networking_deployment_cidr = "10.0.0.0/24" 27 | preferred_availability_zones = ["eu-west-1a"] 28 | } 29 | } 30 | 31 | creation_plan { 32 | dataset_size_in_gb = 1 33 | quantity = 1 34 | replication = false 35 | throughput_measurement_by = "operations-per-second" 36 | throughput_measurement_value = 1000 37 | } 38 | } 39 | 40 | resource "rediscloud_subscription_database" "example" { 41 | subscription_id = rediscloud_subscription.example.id 42 | name = "example" 43 | protocol = "redis" 44 | dataset_size_in_gb = 1 45 | data_persistence = "none" 46 | throughput_measurement_by = "operations-per-second" 47 | throughput_measurement_value = 1000 48 | password = local.rediscloud_database_password 49 | redis_version = "8.2" 50 | 51 | modules = [ 52 | { 53 | name = "RedisBloom" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | # Visit https://goreleaser.com for documentation on how to customize this 2 | # behavior. 3 | version: 2 4 | before: 5 | hooks: 6 | # this is just an example and not a requirement for provider building/publishing 7 | - go mod tidy 8 | builds: 9 | - env: 10 | # goreleaser does not work with CGO, it could also complicate 11 | # usage by users in CI/CD systems like Terraform Cloud where 12 | # they are unable to install libraries. 13 | - CGO_ENABLED=0 14 | mod_timestamp: '{{ .CommitTimestamp }}' 15 | flags: 16 | - -trimpath 17 | ldflags: 18 | - '-s -w -X main.version={{.Version}}' 19 | goos: 20 | - freebsd 21 | - windows 22 | - linux 23 | - darwin 24 | goarch: 25 | - amd64 26 | - '386' 27 | - arm 28 | - arm64 29 | ignore: 30 | - goos: darwin 31 | goarch: '386' 32 | binary: '{{ .ProjectName }}_v{{ .Version }}' 33 | archives: 34 | - format: zip 35 | name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' 36 | checksum: 37 | name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' 38 | algorithm: sha256 39 | signs: 40 | - artifacts: checksum 41 | args: 42 | # if you are using this is a GitHub action or some other automated pipeline, you 43 | # need to pass the batch flag to indicate its not interactive. 44 | - "--batch" 45 | - "--local-user" 46 | - "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key 47 | - "--output" 48 | - "${signature}" 49 | - "--detach-sign" 50 | - "${artifact}" 51 | release: 52 | # If you want to manually examine the release before its live, uncomment this line: 53 | # draft: true 54 | changelog: 55 | disable: true 56 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_active_active_transit_gateway_invitations.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_active_active_transit_gateway_invitations" 4 | description: |- 5 | Active-Active Transit Gateway Invitations data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_active_active_transit_gateway_invitations 9 | 10 | The Active-Active Transit Gateway Invitations data source allows access to pending Transit Gateway invitations within an Active-Active Redis Enterprise Cloud Subscription region. These invitations are created when an AWS Resource Share shares a Transit Gateway with your subscription. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_active_active_transit_gateway_invitations" "example" { 16 | subscription_id = "113991" 17 | region_id = 1 18 | } 19 | 20 | output "pending_invitations" { 21 | value = data.rediscloud_active_active_transit_gateway_invitations.example.invitations 22 | } 23 | ``` 24 | 25 | ## Argument Reference 26 | 27 | * `subscription_id` - (Required) The ID of an Active-Active subscription 28 | * `region_id` - (Required) The ID of the region within the Active-Active subscription 29 | 30 | ## Attribute Reference 31 | 32 | * `invitations` - List of Transit Gateway invitations, documented below 33 | 34 | The `invitations` object has these attributes: 35 | 36 | * `id` - The ID of the Transit Gateway invitation 37 | * `name` - The name of the resource share 38 | * `resource_share_uid` - The AWS Resource Share ARN 39 | * `aws_account_id` - The AWS account ID that shared the Transit Gateway 40 | * `status` - The status of the invitation (e.g., `pending`, `accepted`, `rejected`) 41 | * `shared_date` - The date the resource was shared 42 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # This GitHub action can publish assets for release when a tag is created. 2 | # Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0). 3 | # 4 | # This uses an action (paultyng/ghaction-import-gpg) that assumes you set your 5 | # private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE` 6 | # secret. If you would rather own your own GPG handling, please fork this action 7 | # or use an alternative one for key handling. 8 | # 9 | # You will need to pass the `--batch` flag to `gpg` in your signing step 10 | # in `goreleaser` to indicate this is being used in a non-interactive mode. 11 | # 12 | name: release 13 | on: 14 | push: 15 | tags: 16 | - 'v*' 17 | jobs: 18 | goreleaser: 19 | runs-on: ubuntu-latest 20 | steps: 21 | - 22 | name: Checkout 23 | uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 24 | - 25 | name: Unshallow 26 | run: git fetch --prune --unshallow 27 | - 28 | name: Set up Go 29 | uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 30 | with: 31 | go-version-file: go.mod 32 | - 33 | name: Import GPG key 34 | id: import_gpg 35 | uses: paultyng/ghaction-import-gpg@v2.1.0 36 | env: 37 | GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} 38 | PASSPHRASE: ${{ secrets.PASSPHRASE }} 39 | - 40 | name: Run GoReleaser 41 | uses: goreleaser/goreleaser-action@v6.4.0 42 | with: 43 | version: latest 44 | args: release --clean 45 | env: 46 | GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} 47 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 48 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_payment_method.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_payment_method" 4 | description: |- 5 | Payment method data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_payment_method 9 | 10 | The Payment Method data source allows access to the ID of a Payment Method configured against your Redis Enterprise Cloud account. This ID can be used when creating Subscription resources. 11 | 12 | ## Example Usage 13 | 14 | The following example shows a payment method data source being used with a subscription resource. 15 | 16 | The example assumes only a single payment method has been defined with a card type of Visa. By default all expired payment methods are excluded. 17 | 18 | ```hcl 19 | data "rediscloud_payment_method" "card" { 20 | card_type = "Visa" 21 | } 22 | 23 | resource "rediscloud_subscription" "example" { 24 | 25 | name = "My Test Subscription" 26 | payment_method_id = data.rediscloud_payment_method.card.id 27 | memory_storage = "ram" 28 | 29 | ... 30 | } 31 | ``` 32 | 33 | The following example shows how a single payment method can be identified when there are multiple methods against the same card type. 34 | 35 | ```hcl 36 | data "rediscloud_payment_method" "card" { 37 | card_type = "Visa" 38 | last_four_numbers = "0123" 39 | } 40 | ``` 41 | 42 | ## Argument Reference 43 | 44 | * `card_type` - (Optional) Type of card that the payment method should be, such as `Visa`. 45 | 46 | * `last_four_numbers` - (Optional) Last four numbers of the card of the payment method. 47 | 48 | * `exclude_expired` - (Optional) Whether to exclude any expired cards or not. Default is `true`. 49 | 50 | ## Attributes Reference 51 | 52 | `id` is set to the ID of the found payment method. 53 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_transit_gateway_attachment.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_transit_gateway_attachment" 4 | description: |- 5 | Transit Gateway Attachment resource in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_transit_gateway_attachment 9 | 10 | Manages a Transit Gateway Attachment to a Pro/Flexible Subscription in your Redis Enterprise Cloud Account. 11 | 12 | ```hcl 13 | data "rediscloud_transit_gateway" "gateway" { 14 | subscription_id = "113491" 15 | aws_tgw_id = "tgw-1c55bfdoe20pdsad2" 16 | } 17 | 18 | resource "rediscloud_transit_gateway_attachment" "attachment" { 19 | subscription_id = "113491" 20 | tgw_id = data.rediscloud_transit_gateway.gateway.tgw_id 21 | } 22 | ``` 23 | 24 | ## Argument Reference 25 | 26 | * `subscription_id` - (Required) The id of the Pro/Flexible subscription to attach 27 | * `tgw_id` - (Required) The id of the Transit Gateway to attach to 28 | * `cidrs` - (Optional) A list of consumer Cidr blocks. **May only be added once the Attachment has been accepted** 29 | 30 | ## Attribute Reference 31 | 32 | * `aws_tgw_uid` - The id of the Transit Gateway as known to AWS 33 | * `attachment_uid` - A unique identifier for the Subscription/Transit Gateway attachment, if established 34 | * `status` - The status of the Transit Gateway 35 | * `attachment_status` - The status of the Subscription/Transit Gateway attachment, if established 36 | * `aws_account_id` - The Transit Gateway's AWS account id 37 | 38 | ## Import 39 | `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. 40 | 41 | ``` 42 | $ terraform import rediscloud_transit_gateway_attachment.tgwa-resource 123456/47 43 | ``` 44 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_active_active_subscription_regions.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_active_active_subscription_regions" 4 | description: |- 5 | Active-Active subscription regions data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_active_active_subscription_regions 9 | 10 | The Active-Active subscription regions data source allows access to the regions associated with an Active-Active subscription within your Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | ```terraform 15 | 16 | data "rediscloud_active_active_subscription_regions" "example" { 17 | subscription_name = rediscloud_active_active_subscription.example.name 18 | } 19 | 20 | output "rediscloud_active_active_subscription_regions" { 21 | value = data.rediscloud_active_active_subscription_regions.example.regions 22 | } 23 | ``` 24 | 25 | ## Argument Reference 26 | 27 | * `subscription_name` - (Required) The name of the g subscription. 28 | 29 | ## Attribute Reference 30 | 31 | * `subscription_name` - The name of the subscription. 32 | * `regions` - A list of regions associated with an Active-Active subscription. 33 | 34 | Each block within the `regions` list supports: 35 | 36 | * `region_id` - The unique identifier of the region. 37 | * `region` - Deployment region as defined by the cloud provider. 38 | * `networking_deployment_cidr` - Deployment CIDR mask. 39 | * `vpc_id` - VPC ID for the region. 40 | * `databases` - A list of databases found in the region. 41 | 42 | The `databases` block supports: 43 | 44 | * `database_id` - A numeric ID for the database. 45 | * `database_name` - The name of the database. 46 | * `write_operations_per_second` - Write operations per second for the database. 47 | * `read_operations_per_second` - Read operations per second for the database. 48 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_update_destroy_alerts.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | data "rediscloud_cloud_account" "account" { 12 | exclude_internal_account = true 13 | provider_type = "AWS" 14 | name = local.rediscloud_cloud_account 15 | } 16 | 17 | resource "rediscloud_subscription" "example" { 18 | name = local.rediscloud_subscription_name 19 | payment_method_id = data.rediscloud_payment_method.card.id 20 | cloud_provider { 21 | provider = data.rediscloud_cloud_account.account.provider_type 22 | cloud_account_id = data.rediscloud_cloud_account.account.id 23 | region { 24 | region = "eu-west-1" 25 | networking_deployment_cidr = "10.0.0.0/24" 26 | preferred_availability_zones = ["eu-west-1a"] 27 | } 28 | } 29 | 30 | creation_plan { 31 | dataset_size_in_gb = 1 32 | quantity = 1 33 | replication = false 34 | throughput_measurement_by = "operations-per-second" 35 | throughput_measurement_value = 1000 36 | } 37 | } 38 | 39 | resource "rediscloud_subscription_database" "example" { 40 | subscription_id = rediscloud_subscription.example.id 41 | name = "example-updated" 42 | protocol = "redis" 43 | dataset_size_in_gb = 1 44 | data_persistence = "aof-every-write" 45 | data_eviction = "volatile-lru" 46 | throughput_measurement_by = "operations-per-second" 47 | throughput_measurement_value = 2000 48 | password = "updated-password" 49 | support_oss_cluster_api = true 50 | external_endpoint_for_oss_cluster_api = true 51 | replication = true 52 | average_item_size_in_bytes = 0 53 | 54 | modules = [ 55 | { 56 | name = "RedisBloom" 57 | } 58 | ] 59 | } 60 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_subscription_data_source.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | data "rediscloud_cloud_account" "account" { 12 | exclude_internal_account = true 13 | provider_type = "AWS" 14 | name = local.rediscloud_cloud_account 15 | } 16 | resource "rediscloud_subscription" "example" { 17 | name = local.rediscloud_subscription_name 18 | payment_method = "credit-card" 19 | payment_method_id = data.rediscloud_payment_method.card.id 20 | memory_storage = "ram" 21 | cloud_provider { 22 | provider = data.rediscloud_cloud_account.account.provider_type 23 | cloud_account_id = data.rediscloud_cloud_account.account.id 24 | region { 25 | region = "eu-west-1" 26 | networking_deployment_cidr = "10.0.0.0/24" 27 | preferred_availability_zones = ["eu-west-1a"] 28 | } 29 | } 30 | creation_plan { 31 | memory_limit_in_gb = 1 32 | quantity = 1 33 | replication = false 34 | support_oss_cluster_api = false 35 | throughput_measurement_by = "operations-per-second" 36 | throughput_measurement_value = 1000 37 | modules = [] 38 | } 39 | } 40 | resource "rediscloud_subscription_database" "example" { 41 | subscription_id = rediscloud_subscription.example.id 42 | name = "tf-database" 43 | protocol = "redis" 44 | memory_limit_in_gb = 1 45 | data_persistence = "none" 46 | throughput_measurement_by = "operations-per-second" 47 | throughput_measurement_value = 1000 48 | } 49 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/public_endpoint_enabled_default_source_ips.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_database_password = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | resource "rediscloud_active_active_subscription" "example" { 12 | name = local.rediscloud_subscription_name 13 | payment_method_id = data.rediscloud_payment_method.card.id 14 | cloud_provider = "AWS" 15 | public_endpoint_access = true 16 | 17 | creation_plan { 18 | memory_limit_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 | resource "rediscloud_active_active_subscription_database" "example" { 36 | subscription_id = rediscloud_active_active_subscription.example.id 37 | name = local.rediscloud_subscription_name 38 | dataset_size_in_gb = 1 39 | global_data_persistence = "none" 40 | global_password = local.rediscloud_database_password 41 | 42 | override_region { 43 | name = "us-east-1" 44 | } 45 | 46 | override_region { 47 | name = "us-east-2" 48 | } 49 | } 50 | 51 | data "rediscloud_active_active_subscription_database" "example" { 52 | subscription_id = rediscloud_active_active_subscription.example.id 53 | name = rediscloud_active_active_subscription_database.example.name 54 | } 55 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/public_endpoint_disabled_default_source_ips.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_database_password = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | resource "rediscloud_active_active_subscription" "example" { 12 | name = local.rediscloud_subscription_name 13 | payment_method_id = data.rediscloud_payment_method.card.id 14 | cloud_provider = "AWS" 15 | public_endpoint_access = false 16 | 17 | creation_plan { 18 | memory_limit_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 | resource "rediscloud_active_active_subscription_database" "example" { 36 | subscription_id = rediscloud_active_active_subscription.example.id 37 | name = local.rediscloud_subscription_name 38 | dataset_size_in_gb = 1 39 | global_data_persistence = "none" 40 | global_password = local.rediscloud_database_password 41 | 42 | override_region { 43 | name = "us-east-1" 44 | } 45 | 46 | override_region { 47 | name = "us-east-2" 48 | } 49 | } 50 | 51 | data "rediscloud_active_active_subscription_database" "example" { 52 | subscription_id = rediscloud_active_active_subscription.example.id 53 | name = rediscloud_active_active_subscription_database.example.name 54 | } 55 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_update.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | data "rediscloud_cloud_account" "account" { 12 | exclude_internal_account = true 13 | provider_type = "AWS" 14 | name = local.rediscloud_cloud_account 15 | } 16 | 17 | resource "rediscloud_subscription" "example" { 18 | name = local.rediscloud_subscription_name 19 | payment_method_id = data.rediscloud_payment_method.card.id 20 | cloud_provider { 21 | provider = data.rediscloud_cloud_account.account.provider_type 22 | cloud_account_id = data.rediscloud_cloud_account.account.id 23 | region { 24 | region = "eu-west-1" 25 | networking_deployment_cidr = "10.0.0.0/24" 26 | preferred_availability_zones = ["eu-west-1a"] 27 | } 28 | } 29 | 30 | creation_plan { 31 | dataset_size_in_gb = 1 32 | quantity = 1 33 | replication = false 34 | throughput_measurement_by = "operations-per-second" 35 | throughput_measurement_value = 1000 36 | } 37 | } 38 | 39 | resource "rediscloud_subscription_database" "example" { 40 | subscription_id = rediscloud_subscription.example.id 41 | name = "example-updated" 42 | protocol = "redis" 43 | dataset_size_in_gb = 1 44 | data_persistence = "aof-every-write" 45 | data_eviction = "volatile-lru" 46 | throughput_measurement_by = "operations-per-second" 47 | throughput_measurement_value = 2000 48 | password = "updated-password" 49 | support_oss_cluster_api = true 50 | external_endpoint_for_oss_cluster_api = true 51 | replication = true 52 | average_item_size_in_bytes = 0 53 | enable_default_user = true 54 | redis_version = "8.2" 55 | 56 | alert { 57 | name = "dataset-size" 58 | value = 80 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_auto_minor_version_upgrade.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | auto_minor_version_upgrade = %s 5 | } 6 | 7 | data "rediscloud_payment_method" "card" { 8 | card_type = "Visa" 9 | last_four_numbers = "5556" 10 | } 11 | 12 | data "rediscloud_cloud_account" "account" { 13 | exclude_internal_account = true 14 | provider_type = "AWS" 15 | name = local.rediscloud_cloud_account 16 | } 17 | 18 | resource "rediscloud_subscription" "example" { 19 | name = local.rediscloud_subscription_name 20 | payment_method_id = data.rediscloud_payment_method.card.id 21 | memory_storage = "ram" 22 | cloud_provider { 23 | provider = data.rediscloud_cloud_account.account.provider_type 24 | cloud_account_id = data.rediscloud_cloud_account.account.id 25 | region { 26 | region = "eu-west-1" 27 | networking_deployment_cidr = "10.0.0.0/24" 28 | preferred_availability_zones = ["eu-west-1a"] 29 | } 30 | } 31 | 32 | creation_plan { 33 | memory_limit_in_gb = 1 34 | quantity = 1 35 | replication = false 36 | throughput_measurement_by = "operations-per-second" 37 | throughput_measurement_value = 1000 38 | } 39 | } 40 | 41 | resource "rediscloud_subscription_database" "example" { 42 | subscription_id = rediscloud_subscription.example.id 43 | name = "auto-minor-version-upgrade-test" 44 | protocol = "redis" 45 | memory_limit_in_gb = 1 46 | data_persistence = "none" 47 | throughput_measurement_by = "operations-per-second" 48 | throughput_measurement_value = 1000 49 | auto_minor_version_upgrade = local.auto_minor_version_upgrade 50 | } 51 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/subscription_update.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_cloud_provider_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | resource "rediscloud_active_active_subscription" "example" { 12 | name = local.rediscloud_subscription_name 13 | payment_method_id = data.rediscloud_payment_method.card.id 14 | cloud_provider = local.rediscloud_cloud_provider_name 15 | 16 | maintenance_windows { 17 | mode = "automatic" 18 | } 19 | } 20 | 21 | data "rediscloud_active_active_subscription" "example" { 22 | name = rediscloud_active_active_subscription.example.name 23 | } 24 | 25 | resource "rediscloud_active_active_subscription_database" "example" { 26 | subscription_id = rediscloud_active_active_subscription.example.id 27 | name = local.rediscloud_subscription_name 28 | dataset_size_in_gb = 1 29 | global_data_persistence = "aof-every-1-second" 30 | global_password = "some-random-pass-2" 31 | global_source_ips = ["192.168.0.0/16"] 32 | global_alert { 33 | name = "dataset-size" 34 | value = 40 35 | } 36 | 37 | global_modules = ["RedisJSON"] 38 | global_enable_default_user = false 39 | 40 | override_region { 41 | name = "us-east-1" 42 | override_global_data_persistence = "none" 43 | override_global_password = "region-specific-password" 44 | override_global_alert { 45 | name = "dataset-size" 46 | value = 60 47 | } 48 | } 49 | 50 | override_region { 51 | name = "us-east-2" 52 | enable_default_user = false 53 | override_global_source_ips = ["192.10.0.0/16"] 54 | } 55 | 56 | tags = { 57 | "environment" = "production" 58 | "cost_center" = "0700" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/subscription_import_redis8.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | } 4 | 5 | data "rediscloud_payment_method" "card" { 6 | card_type = "Visa" 7 | last_four_numbers = "5556" 8 | } 9 | 10 | resource "rediscloud_active_active_subscription" "example" { 11 | name = local.rediscloud_subscription_name 12 | payment_method_id = data.rediscloud_payment_method.card.id 13 | cloud_provider = "AWS" 14 | redis_version = "8.2" 15 | 16 | maintenance_windows { 17 | mode = "automatic" 18 | } 19 | } 20 | 21 | data "rediscloud_active_active_subscription" "example" { 22 | name = rediscloud_active_active_subscription.example.name 23 | } 24 | 25 | resource "rediscloud_active_active_subscription_database" "example" { 26 | subscription_id = rediscloud_active_active_subscription.example.id 27 | name = local.rediscloud_subscription_name 28 | redis_version = "8.2" 29 | dataset_size_in_gb = 1 30 | global_data_persistence = "aof-every-1-second" 31 | global_password = "some-random-pass-2" 32 | global_source_ips = ["192.168.0.0/16"] 33 | global_alert { 34 | name = "dataset-size" 35 | value = 40 36 | } 37 | 38 | global_enable_default_user = false 39 | 40 | override_region { 41 | name = "us-east-1" 42 | override_global_data_persistence = "none" 43 | override_global_password = "region-specific-password" 44 | override_global_alert { 45 | name = "dataset-size" 46 | value = 60 47 | } 48 | } 49 | 50 | override_region { 51 | name = "us-east-2" 52 | enable_default_user = false 53 | override_global_source_ips = ["192.10.0.0/16"] 54 | } 55 | 56 | tags = { 57 | "environment" = "production" 58 | "cost_center" = "0700" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Provider: Redis Enterprise Cloud" 4 | description: |- 5 | The Redis Enterprise Cloud provider is used to interact with the resources supported by Redis Enterprise Cloud. The provider needs to be configured with the proper credentials before it can be used.. 6 | --- 7 | 8 | # Redis Enterprise Cloud Provider 9 | 10 | The Redis Enterprise Cloud provider is used to interact with the resources supported by Redis Enterprise Cloud . The provider needs to be configured with the proper credentials before it can be used. 11 | 12 | Use the navigation to the left to read about the available provider resources and data sources. 13 | 14 | ## Configure Redis Enterprise Cloud Programmatic Access 15 | 16 | In order to setup authentication with the Redis Enterprise Cloud provider a programmatic API key must be generated for Redis Enterprise Cloud. The [Redis Enterprise Cloud documentation](https://redis.io/docs/latest/integrate/terraform-provider-for-redis-cloud/) contains the most up-to-date instructions for creating and managing your key(s) and IP access. 17 | 18 | ## Example Usage 19 | 20 | ```hcl 21 | provider "rediscloud" { 22 | } 23 | 24 | # Example resource configuration 25 | resource "rediscloud_subscription" "example" { 26 | # ... 27 | } 28 | ``` 29 | 30 | ## Argument Reference 31 | 32 | In addition to [generic `provider` arguments](https://www.terraform.io/docs/configuration/providers.html) 33 | (e.g. `alias` and `version`), the following arguments are supported in the Redis Cloud 34 | `provider` block: 35 | 36 | * `api_key` - (Optional) This is the Redis Enterprise Cloud API key. It must be provided but can also be set by the 37 | `REDISCLOUD_ACCESS_KEY` environment variable. 38 | 39 | * `secret_key` - (Optional) This is the Redis Enterprise Cloud API secret key. It must be provided but can also be set 40 | by the `REDISCLOUD_SECRET_KEY` environment variable. 41 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_cloud_account.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_cloud_account" 4 | description: |- 5 | Cloud Account data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_cloud_account 9 | 10 | The Cloud Account data source allows access to the ID of a Cloud Account configuration. This ID can be 11 | used when creating Subscription resources. 12 | 13 | ## Example Usage 14 | 15 | The following example excludes the Redis Labs internal cloud account and returns only AWS related accounts. 16 | This example assumes there is only a single AWS cloud account defined. 17 | 18 | ```hcl-terraform 19 | data "rediscloud_cloud_account" "example" { 20 | exclude_internal_account = true 21 | provider_type = "AWS" 22 | } 23 | ``` 24 | 25 | If there is more than one AWS cloud account then the name attribute can be used to further filter the ID returned. 26 | This example looks for a cloud account named `test` and returns the cloud account ID and access key ID. 27 | 28 | ```hcl 29 | data "rediscloud_cloud_account" "example" { 30 | exclude_internal_account = true 31 | provider_type = "AWS" 32 | name = "test" 33 | } 34 | 35 | output "cloud_account_id" { 36 | value = data.rediscloud_cloud_account.example.id 37 | } 38 | 39 | output "cloud_account_access_key_id" { 40 | value = data.rediscloud_cloud_account.example.access_key_id 41 | } 42 | 43 | ``` 44 | 45 | ## Argument Reference 46 | 47 | * `exclude_internal_account` - (Optional) Whether to exclude the Redis Labs internal cloud account. 48 | 49 | * `provider_type` - (Optional) The cloud provider of the cloud account, (either `AWS` or `GCP`) 50 | 51 | * `name` - (Optional) A meaningful name to identify the cloud account 52 | 53 | ## Attributes Reference 54 | 55 | `id` is set to the ID of the found cloud account. 56 | 57 | * `access_key_id` The access key ID associated with the cloud account 58 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_active_active_transit_gateway_attachment.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_transit_gateway_attachment" 4 | description: |- 5 | Transit Gateway Attachment resource in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_transit_gateway_attachment 9 | 10 | Manages a Transit Gateway Attachment to an Active Active Subscription in your Redis Enterprise Cloud Account. 11 | 12 | ```hcl 13 | data "rediscloud_transit_gateway" "gateway" { 14 | subscription_id = "113492" 15 | aws_tgw_id = "tgw-1c55bfdoe20pdsad2" 16 | } 17 | 18 | resource "rediscloud_active_active_transit_gateway_attachment" "attachment" { 19 | subscription_id = "113492" 20 | region_id = 1 21 | tgw_id = data.rediscloud_transit_gateway.gateway.tgw_id 22 | } 23 | ``` 24 | 25 | ## Argument Reference 26 | 27 | * `subscription_id` - (Required) The id of the Pro/Flexible subscription to attach 28 | * `region_id` - (Required) The id of the AWS region 29 | * `tgw_id` - (Required) The id of the Transit Gateway to attach to 30 | * `cidrs` - (Optional) A list of consumer Cidr blocks. **May only be added once the Attachment has been accepted** 31 | 32 | ## Attribute Reference 33 | 34 | * `aws_tgw_uid` - The id of the Transit Gateway as known to AWS 35 | * `attachment_uid` - A unique identifier for the Subscription/Transit Gateway attachment, if established 36 | * `status` - The status of the Transit Gateway 37 | * `attachment_status` - The status of the Subscription/Transit Gateway attachment, if established 38 | * `aws_account_id` - The Transit Gateway's AWS account id 39 | 40 | ## Import 41 | `rediscloud_active_active_transit_gateway_attachment` can be imported using the ID of the Active-Active subscription, region ID, and Transit Gateway ID in the format {subscription_id}/{region_id}/{tgw_id}, e.g. 42 | 43 | ``` 44 | $ terraform import rediscloud_active_active_transit_gateway_attachment.tgwa-resource 123456/1/47 45 | ``` 46 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/subscription_import_redis7.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | } 4 | 5 | data "rediscloud_payment_method" "card" { 6 | card_type = "Visa" 7 | last_four_numbers = "5556" 8 | } 9 | 10 | resource "rediscloud_active_active_subscription" "example" { 11 | name = local.rediscloud_subscription_name 12 | payment_method_id = data.rediscloud_payment_method.card.id 13 | cloud_provider = "AWS" 14 | redis_version = "7.4" 15 | 16 | maintenance_windows { 17 | mode = "automatic" 18 | } 19 | } 20 | 21 | data "rediscloud_active_active_subscription" "example" { 22 | name = rediscloud_active_active_subscription.example.name 23 | } 24 | 25 | resource "rediscloud_active_active_subscription_database" "example" { 26 | subscription_id = rediscloud_active_active_subscription.example.id 27 | name = local.rediscloud_subscription_name 28 | redis_version = "7.4" 29 | dataset_size_in_gb = 1 30 | global_data_persistence = "aof-every-1-second" 31 | global_password = "some-random-pass-2" 32 | global_source_ips = ["192.168.0.0/16"] 33 | global_alert { 34 | name = "dataset-size" 35 | value = 40 36 | } 37 | 38 | global_modules = ["RedisJSON"] 39 | global_enable_default_user = false 40 | 41 | override_region { 42 | name = "us-east-1" 43 | override_global_data_persistence = "none" 44 | override_global_password = "region-specific-password" 45 | override_global_alert { 46 | name = "dataset-size" 47 | value = 60 48 | } 49 | } 50 | 51 | override_region { 52 | name = "us-east-2" 53 | enable_default_user = false 54 | override_global_source_ips = ["192.10.0.0/16"] 55 | } 56 | 57 | tags = { 58 | "environment" = "production" 59 | "cost_center" = "0700" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Hi there, 2 | 3 | Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html. 4 | 5 | ### Terraform Version 6 | Run `terraform -v` to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed. 7 | 8 | ### Affected Resource(s) 9 | Please list the resources as a list, for example: 10 | - opc_instance 11 | - opc_storage_volume 12 | 13 | If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this. 14 | 15 | ### Terraform Configuration Files 16 | ```hcl 17 | # Copy-paste your Terraform configurations here - for large Terraform configs, 18 | # please use a service like Dropbox and share a link to the ZIP file. For 19 | # security, you can also encrypt the files using our GPG public key. 20 | ``` 21 | 22 | ### Debug Output 23 | Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist. 24 | 25 | ### Panic Output 26 | If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the `crash.log`. 27 | 28 | ### Expected Behavior 29 | What should have happened? 30 | 31 | ### Actual Behavior 32 | What actually happened? 33 | 34 | ### Steps to Reproduce 35 | Please list the steps required to reproduce the issue, for example: 36 | 1. `terraform apply` 37 | 38 | ### Important Factoids 39 | Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs? 40 | 41 | ### References 42 | Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example: 43 | - GH-1234 44 | -------------------------------------------------------------------------------- /provider/pro/utils.go: -------------------------------------------------------------------------------- 1 | package pro 2 | 3 | import ( 4 | "context" 5 | "strings" 6 | 7 | "github.com/RedisLabs/rediscloud-go-api/redis" 8 | redisTags "github.com/RedisLabs/rediscloud-go-api/service/tags" 9 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/client" 10 | "github.com/hashicorp/go-cty/cty" 11 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 12 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 13 | ) 14 | 15 | func ReadTags(ctx context.Context, api *client.ApiClient, subId int, databaseId int, d *schema.ResourceData) error { 16 | tags := make(map[string]string) 17 | tagResponse, err := api.Client.Tags.Get(ctx, subId, databaseId) 18 | if err != nil { 19 | return err 20 | } 21 | if tagResponse.Tags != nil { 22 | for _, t := range *tagResponse.Tags { 23 | tags[redis.StringValue(t.Key)] = redis.StringValue(t.Value) 24 | } 25 | } 26 | return d.Set("tags", tags) 27 | } 28 | 29 | func WriteTags(ctx context.Context, api *client.ApiClient, subId int, databaseId int, d *schema.ResourceData) error { 30 | tags := make([]*redisTags.Tag, 0) 31 | tState := d.Get("tags").(map[string]interface{}) 32 | for k, v := range tState { 33 | tags = append(tags, &redisTags.Tag{ 34 | Key: redis.String(k), 35 | Value: redis.String(v.(string)), 36 | }) 37 | } 38 | return api.Client.Tags.Put(ctx, subId, databaseId, redisTags.AllTags{Tags: &tags}) 39 | } 40 | 41 | func ValidateTagsfunc(tagsRaw interface{}, _ cty.Path) diag.Diagnostics { 42 | tags := tagsRaw.(map[string]interface{}) 43 | invalid := make([]string, 0) 44 | for k, v := range tags { 45 | if k != strings.ToLower(k) { 46 | invalid = append(invalid, k) 47 | } 48 | vStr := v.(string) 49 | if vStr != strings.ToLower(vStr) { 50 | invalid = append(invalid, vStr) 51 | } 52 | } 53 | 54 | if len(invalid) > 0 { 55 | return diag.Errorf("tag keys and values must be lower case, invalid entries: %s", strings.Join(invalid, ", ")) 56 | } 57 | return nil 58 | } 59 | -------------------------------------------------------------------------------- /provider/privatelink/testdata/private_link_update.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_cloud_account = "%s" 4 | rediscloud_private_link_share_name = "%s" 5 | } 6 | 7 | data "rediscloud_payment_method" "card" { 8 | card_type = "Visa" 9 | last_four_numbers = "5556" 10 | } 11 | 12 | data "rediscloud_cloud_account" "account" { 13 | exclude_internal_account = true 14 | provider_type = "AWS" 15 | name = local.rediscloud_cloud_account 16 | } 17 | 18 | resource "rediscloud_subscription" "pro_subscription" { 19 | name = local.rediscloud_subscription_name 20 | payment_method_id = data.rediscloud_payment_method.card.id 21 | 22 | cloud_provider { 23 | provider = data.rediscloud_cloud_account.account.provider_type 24 | cloud_account_id = data.rediscloud_cloud_account.account.id 25 | region { 26 | region = "eu-west-1" 27 | networking_deployment_cidr = "10.0.0.0/24" 28 | preferred_availability_zones = ["eu-west-1a"] 29 | } 30 | } 31 | 32 | creation_plan { 33 | dataset_size_in_gb = 1 34 | quantity = 1 35 | replication = true 36 | throughput_measurement_by = "operations-per-second" 37 | throughput_measurement_value = 20000 38 | } 39 | } 40 | 41 | resource "rediscloud_private_link" "private_link" { 42 | subscription_id = rediscloud_subscription.pro_subscription.id 43 | share_name = local.rediscloud_private_link_share_name 44 | 45 | # principal { 46 | # principal = local.rediscloud_principal_1 47 | # principal_type = "aws_account" 48 | # principal_alias = "terraform test aws account" 49 | # } 50 | 51 | principal { 52 | principal = "234567890123" 53 | principal_type = "aws_account" 54 | principal_alias = "terraform test aws account 2" 55 | } 56 | } 57 | 58 | data "rediscloud_private_link" "private_link" { 59 | subscription_id = rediscloud_private_link.private_link.subscription_id 60 | } 61 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_private_service_connect_endpoints.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_private_service_connect_endpoints" 4 | description: |- 5 | Private Service Connect Endpoints data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_private_service_connect_endpoints 9 | 10 | The Private Service Connect Endpoints data source allows access to an available the endpoints within your Redis Enterprise Subscription. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_private_service_connect_endpoints" "example" { 16 | subscription_id = "1234" 17 | private_service_connect_service_id = 5678 18 | } 19 | 20 | output "rediscloud_endpoints" { 21 | value = data.rediscloud_private_service_connect.example.endpoints 22 | } 23 | ``` 24 | 25 | ## Argument Reference 26 | 27 | * `subscription_id` - (Required) The ID of a Pro subscription 28 | * `private_service_connect_service_id` - (Required) The ID of the Private Service Connect Service relative to the associated subscription 29 | 30 | ## Attribute Reference 31 | 32 | * `endpoints` - List of Private Service Connect endpoints, documented below 33 | 34 | The `endpoints` object has these attributes: 35 | 36 | * `private_service_connect_endpoint_id` - The ID of the Private Service Connect endpoint 37 | * `gcp_project_id` - The Google Cloud Project ID 38 | * `gcp_vpc_name` - The GCP VPC name 39 | * `gcp_vpc_subnet_name` - The GCP Subnet name 40 | * `endpoint_connection_name` - The endpoint connection name 41 | * `status` - The endpoint status 42 | * `service_attachments` - The service attachments that are created for the Private Service Connect endpoint, documented below 43 | 44 | The `service_attachments` object has these attributes: 45 | 46 | * `name` - Name of the service attachment 47 | * `dns_record` - DNS record for the service attachment 48 | * `ip_address_name` - IP address name for the service attachment 49 | * `forwarding_rule_name` - Name of the forwarding rule for the service attachment 50 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/subscription_update_redis7.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_cloud_provider_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | resource "rediscloud_active_active_subscription" "example" { 12 | name = local.rediscloud_subscription_name 13 | payment_method_id = data.rediscloud_payment_method.card.id 14 | cloud_provider = local.rediscloud_cloud_provider_name 15 | redis_version = "7.4" 16 | 17 | maintenance_windows { 18 | mode = "automatic" 19 | } 20 | } 21 | 22 | data "rediscloud_active_active_subscription" "example" { 23 | name = rediscloud_active_active_subscription.example.name 24 | } 25 | 26 | resource "rediscloud_active_active_subscription_database" "example" { 27 | subscription_id = rediscloud_active_active_subscription.example.id 28 | name = local.rediscloud_subscription_name 29 | redis_version = "7.4" 30 | dataset_size_in_gb = 1 31 | global_data_persistence = "aof-every-1-second" 32 | global_password = "some-random-pass-2" 33 | global_source_ips = ["192.168.0.0/16"] 34 | global_alert { 35 | name = "dataset-size" 36 | value = 40 37 | } 38 | 39 | global_modules = ["RedisJSON"] 40 | global_enable_default_user = false 41 | 42 | override_region { 43 | name = "us-east-1" 44 | override_global_data_persistence = "none" 45 | override_global_password = "region-specific-password" 46 | override_global_alert { 47 | name = "dataset-size" 48 | value = 60 49 | } 50 | } 51 | 52 | override_region { 53 | name = "us-east-2" 54 | enable_default_user = false 55 | override_global_source_ips = ["192.10.0.0/16"] 56 | } 57 | 58 | tags = { 59 | "environment" = "production" 60 | "cost_center" = "0700" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /provider/transitgateway/helpers.go: -------------------------------------------------------------------------------- 1 | package transitgateway 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | // ParseTransitGatewayAttachmentId parses a Pro TGW attachment ID with format "subscription_id/tgw_id". 10 | func ParseTransitGatewayAttachmentId(id string) (subscriptionId int, tgwId int, err error) { 11 | parts := strings.Split(id, "/") 12 | if len(parts) != 2 { 13 | return 0, 0, fmt.Errorf("unexpected format of ID (%q), expected /", id) 14 | } 15 | 16 | subscriptionId, err = strconv.Atoi(parts[0]) 17 | if err != nil { 18 | return 0, 0, fmt.Errorf("failed to parse subscription_id: %w", err) 19 | } 20 | tgwId, err = strconv.Atoi(parts[1]) 21 | if err != nil { 22 | return 0, 0, fmt.Errorf("failed to parse tgw_id: %w", err) 23 | } 24 | 25 | return subscriptionId, tgwId, nil 26 | } 27 | 28 | // ParseActiveActiveTransitGatewayAttachmentId parses an AA TGW attachment ID with format "subscription_id/region_id/tgw_id". 29 | func ParseActiveActiveTransitGatewayAttachmentId(id string) (subscriptionId int, regionId int, tgwId int, err error) { 30 | parts := strings.Split(id, "/") 31 | if len(parts) != 3 { 32 | return 0, 0, 0, fmt.Errorf("unexpected format of ID (%q), expected //", id) 33 | } 34 | 35 | subscriptionId, err = strconv.Atoi(parts[0]) 36 | if err != nil { 37 | return 0, 0, 0, fmt.Errorf("failed to parse subscription_id: %w", err) 38 | } 39 | regionId, err = strconv.Atoi(parts[1]) 40 | if err != nil { 41 | return 0, 0, 0, fmt.Errorf("failed to parse region_id: %w", err) 42 | } 43 | tgwId, err = strconv.Atoi(parts[2]) 44 | if err != nil { 45 | return 0, 0, 0, fmt.Errorf("failed to parse tgw_id: %w", err) 46 | } 47 | 48 | return subscriptionId, regionId, tgwId, nil 49 | } 50 | 51 | // BuildActiveActiveTransitGatewayAttachmentId builds an AA TGW attachment ID with format "subscription_id/region_id/tgw_id". 52 | func BuildActiveActiveTransitGatewayAttachmentId(subscriptionId, regionId, tgwId int) string { 53 | return fmt.Sprintf("%d/%d/%d", subscriptionId, regionId, tgwId) 54 | } 55 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_private_link.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_private_link" 4 | description: |- 5 | PrivateLink data source for Pro Subscription in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_private_link 9 | Retrieves details of an existing PrivateLink for a Pro Subscription. 10 | 11 | ## Example Usage 12 | 13 | ```hcl 14 | data "rediscloud_private_link" "example" { 15 | subscription_id = "1234" 16 | } 17 | 18 | output "rediscloud_private_link_principals" { 19 | value = data.rediscloud_private_link.example.principals 20 | } 21 | ``` 22 | 23 | ## Argument Reference 24 | 25 | * `subscription_id` - (Required) The ID of the Pro Subscription the PrivateLink is attached to. 26 | 27 | ## Attribute Reference 28 | 29 | * `principals` - A list of principals attached to the PrivateLink. 30 | * `resource_configuration_id` - The ID of the resource configuration attached to this PrivateLink. 31 | * `resource_configuration_arn` - The ARN of the resource configuration attached to this PrivateLink. 32 | * `share_arn` - The share ARN of this PrivateLink. 33 | * `connections` - A list of connections associated with the PrivateLink. 34 | * `databases` - A list of databases associated with the PrivateLink. 35 | 36 | The `principals` object supports the following attributes: 37 | * `principal` - The principal attached to this PrivateLink. 38 | * `principal_type` - The type of principal. 39 | * `principal_alias` - A friendly name for the principal. 40 | 41 | The `connections` object supports the following attributes: 42 | * `association_id` - The association ID of the PrivateLink connection. 43 | * `connection_id` - The connection ID of the PrivateLink connection. 44 | * `connection_type` - The type of the PrivateLink connection. 45 | * `owner_id` - The owner ID of the connection. 46 | * `association_date` - The date the connection was associated. 47 | 48 | The `databases` object supports the following attributes: 49 | * `database_id` - The ID of the database. 50 | * `port` - The port the database is available on. 51 | * `resource_link_endpoint` - The resource link endpoint for the database. 52 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_subscription_public_endpoint_disabled.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_database_password = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | resource "rediscloud_subscription" "example" { 12 | name = local.rediscloud_subscription_name 13 | payment_method_id = data.rediscloud_payment_method.card.id 14 | public_endpoint_access = false 15 | 16 | cloud_provider { 17 | provider = "AWS" 18 | region { 19 | region = "eu-west-1" 20 | networking_deployment_cidr = "10.0.0.0/24" 21 | } 22 | } 23 | 24 | creation_plan { 25 | dataset_size_in_gb = 1 26 | quantity = 1 27 | replication = false 28 | throughput_measurement_by = "operations-per-second" 29 | throughput_measurement_value = 1000 30 | } 31 | } 32 | 33 | 34 | resource "rediscloud_subscription_database" "example" { 35 | subscription_id = rediscloud_subscription.example.id 36 | name = local.rediscloud_subscription_name 37 | protocol = "redis" 38 | dataset_size_in_gb = 1 39 | data_persistence = "none" 40 | data_eviction = "allkeys-random" 41 | throughput_measurement_by = "operations-per-second" 42 | throughput_measurement_value = 1000 43 | password = local.rediscloud_database_password 44 | support_oss_cluster_api = false 45 | external_endpoint_for_oss_cluster_api = false 46 | replication = false 47 | average_item_size_in_bytes = 0 48 | client_ssl_certificate = "" 49 | enable_default_user = true 50 | redis_version = "8.2" 51 | 52 | alert { 53 | name = "dataset-size" 54 | value = 1 55 | } 56 | } 57 | 58 | data "rediscloud_database" "example" { 59 | subscription_id = rediscloud_subscription.example.id 60 | name = rediscloud_subscription_database.example.name 61 | } 62 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_subscription_peerings.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_subscription_peerings" 4 | description: |- 5 | Subscription Peerings data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | 9 | # Data Source: rediscloud_subscription_peerings 10 | 11 | The Subscription Peerings data source allows access to a list of VPC peerings for a particular subscription. 12 | 13 | ## Example Usage 14 | 15 | The following example returns a list of all VPC peering within a Subscription. 16 | 17 | ```hcl-terraform 18 | data "rediscloud_subscription_peerings" "example" { 19 | subscription_id = "1234" 20 | } 21 | 22 | output "rediscloud_subscription_peerings" { 23 | value = data.rediscloud_subscription_peerings.example.peerings 24 | } 25 | ``` 26 | 27 | ## Argument Reference 28 | 29 | * `subscription_id` - (Required) ID of the subscription that the peerings belongs to 30 | * `status` - (Optional) Current status of the peering - `initiating-request`, `pending-acceptance`, `active`, `inactive` or `failed`. 31 | 32 | ## Attributes Reference 33 | 34 | * `peerings` A list of subscription peerings. 35 | 36 | Each peering entry provides the following attributes 37 | 38 | * `peering_id` - ID of the subscription peering 39 | * `provider_name` - The name of the cloud provider. (either `AWS` or `GCP`) 40 | * `status` Current status of the peering - `initiating-request`, `pending-acceptance`, `active`, `inactive` or `failed`. 41 | 42 | **AWS ONLY:** 43 | 44 | * `aws_account_id` AWS account id that the VPC to be peered lives in 45 | * `vpc_id` Identifier of the VPC to be peered 46 | * `vpc_cidr` CIDR range of the VPC to be peered 47 | * `aws_peering_id` Identifier of the AWS cloud peering 48 | * `region` AWS Region that the VPC to be peered lives in 49 | 50 | **GCP ONLY:** 51 | * `gcp_project_id` GCP project ID that the VPC to be peered lives in 52 | * `gcp_network_name` The name of the network to be peered 53 | * `gcp_redis_project_id` Identifier of the Redis Enterprise Cloud GCP project to be peered 54 | * `gcp_redis_network_name` - The name of the Redis Enterprise Cloud network to be peered 55 | * `gcp_peering_id` - Identifier of the cloud peering 56 | -------------------------------------------------------------------------------- /provider/privatelink/datasource_rediscloud_active_active_endpoint_script.go: -------------------------------------------------------------------------------- 1 | package privatelink 2 | 3 | import ( 4 | "context" 5 | "github.com/RedisLabs/rediscloud-go-api/redis" 6 | "strconv" 7 | 8 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/client" 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 10 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 11 | ) 12 | 13 | func DataSourceActiveActivePrivateLinkEndpointScript() *schema.Resource { 14 | return &schema.Resource{ 15 | Description: "The Active Active PrivateLink Endpoint Script data source allows users to request an endpoint script for an Active Active Subscription PrivateLink", 16 | ReadContext: dataSourceActiveActivePrivateLinkScriptRead, 17 | 18 | Schema: map[string]*schema.Schema{ 19 | "subscription_id": { 20 | Description: "The ID of an Active Active subscription", 21 | Type: schema.TypeString, 22 | Required: true, 23 | }, 24 | "region_id": { 25 | Description: "The ID of an Active Active subscription region", 26 | Type: schema.TypeInt, 27 | Required: true, 28 | }, 29 | "endpoint_script": { 30 | Description: "The endpoint script for the PrivateLink", 31 | Type: schema.TypeString, 32 | Computed: true, 33 | }, 34 | }, 35 | } 36 | } 37 | 38 | func dataSourceActiveActivePrivateLinkScriptRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 39 | var diags diag.Diagnostics 40 | api := meta.(*client.ApiClient) 41 | 42 | subId, err := strconv.Atoi(d.Get("subscription_id").(string)) 43 | if err != nil { 44 | return diag.FromErr(err) 45 | } 46 | 47 | regionId := d.Get("region_id").(int) 48 | 49 | endpointScript, err := api.Client.PrivateLink.GetActiveActivePrivateLinkEndpointScript(ctx, subId, regionId) 50 | if err != nil { 51 | return diag.FromErr(err) 52 | } 53 | 54 | d.SetId(strconv.Itoa(subId)) 55 | 56 | if endpointScript != nil && endpointScript.ResourceEndpointScript != nil { 57 | err = d.Set("endpoint_script", redis.StringValue(endpointScript.ResourceEndpointScript)) 58 | if err != nil { 59 | return diag.FromErr(err) 60 | } 61 | } 62 | 63 | return diags 64 | } 65 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | rediscloud_database_password = "%s" 5 | } 6 | 7 | data "rediscloud_payment_method" "card" { 8 | card_type = "Visa" 9 | last_four_numbers = "5556" 10 | } 11 | 12 | data "rediscloud_cloud_account" "account" { 13 | exclude_internal_account = true 14 | provider_type = "AWS" 15 | name = local.rediscloud_cloud_account 16 | } 17 | 18 | resource "rediscloud_subscription" "example" { 19 | name = local.rediscloud_subscription_name 20 | payment_method_id = data.rediscloud_payment_method.card.id 21 | cloud_provider { 22 | provider = data.rediscloud_cloud_account.account.provider_type 23 | cloud_account_id = data.rediscloud_cloud_account.account.id 24 | region { 25 | region = "eu-west-1" 26 | networking_deployment_cidr = "10.0.0.0/24" 27 | preferred_availability_zones = ["eu-west-1a"] 28 | } 29 | } 30 | 31 | creation_plan { 32 | dataset_size_in_gb = 1 33 | quantity = 1 34 | replication = false 35 | throughput_measurement_by = "operations-per-second" 36 | throughput_measurement_value = 1000 37 | } 38 | } 39 | 40 | resource "rediscloud_subscription_database" "example" { 41 | subscription_id = rediscloud_subscription.example.id 42 | name = "example" 43 | protocol = "redis" 44 | dataset_size_in_gb = 3 45 | data_persistence = "none" 46 | data_eviction = "allkeys-random" 47 | throughput_measurement_by = "operations-per-second" 48 | throughput_measurement_value = 1000 49 | password = local.rediscloud_database_password 50 | support_oss_cluster_api = false 51 | external_endpoint_for_oss_cluster_api = false 52 | replication = false 53 | average_item_size_in_bytes = 0 54 | client_ssl_certificate = "" 55 | periodic_backup_path = "" 56 | enable_default_user = true 57 | redis_version = "7.4" 58 | 59 | alert { 60 | name = "dataset-size" 61 | value = 1 62 | } 63 | 64 | modules = [ 65 | { 66 | name = "RedisBloom" 67 | } 68 | ] 69 | 70 | tags = { 71 | "market" = "emea" 72 | "material" = "cardboard" 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_active_active_private_service_connect_endpoints.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_active_active_private_service_connect_endpoints" 4 | description: |- 5 | Active-Active Private Service Connect Endpoints data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_active_active_private_service_connect_endpoints 9 | 10 | The Active-Active Private Service Connect Endpoints data source allows access to an available the endpoints within your Redis Enterprise Subscription. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_active_active_private_service_connect_endpoints" "example" { 16 | subscription_id = "1234" 17 | private_service_connect_service_id = 5678 18 | region_id = 1 19 | } 20 | 21 | output "rediscloud_endpoints" { 22 | value = data.rediscloud_active_active_private_service_connect.example.endpoints 23 | } 24 | ``` 25 | 26 | ## Argument Reference 27 | 28 | * `subscription_id` - (Required) The ID of an Active-Active subscription 29 | * `private_service_connect_service_id` - (Required) The ID of the Private Service Connect Service relative to the associated subscription 30 | * `region_id` - (Required) The ID of the GCP region 31 | 32 | ## Attribute Reference 33 | 34 | * `endpoints` - List of Private Service Connect endpoints, documented below 35 | 36 | The `endpoints` object has these attributes: 37 | 38 | * `private_service_connect_endpoint_id` - The ID of the Private Service Connect endpoint 39 | * `gcp_project_id` - The Google Cloud Project ID 40 | * `gcp_vpc_name` - The GCP VPC name 41 | * `gcp_vpc_subnet_name` - The GCP Subnet name 42 | * `endpoint_connection_name` - The endpoint connection name 43 | * `status` - The endpoint status 44 | * `service_attachments` - The 40 service attachments that are created for the Private Service Connect endpoint, documented below 45 | 46 | The `service_attachments` object has these attributes: 47 | 48 | * `name` - Name of the service attachment 49 | * `dns_record` - DNS record for the service attachment 50 | * `ip_address_name` - IP address name for the service attachment 51 | * `forwarding_rule_name` - Name of the forwarding rule for the service attachment 52 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_upgrade.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | redis_version = "%s" 5 | } 6 | 7 | data "rediscloud_payment_method" "card" { 8 | card_type = "Visa" 9 | last_four_numbers = "5556" 10 | } 11 | 12 | data "rediscloud_cloud_account" "account" { 13 | exclude_internal_account = true 14 | provider_type = "AWS" 15 | name = local.rediscloud_cloud_account 16 | } 17 | 18 | resource "rediscloud_subscription" "example" { 19 | name = local.rediscloud_subscription_name 20 | payment_method_id = data.rediscloud_payment_method.card.id 21 | memory_storage = "ram" 22 | 23 | allowlist { 24 | cidrs = ["192.168.0.0/16"] 25 | security_group_ids = [] 26 | } 27 | 28 | cloud_provider { 29 | provider = data.rediscloud_cloud_account.account.provider_type 30 | cloud_account_id = data.rediscloud_cloud_account.account.id 31 | region { 32 | region = "eu-west-1" 33 | networking_deployment_cidr = "10.0.0.0/24" 34 | preferred_availability_zones = ["eu-west-1a"] 35 | } 36 | } 37 | 38 | creation_plan { 39 | dataset_size_in_gb = 1 40 | throughput_measurement_by = "operations-per-second" 41 | throughput_measurement_value = 1000 42 | quantity = 1 43 | replication=false 44 | support_oss_cluster_api=false 45 | modules = [] 46 | } 47 | } 48 | 49 | resource "rediscloud_subscription_database" "example" { 50 | subscription_id = rediscloud_subscription.example.id 51 | name = "example" 52 | protocol = "redis" 53 | dataset_size_in_gb = 1 54 | data_persistence = "none" 55 | data_eviction = "allkeys-random" 56 | throughput_measurement_by = "operations-per-second" 57 | throughput_measurement_value = 1000 58 | support_oss_cluster_api = false 59 | external_endpoint_for_oss_cluster_api = false 60 | replication = false 61 | average_item_size_in_bytes = 0 62 | client_ssl_certificate = "" 63 | periodic_backup_path = "" 64 | enable_default_user = true 65 | redis_version = local.redis_version 66 | 67 | alert { 68 | name = "dataset-size" 69 | value = 1 70 | } 71 | 72 | tags = { 73 | "market" = "emea" 74 | "material" = "cardboard" 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_transit_gateway_invitation_acceptor.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_transit_gateway_invitation_acceptor" 4 | description: |- 5 | Transit Gateway Invitation Acceptor resource for a Pro Subscription in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_transit_gateway_invitation_acceptor 9 | 10 | Manages the acceptance or rejection of a Transit Gateway invitation in your Redis Enterprise Cloud Account. Transit Gateway invitations are created when an AWS Resource Share shares a Transit Gateway with your subscription. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_transit_gateway_invitations" "example" { 16 | subscription_id = rediscloud_subscription.example.id 17 | } 18 | 19 | resource "rediscloud_transit_gateway_invitation_acceptor" "example" { 20 | subscription_id = rediscloud_subscription.example.id 21 | tgw_invitation_id = data.rediscloud_transit_gateway_invitations.example.invitations[0].id 22 | action = "accept" 23 | } 24 | ``` 25 | 26 | ## Argument Reference 27 | 28 | * `subscription_id` - (Required) The ID of the Pro subscription. **Modifying this attribute will force creation of a new resource.** 29 | * `tgw_invitation_id` - (Required) The ID of the Transit Gateway invitation to accept or reject. **Modifying this attribute will force creation of a new resource.** 30 | * `action` - (Required) Accept or reject the invitation. Accepted values are `accept` and `reject`. 31 | 32 | ## Attribute Reference 33 | 34 | * `name` - The name of the resource share 35 | * `resource_share_uid` - The AWS Resource Share ARN 36 | * `aws_account_id` - The AWS account ID that shared the Transit Gateway 37 | * `status` - The status of the invitation 38 | * `shared_date` - The date the resource was shared 39 | 40 | ## Import 41 | 42 | `rediscloud_transit_gateway_invitation_acceptor` can be imported using the format `{subscription_id}/{tgw_invitation_id}`, e.g. 43 | 44 | ``` 45 | $ terraform import rediscloud_transit_gateway_invitation_acceptor.example 123456/7890 46 | ``` 47 | 48 | **Note:** After import, you must add the `action` attribute to your configuration (e.g., `action = "accept"`) as this value is not stored in the API. 49 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_subscription_public_endpoint_enabled.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_database_password = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | resource "rediscloud_subscription" "example" { 12 | name = local.rediscloud_subscription_name 13 | payment_method_id = data.rediscloud_payment_method.card.id 14 | public_endpoint_access = true 15 | 16 | cloud_provider { 17 | provider = "AWS" 18 | region { 19 | region = "eu-west-1" 20 | networking_deployment_cidr = "10.0.0.0/24" 21 | } 22 | } 23 | 24 | creation_plan { 25 | dataset_size_in_gb = 1 26 | quantity = 1 27 | replication = false 28 | throughput_measurement_by = "operations-per-second" 29 | throughput_measurement_value = 1000 30 | } 31 | } 32 | 33 | resource "rediscloud_subscription_database" "example" { 34 | subscription_id = rediscloud_subscription.example.id 35 | name = local.rediscloud_subscription_name 36 | protocol = "redis" 37 | dataset_size_in_gb = 1 38 | data_persistence = "none" 39 | data_eviction = "allkeys-random" 40 | throughput_measurement_by = "operations-per-second" 41 | throughput_measurement_value = 1000 42 | password = local.rediscloud_database_password 43 | support_oss_cluster_api = false 44 | external_endpoint_for_oss_cluster_api = false 45 | replication = false 46 | average_item_size_in_bytes = 0 47 | client_ssl_certificate = "" 48 | enable_default_user = true 49 | redis_version = "8.2" 50 | 51 | alert { 52 | name = "dataset-size" 53 | value = 1 54 | } 55 | } 56 | 57 | data "rediscloud_database" "example" { 58 | subscription_id = rediscloud_subscription.example.id 59 | name = rediscloud_subscription_database.example.name 60 | } 61 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_multi_modules.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | database_name = "%s" 5 | } 6 | 7 | data "rediscloud_payment_method" "card" { 8 | card_type = "Visa" 9 | last_four_numbers = "5556" 10 | } 11 | 12 | data "rediscloud_cloud_account" "account" { 13 | exclude_internal_account = true 14 | provider_type = "AWS" 15 | name = local.rediscloud_cloud_account 16 | } 17 | 18 | resource "rediscloud_subscription" "example" { 19 | name = local.rediscloud_subscription_name 20 | payment_method_id = data.rediscloud_payment_method.card.id 21 | memory_storage = "ram" 22 | redis_version = "7.4" 23 | allowlist { 24 | cidrs = ["192.168.0.0/16"] 25 | security_group_ids = [] 26 | } 27 | cloud_provider { 28 | provider = data.rediscloud_cloud_account.account.provider_type 29 | cloud_account_id = data.rediscloud_cloud_account.account.id 30 | region { 31 | region = "eu-west-1" 32 | networking_deployment_cidr = "10.0.0.0/24" 33 | preferred_availability_zones = ["eu-west-1a"] 34 | } 35 | } 36 | creation_plan { 37 | dataset_size_in_gb = 1 38 | quantity = 1 39 | replication = false 40 | support_oss_cluster_api = false 41 | throughput_measurement_by = "operations-per-second" 42 | throughput_measurement_value = 1000 43 | modules = ["RedisJSON", "RedisBloom"] 44 | } 45 | } 46 | 47 | resource "rediscloud_subscription_database" "example" { 48 | subscription_id = rediscloud_subscription.example.id 49 | name = local.database_name 50 | protocol = "redis" 51 | dataset_size_in_gb = 1 52 | data_persistence = "none" 53 | throughput_measurement_by = "operations-per-second" 54 | throughput_measurement_value = 1000 55 | modules = [ 56 | { 57 | name = "RedisJSON" 58 | }, 59 | { 60 | name = "RedisBloom" 61 | } 62 | ] 63 | alert { 64 | name = "latency" 65 | value = 11 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /provider/privatelink/datasource_rediscloud_endpoint_script.go: -------------------------------------------------------------------------------- 1 | package privatelink 2 | 3 | import ( 4 | "context" 5 | "github.com/RedisLabs/rediscloud-go-api/redis" 6 | "strconv" 7 | 8 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/client" 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 10 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 11 | ) 12 | 13 | func DataSourcePrivateLinkEndpointScript() *schema.Resource { 14 | return &schema.Resource{ 15 | Description: "The PrivateLink Endpoint Script data source allows users to request an endpoint script for a pro subscription PrivateLink", 16 | ReadContext: dataSourcePrivateLinkScriptRead, 17 | 18 | Schema: map[string]*schema.Schema{ 19 | "subscription_id": { 20 | Description: "The ID of a Pro subscription", 21 | Type: schema.TypeString, 22 | Required: true, 23 | }, 24 | "endpoint_script": { 25 | Description: "The endpoint script for the PrivateLink", 26 | Type: schema.TypeString, 27 | Computed: true, 28 | }, 29 | }, 30 | } 31 | } 32 | 33 | func dataSourcePrivateLinkScriptRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 34 | var diags diag.Diagnostics 35 | api := meta.(*client.ApiClient) 36 | 37 | subId, err := strconv.Atoi(d.Get("subscription_id").(string)) 38 | if err != nil { 39 | return diag.FromErr(err) 40 | } 41 | 42 | // check if sub and privatelink exist first 43 | subscription, err := api.Client.Subscription.Get(ctx, subId) 44 | 45 | if err != nil || subscription == nil { 46 | return diag.FromErr(err) 47 | } 48 | 49 | privateLink, err := api.Client.PrivateLink.GetPrivateLink(ctx, subId) 50 | 51 | if err != nil || privateLink == nil { 52 | return diag.FromErr(err) 53 | } 54 | 55 | endpointScript, err := api.Client.PrivateLink.GetPrivateLinkEndpointScript(ctx, subId) 56 | if err != nil { 57 | return diag.FromErr(err) 58 | } 59 | 60 | d.SetId(strconv.Itoa(subId)) 61 | 62 | if endpointScript != nil && endpointScript.ResourceEndpointScript != nil { 63 | err = d.Set("endpoint_script", redis.StringValue(endpointScript.ResourceEndpointScript)) 64 | if err != nil { 65 | return diag.FromErr(err) 66 | } 67 | } 68 | 69 | return diags 70 | } 71 | -------------------------------------------------------------------------------- /provider/datasource_rediscloud_database_modules.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "context" 5 | "github.com/RedisLabs/rediscloud-go-api/service/account" 6 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/client" 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 8 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 9 | ) 10 | 11 | func dataSourceRedisCloudDatabaseModules() *schema.Resource { 12 | return &schema.Resource{ 13 | Description: "The Database modules data source allows access to the details of existing database modules within your Redis Enterprise Cloud account.", 14 | ReadContext: dataSourceRedisCloudDatabaseModulesRead, 15 | 16 | Schema: map[string]*schema.Schema{ 17 | "modules": { 18 | Description: "A list of database modules", 19 | Type: schema.TypeSet, 20 | Computed: true, 21 | Elem: &schema.Resource{ 22 | Schema: map[string]*schema.Schema{ 23 | "name": { 24 | Description: "The identifier assigned by the database module", 25 | Computed: true, 26 | Type: schema.TypeString, 27 | }, 28 | "description": { 29 | Description: "A meaningful description of the database module", 30 | Computed: true, 31 | Type: schema.TypeString, 32 | }, 33 | }, 34 | }, 35 | }, 36 | }, 37 | } 38 | } 39 | 40 | func dataSourceRedisCloudDatabaseModulesRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 41 | var diags diag.Diagnostics 42 | api := meta.(*client.ApiClient) 43 | 44 | modules, err := api.Client.Account.ListDatabaseModules(ctx) 45 | 46 | if err != nil { 47 | return diag.FromErr(err) 48 | } 49 | 50 | d.SetId("ALL") 51 | if err := d.Set("modules", flattenDatabaseModules(modules)); err != nil { 52 | return diag.FromErr(err) 53 | } 54 | 55 | return diags 56 | } 57 | 58 | func flattenDatabaseModules(moduleList []*account.DatabaseModule) []map[string]interface{} { 59 | 60 | var dbml []map[string]interface{} 61 | for _, currentModule := range moduleList { 62 | 63 | moduleMapString := map[string]interface{}{ 64 | "name": currentModule.Name, 65 | "description": currentModule.Description, 66 | } 67 | 68 | dbml = append(dbml, moduleMapString) 69 | } 70 | 71 | return dbml 72 | } 73 | -------------------------------------------------------------------------------- /provider/provider_test.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | rediscloudApi "github.com/RedisLabs/rediscloud-go-api" 8 | 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 10 | ) 11 | 12 | var testProvider *schema.Provider 13 | var providerFactories map[string]func() (*schema.Provider, error) 14 | 15 | func init() { 16 | testProvider = New("dev")() 17 | providerFactories = map[string]func() (*schema.Provider, error){ 18 | "rediscloud": func() (*schema.Provider, error) { 19 | return testProvider, nil 20 | }, 21 | } 22 | } 23 | 24 | func TestProvider(t *testing.T) { 25 | if err := New("dev")().InternalValidate(); err != nil { 26 | t.Fatalf("err: %s", err) 27 | } 28 | } 29 | 30 | func testAccPreCheck(t *testing.T) { 31 | requireEnvironmentVariables(t, RedisCloudUrlEnvVar, rediscloudApi.AccessKeyEnvVar, rediscloudApi.SecretKeyEnvVar) 32 | } 33 | 34 | func testAccAwsPreExistingCloudAccountPreCheck(t *testing.T) { 35 | requireEnvironmentVariables(t, "AWS_TEST_CLOUD_ACCOUNT_NAME") 36 | } 37 | 38 | func testAccAwsCloudAccountPreCheck(t *testing.T) { 39 | requireEnvironmentVariables(t, "AWS_ACCESS_KEY_ID", "AWS_ACCESS_SECRET_KEY", "AWS_CONSOLE_USERNAME", "AWS_CONSOLE_PASSWORD", "AWS_SIGNIN_URL") 40 | } 41 | 42 | func testAccAwsPeeringPreCheck(t *testing.T) { 43 | requireEnvironmentVariables(t, "AWS_PEERING_REGION", "AWS_ACCOUNT_ID", "AWS_VPC_ID", "AWS_VPC_CIDR") 44 | } 45 | 46 | func testAccGcpProjectPreCheck(t *testing.T) { 47 | requireEnvironmentVariables(t, "GCP_PROJECT_ID") 48 | } 49 | 50 | func testAccGcpCredentialsPreCheck(t *testing.T) { 51 | requireEnvironmentVariables(t, "GOOGLE_CREDENTIALS") 52 | } 53 | 54 | func testAccAwsPreExistingTgwCheck(t *testing.T) { 55 | requireEnvironmentVariables(t, "AWS_TEST_TGW_ID") 56 | } 57 | 58 | func testAccAwsCredentialsPreCheck(t *testing.T) { 59 | requireEnvironmentVariables(t, "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_REGION") 60 | } 61 | 62 | func testAccRedisCloudAwsAccountPreCheck(t *testing.T) { 63 | requireEnvironmentVariables(t, "REDISCLOUD_AWS_ACCOUNT_ID") 64 | } 65 | 66 | func requireEnvironmentVariables(t *testing.T, names ...string) { 67 | for _, name := range names { 68 | if _, ok := os.LookupEnv(name); !ok { 69 | t.Fatalf("Missing `%s` environment variable", name) 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_essentials_subscription.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_essentials_subscription" 4 | description: |- 5 | Essentials Subscription resource in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_essentials_subscription 9 | 10 | This resource allows you to manage an Essentials subscription within your Redis Enterprise Cloud account. 11 | 12 | -> **Note:** This is for Essential Subscriptions only. See also `rediscloud_subscription` (Pro) and `rediscloud_active_active_subscription`. 13 | 14 | -> **Note:** It's recommended to create a Database (`rediscloud_essentials_database`) when you create a Subscription. 15 | 16 | ## Example Usage 17 | 18 | ```hcl 19 | data "rediscloud_payment_method" "card" { 20 | card_type = "Visa" 21 | } 22 | 23 | data "rediscloud_essentials_plan" "plan" { 24 | name = "Single-Zone_1GB" 25 | cloud_provider = "AWS" 26 | region = "us-west-1" 27 | } 28 | 29 | resource "rediscloud_essentials_subscription" "subscription-resource" { 30 | name = "subscription-name" 31 | plan_id = data.rediscloud_essentials_plan.plan.id 32 | payment_method_id = data.rediscloud_payment_method.card.id 33 | } 34 | ``` 35 | 36 | ## Argument Reference 37 | 38 | The following arguments are supported: 39 | 40 | * `name` - (Required) A meaningful name to identify the subscription 41 | * `plan_id` - (Required) The plan to which this subscription will belong 42 | * `payment_method_id` - (Optional) If the plan is paid, this must be a valid payment method pre-defined in the current account 43 | 44 | ### Timeouts 45 | 46 | The `timeouts` block allows you to 47 | specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: 48 | 49 | * `create` - (Defaults to 30 mins) Used when creating the subscription 50 | * `update` - (Defaults to 30 mins) Used when updating the subscription 51 | * `delete` - (Defaults to 10 mins) Used when destroying the subscription 52 | 53 | ## Attribute reference 54 | 55 | * `status` - The current status of the subscription 56 | * `creation_date` - When the subscription was created 57 | 58 | ## Import 59 | 60 | `rediscloud_essentials_subscription` can be imported using the ID of the subscription, e.g. 61 | 62 | ``` 63 | $ terraform import rediscloud_essentials_subscription.subscription-resource 12345678 64 | ``` 65 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_redis_7.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | rediscloud_database_password = "%s" 5 | } 6 | 7 | data "rediscloud_payment_method" "card" { 8 | card_type = "Visa" 9 | last_four_numbers = "5556" 10 | } 11 | 12 | data "rediscloud_cloud_account" "account" { 13 | exclude_internal_account = true 14 | provider_type = "AWS" 15 | name = local.rediscloud_cloud_account 16 | } 17 | 18 | resource "rediscloud_subscription" "example" { 19 | name = local.rediscloud_subscription_name 20 | payment_method_id = data.rediscloud_payment_method.card.id 21 | cloud_provider { 22 | provider = data.rediscloud_cloud_account.account.provider_type 23 | cloud_account_id = data.rediscloud_cloud_account.account.id 24 | region { 25 | region = "eu-west-1" 26 | networking_deployment_cidr = "10.0.0.0/24" 27 | preferred_availability_zones = ["eu-west-1a"] 28 | } 29 | } 30 | 31 | creation_plan { 32 | dataset_size_in_gb = 1 33 | quantity = 1 34 | replication = false 35 | throughput_measurement_by = "operations-per-second" 36 | throughput_measurement_value = 1000 37 | } 38 | } 39 | 40 | resource "rediscloud_subscription_database" "example" { 41 | subscription_id = rediscloud_subscription.example.id 42 | name = "example" 43 | protocol = "redis" 44 | dataset_size_in_gb = 1 45 | data_persistence = "none" 46 | data_eviction = "allkeys-random" 47 | throughput_measurement_by = "operations-per-second" 48 | throughput_measurement_value = 1000 49 | password = local.rediscloud_database_password 50 | support_oss_cluster_api = false 51 | external_endpoint_for_oss_cluster_api = false 52 | replication = false 53 | average_item_size_in_bytes = 0 54 | client_ssl_certificate = "" 55 | periodic_backup_path = "" 56 | enable_default_user = true 57 | redis_version = "7.4" 58 | 59 | alert { 60 | name = "dataset-size" 61 | value = 1 62 | } 63 | 64 | tags = { 65 | "market" = "emea" 66 | "material" = "cardboard" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_redis_8.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | rediscloud_database_password = "%s" 5 | } 6 | 7 | data "rediscloud_payment_method" "card" { 8 | card_type = "Visa" 9 | last_four_numbers = "5556" 10 | } 11 | 12 | data "rediscloud_cloud_account" "account" { 13 | exclude_internal_account = true 14 | provider_type = "AWS" 15 | name = local.rediscloud_cloud_account 16 | } 17 | 18 | resource "rediscloud_subscription" "example" { 19 | name = local.rediscloud_subscription_name 20 | payment_method_id = data.rediscloud_payment_method.card.id 21 | cloud_provider { 22 | provider = data.rediscloud_cloud_account.account.provider_type 23 | cloud_account_id = data.rediscloud_cloud_account.account.id 24 | region { 25 | region = "eu-west-1" 26 | networking_deployment_cidr = "10.0.0.0/24" 27 | preferred_availability_zones = ["eu-west-1a"] 28 | } 29 | } 30 | 31 | creation_plan { 32 | dataset_size_in_gb = 1 33 | quantity = 1 34 | replication = false 35 | throughput_measurement_by = "operations-per-second" 36 | throughput_measurement_value = 1000 37 | } 38 | } 39 | 40 | resource "rediscloud_subscription_database" "example" { 41 | subscription_id = rediscloud_subscription.example.id 42 | name = "example" 43 | protocol = "redis" 44 | dataset_size_in_gb = 3 45 | data_persistence = "none" 46 | data_eviction = "allkeys-random" 47 | throughput_measurement_by = "operations-per-second" 48 | throughput_measurement_value = 1000 49 | password = local.rediscloud_database_password 50 | support_oss_cluster_api = false 51 | external_endpoint_for_oss_cluster_api = false 52 | replication = false 53 | average_item_size_in_bytes = 0 54 | client_ssl_certificate = "" 55 | periodic_backup_path = "" 56 | enable_default_user = true 57 | redis_version = "8.2" 58 | 59 | alert { 60 | name = "dataset-size" 61 | value = 1 62 | } 63 | 64 | tags = { 65 | "market" = "emea" 66 | "material" = "cardboard" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_active_active_private_link.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_active_active_private_link" 4 | description: |- 5 | PrivateLink data source for Active-Active subscriptions in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_active_active_private_link 9 | Retrieves information about an existing PrivateLink for an Active-Active subscription region. 10 | 11 | ## Example Usage 12 | 13 | ```hcl 14 | data "rediscloud_active_active_private_link" "example" { 15 | subscription_id = "1234" 16 | region_id = 1 17 | } 18 | 19 | output "rediscloud_private_link_principals" { 20 | value = data.rediscloud_active_active_private_link.example.principals 21 | } 22 | ``` 23 | 24 | ## Argument Reference 25 | 26 | * `subscription_id` - (Required) The ID of the Active-Active subscription the PrivateLink is attached to. 27 | * `region_id` - (Required) The region ID within the Active-Active subscription that the PrivateLink is attached to. 28 | 29 | ## Attribute Reference 30 | 31 | * `principals` - A list of principals attached to the PrivateLink. 32 | * `resource_configuration_id` - The ID of the resource configuration attached to this PrivateLink. 33 | * `resource_configuration_arn` - The ARN of the resource configuration attached to this PrivateLink. 34 | * `share_arn` - The share ARN of this PrivateLink. 35 | * `connections` - A list of connections associated with the PrivateLink. 36 | * `databases` - A list of databases associated with the PrivateLink. 37 | 38 | The `principals` object is a list with these attributes: 39 | * `principal` - The principal attached to this PrivateLink. 40 | * `principal_type` - The type of principal. 41 | * `principal_alias` - A friendly name for the principal. 42 | 43 | The `connections` object is a list with these attributes: 44 | * `association_id` - The association ID of the PrivateLink connection. 45 | * `connection_id` - The connection ID of the PrivateLink connection. 46 | * `connection_type` - The type of the PrivateLink connection. 47 | * `owner_id` - The owner ID of the connection. 48 | * `association_date` - The date the connection was associated. 49 | 50 | The `databases` object is a list with these attributes: 51 | * `database_id` - The ID of the database. 52 | * `port` - The port the database is available on. 53 | * `resource_link_endpoint` - The resource link endpoint for the database. 54 | -------------------------------------------------------------------------------- /provider/pro/testdata/active_active_database_with_pro_data_source.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_database_password = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | resource "rediscloud_active_active_subscription" "example" { 12 | name = local.rediscloud_subscription_name 13 | payment_method_id = data.rediscloud_payment_method.card.id 14 | cloud_provider = "AWS" 15 | creation_plan { 16 | memory_limit_in_gb = 1 17 | quantity = 1 18 | region { 19 | region = "us-east-1" 20 | networking_deployment_cidr = "192.168.0.0/24" 21 | write_operations_per_second = 1000 22 | read_operations_per_second = 1000 23 | } 24 | region { 25 | region = "us-east-2" 26 | networking_deployment_cidr = "10.0.1.0/24" 27 | write_operations_per_second = 1000 28 | read_operations_per_second = 1000 29 | } 30 | } 31 | } 32 | resource "rediscloud_active_active_subscription_database" "example" { 33 | subscription_id = rediscloud_active_active_subscription.example.id 34 | name = local.rediscloud_subscription_name 35 | memory_limit_in_gb = 3 36 | support_oss_cluster_api = false 37 | external_endpoint_for_oss_cluster_api = false 38 | enable_tls = false 39 | 40 | global_data_persistence = "none" 41 | global_password = local.rediscloud_database_password 42 | global_source_ips = ["192.168.0.0/16", "192.170.0.0/16"] 43 | global_alert { 44 | name = "dataset-size" 45 | value = 1 46 | } 47 | override_region { 48 | name = "us-east-1" 49 | override_global_data_persistence = "aof-every-write" 50 | override_global_source_ips = ["192.175.0.0/16"] 51 | override_global_password = "region-specific-password" 52 | override_global_alert { 53 | name = "dataset-size" 54 | value = 42 55 | } 56 | } 57 | override_region { 58 | name = "us-east-2" 59 | } 60 | } 61 | data "rediscloud_database" "example" { 62 | subscription_id = rediscloud_active_active_subscription.example.id 63 | name = rediscloud_active_active_subscription_database.example.name 64 | } 65 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/public_endpoint_disabled.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_database_password = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | resource "rediscloud_active_active_subscription" "example" { 12 | name = local.rediscloud_subscription_name 13 | payment_method_id = data.rediscloud_payment_method.card.id 14 | cloud_provider = "AWS" 15 | public_endpoint_access = false 16 | 17 | creation_plan { 18 | memory_limit_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 | resource "rediscloud_active_active_subscription_database" "example" { 36 | subscription_id = rediscloud_active_active_subscription.example.id 37 | name = local.rediscloud_subscription_name 38 | dataset_size_in_gb = 1 39 | global_data_persistence = "aof-every-1-second" 40 | global_password = local.rediscloud_database_password 41 | global_source_ips = ["192.168.0.0/16"] 42 | global_alert { 43 | name = "dataset-size" 44 | value = 40 45 | } 46 | 47 | override_region { 48 | name = "us-east-2" 49 | enable_default_user = true 50 | } 51 | 52 | override_region { 53 | name = "us-east-1" 54 | override_global_data_persistence = "none" 55 | override_global_password = "region-specific-password" 56 | override_global_source_ips = ["172.16.0.0/16"] 57 | override_global_alert { 58 | name = "dataset-size" 59 | value = 60 60 | } 61 | } 62 | 63 | tags = { 64 | "environment" = "production" 65 | "cost_center" = "0700" 66 | } 67 | } 68 | 69 | data "rediscloud_active_active_subscription_database" "example" { 70 | subscription_id = rediscloud_active_active_subscription.example.id 71 | name = rediscloud_active_active_subscription_database.example.name 72 | } 73 | -------------------------------------------------------------------------------- /provider/datasource_rediscloud_data_persistence.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "context" 5 | "github.com/RedisLabs/rediscloud-go-api/service/account" 6 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/client" 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 8 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 9 | ) 10 | 11 | func dataSourceRedisCloudDataPersistence() *schema.Resource { 12 | return &schema.Resource{ 13 | Description: "The data persistence data source allows access to a list of supported data persistence options. Each option represents the rate at which a database will persist its data to storage.", 14 | ReadContext: dataSourceRedisCloudDataPersistenceRead, 15 | 16 | Schema: map[string]*schema.Schema{ 17 | "data_persistence": { 18 | Type: schema.TypeSet, 19 | Description: "A list of data persistence option that can be applied to subscription databases", 20 | Computed: true, 21 | Elem: &schema.Resource{ 22 | Schema: map[string]*schema.Schema{ 23 | "name": { 24 | Computed: true, 25 | Description: "The identifier of the data persistence option", 26 | Type: schema.TypeString, 27 | }, 28 | "description": { 29 | Computed: true, 30 | Description: "A meaningful description of the data persistence option", 31 | Type: schema.TypeString, 32 | }, 33 | }, 34 | }, 35 | }, 36 | }, 37 | } 38 | } 39 | 40 | func dataSourceRedisCloudDataPersistenceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 41 | var diags diag.Diagnostics 42 | api := meta.(*client.ApiClient) 43 | 44 | dataPersistence, err := api.Client.Account.ListDataPersistence(ctx) 45 | 46 | if err != nil { 47 | return diag.FromErr(err) 48 | } 49 | 50 | d.SetId("ALL") 51 | if err := d.Set("data_persistence", flattenDataPersistence(dataPersistence)); err != nil { 52 | return diag.FromErr(err) 53 | } 54 | 55 | return diags 56 | } 57 | 58 | func flattenDataPersistence(dataPersistenceList []*account.DataPersistence) []map[string]interface{} { 59 | 60 | var dpl []map[string]interface{} 61 | for _, currentDataPersistence := range dataPersistenceList { 62 | 63 | dpMapString := map[string]interface{}{ 64 | "name": currentDataPersistence.Name, 65 | "description": currentDataPersistence.Description, 66 | } 67 | 68 | dpl = append(dpl, dpMapString) 69 | } 70 | 71 | return dpl 72 | } 73 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | default: testacc 2 | 3 | PROVIDER_HOSTNAME=registry.terraform.io 4 | PROVIDER_NAMESPACE=RedisLabs 5 | PROVIDER_TYPE=rediscloud 6 | PROVIDER_TARGET=$(shell go env GOOS)_$(shell go env GOARCH) 7 | PROVIDER_VERSION = 99.99.99 8 | 9 | PLUGINS_PATH = ~/.terraform.d/plugins 10 | PLUGINS_PROVIDER_PATH=$(PROVIDER_HOSTNAME)/$(PROVIDER_NAMESPACE)/$(PROVIDER_TYPE)/$(PROVIDER_VERSION)/$(PROVIDER_TARGET) 11 | 12 | # Use a parallelism of 3 by default for tests, overriding whatever GOMAXPROCS is set to. 13 | TEST_PARALLELISM?=6 14 | TESTARGS?=-short 15 | 16 | bin: 17 | @mkdir -p bin/ 18 | 19 | BIN=$(CURDIR)/bin 20 | $(BIN)/%: 21 | @echo "Installing tools from tools/tools.go" 22 | @cat tools/tools.go | grep _ | awk -F '"' '{print $$2}' | GOBIN=$(BIN) xargs -tI {} go install {} 23 | 24 | .PHONY: build clean testacc generate_coverage install_local website website-test tfproviderlint 25 | 26 | build: bin 27 | @echo "Building local provider binary" 28 | go build -o $(BIN)/terraform-provider-rediscloud_v$(PROVIDER_VERSION) 29 | @sh -c "'$(CURDIR)/scripts/generate-dev-overrides.sh'" 30 | 31 | clean: 32 | @echo "Deleting local provider binary" 33 | rm -rf $(BIN) 34 | 35 | # `-p=1` added to avoid testing packages in parallel which causes `go test` to not stream logs as they are written 36 | testacc: bin 37 | TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 360m -p=1 -parallel=$(TEST_PARALLELISM) -coverprofile bin/coverage.out 38 | 39 | # Essentials tests must run serially due to API limitation of one essentials db per account 40 | testacc-essentials: bin 41 | TF_ACC=1 go test ./provider -v -run="TestAccResourceRedisCloudEssentials|TestAccDataSourceRedisCloudEssentials" -timeout 360m -p=1 -parallel=1 -coverprofile bin/coverage.out 42 | 43 | generate_coverage: 44 | go tool cover -html=bin/coverage.out -o bin/coverage.html 45 | 46 | install_local: build 47 | @echo "Installing local provider binary to plugins mirror path $(PLUGINS_PATH)/$(PLUGINS_PROVIDER_PATH)" 48 | @mkdir -p $(PLUGINS_PATH)/$(PLUGINS_PROVIDER_PATH) 49 | @cp $(BIN)/terraform-provider-rediscloud_v$(PROVIDER_VERSION) $(PLUGINS_PATH)/$(PLUGINS_PROVIDER_PATH) 50 | 51 | sweep: 52 | @echo "WARNING: This will destroy infrastructure. Use only in development accounts." 53 | go test ./provider -v -sweep=ALL $(SWEEPARGS) -timeout 30m 54 | 55 | tfproviderlintx: $(BIN)/tfproviderlintx 56 | $(BIN)/tfproviderlintx $(TFPROVIDERLINT_ARGS) ./... 57 | 58 | tfproviderlint: $(BIN)/tfproviderlint 59 | $(BIN)/tfproviderlint $(TFPROVIDERLINT_ARGS) ./... 60 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/public_endpoint_enabled.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_database_password = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | resource "rediscloud_active_active_subscription" "example" { 12 | name = local.rediscloud_subscription_name 13 | payment_method_id = data.rediscloud_payment_method.card.id 14 | cloud_provider = "AWS" 15 | public_endpoint_access = true 16 | 17 | creation_plan { 18 | memory_limit_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 | resource "rediscloud_active_active_subscription_database" "example" { 36 | subscription_id = rediscloud_active_active_subscription.example.id 37 | name = local.rediscloud_subscription_name 38 | dataset_size_in_gb = 1 39 | global_data_persistence = "aof-every-1-second" 40 | global_password = local.rediscloud_database_password 41 | global_source_ips = ["192.168.0.0/16"] 42 | global_alert { 43 | name = "dataset-size" 44 | value = 40 45 | } 46 | 47 | global_modules = ["RedisJSON"] 48 | 49 | override_region { 50 | name = "us-east-2" 51 | enable_default_user = true 52 | } 53 | 54 | override_region { 55 | name = "us-east-1" 56 | override_global_data_persistence = "none" 57 | override_global_password = "region-specific-password" 58 | override_global_source_ips = ["172.16.0.0/16"] 59 | override_global_alert { 60 | name = "dataset-size" 61 | value = 60 62 | } 63 | } 64 | 65 | tags = { 66 | "environment" = "production" 67 | "cost_center" = "0700" 68 | } 69 | } 70 | 71 | data "rediscloud_active_active_subscription_database" "example" { 72 | subscription_id = rediscloud_active_active_subscription.example.id 73 | name = rediscloud_active_active_subscription_database.example.name 74 | } 75 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/subscription_update_redis8.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_cloud_provider_name = "%s" 4 | } 5 | 6 | data "rediscloud_payment_method" "card" { 7 | card_type = "Visa" 8 | last_four_numbers = "5556" 9 | } 10 | 11 | resource "rediscloud_active_active_subscription" "example" { 12 | name = local.rediscloud_subscription_name 13 | payment_method_id = data.rediscloud_payment_method.card.id 14 | cloud_provider = local.rediscloud_cloud_provider_name 15 | 16 | creation_plan { 17 | memory_limit_in_gb = 1 18 | quantity = 1 19 | region { 20 | region = "us-east-1" 21 | networking_deployment_cidr = "192.168.0.0/24" 22 | write_operations_per_second = 1000 23 | read_operations_per_second = 1000 24 | } 25 | region { 26 | region = "us-east-2" 27 | networking_deployment_cidr = "10.0.1.0/24" 28 | write_operations_per_second = 1000 29 | read_operations_per_second = 1000 30 | } 31 | } 32 | 33 | maintenance_windows { 34 | mode = "automatic" 35 | } 36 | } 37 | 38 | data "rediscloud_active_active_subscription" "example" { 39 | name = rediscloud_active_active_subscription.example.name 40 | } 41 | 42 | resource "rediscloud_active_active_subscription_database" "example" { 43 | subscription_id = rediscloud_active_active_subscription.example.id 44 | name = local.rediscloud_subscription_name 45 | redis_version = "8.2" 46 | dataset_size_in_gb = 1 47 | global_data_persistence = "aof-every-1-second" 48 | global_password = "some-random-pass-2" 49 | global_source_ips = ["192.168.0.0/16"] 50 | global_alert { 51 | name = "dataset-size" 52 | value = 40 53 | } 54 | 55 | global_enable_default_user = false 56 | 57 | override_region { 58 | name = "us-east-1" 59 | override_global_data_persistence = "none" 60 | override_global_password = "region-specific-password" 61 | override_global_alert { 62 | name = "dataset-size" 63 | value = 60 64 | } 65 | } 66 | 67 | override_region { 68 | name = "us-east-2" 69 | enable_default_user = false 70 | override_global_source_ips = ["192.10.0.0/16"] 71 | } 72 | 73 | tags = { 74 | "environment" = "production" 75 | "cost_center" = "0700" 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_with_replica.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | rediscloud_database_password = "%s" 5 | } 6 | 7 | data "rediscloud_payment_method" "card" { 8 | card_type = "Visa" 9 | last_four_numbers = "5556" 10 | } 11 | 12 | data "rediscloud_cloud_account" "account" { 13 | exclude_internal_account = true 14 | provider_type = "AWS" 15 | name = local.rediscloud_cloud_account 16 | } 17 | 18 | resource "rediscloud_subscription" "example" { 19 | name = local.rediscloud_subscription_name 20 | payment_method_id = data.rediscloud_payment_method.card.id 21 | cloud_provider { 22 | provider = data.rediscloud_cloud_account.account.provider_type 23 | cloud_account_id = data.rediscloud_cloud_account.account.id 24 | region { 25 | region = "eu-west-1" 26 | networking_deployment_cidr = "10.0.0.0/24" 27 | preferred_availability_zones = ["eu-west-1a"] 28 | } 29 | } 30 | 31 | creation_plan { 32 | dataset_size_in_gb = 1 33 | quantity = 1 34 | replication = false 35 | throughput_measurement_by = "operations-per-second" 36 | throughput_measurement_value = 1000 37 | } 38 | } 39 | 40 | resource "rediscloud_subscription_database" "example" { 41 | subscription_id = rediscloud_subscription.example.id 42 | name = "example" 43 | protocol = "redis" 44 | dataset_size_in_gb = 1 45 | data_persistence = "none" 46 | data_eviction = "allkeys-random" 47 | throughput_measurement_by = "operations-per-second" 48 | throughput_measurement_value = 1000 49 | password = local.rediscloud_database_password 50 | support_oss_cluster_api = false 51 | external_endpoint_for_oss_cluster_api = false 52 | replication = false 53 | average_item_size_in_bytes = 0 54 | client_ssl_certificate = "" 55 | periodic_backup_path = "" 56 | enable_default_user = true 57 | redis_version = "8.2" 58 | 59 | alert { 60 | name = "dataset-size" 61 | value = 1 62 | } 63 | 64 | tags = { 65 | "market" = "emea" 66 | "material" = "cardboard" 67 | } 68 | } 69 | 70 | resource "rediscloud_subscription_database" "example_replica" { 71 | subscription_id = rediscloud_subscription.example.id 72 | name = "example-replica" 73 | protocol = "redis" 74 | dataset_size_in_gb = 1 75 | throughput_measurement_by = "operations-per-second" 76 | throughput_measurement_value = 1000 77 | replica_of = ["redis://${rediscloud_subscription_database.example.public_endpoint}"] 78 | } 79 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_active_active_transit_gateway_invitation_acceptor.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_active_active_transit_gateway_invitation_acceptor" 4 | description: |- 5 | Active-Active Transit Gateway Invitation Acceptor resource in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_active_active_transit_gateway_invitation_acceptor 9 | 10 | Manages the acceptance or rejection of a Transit Gateway invitation in an Active-Active Redis Enterprise Cloud Subscription region. Transit Gateway invitations are created when an AWS Resource Share shares a Transit Gateway with your subscription. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "rediscloud_active_active_transit_gateway_invitations" "example" { 16 | subscription_id = rediscloud_active_active_subscription.example.id 17 | region_id = 1 18 | } 19 | 20 | resource "rediscloud_active_active_transit_gateway_invitation_acceptor" "example" { 21 | subscription_id = rediscloud_active_active_subscription.example.id 22 | region_id = 1 23 | tgw_invitation_id = data.rediscloud_active_active_transit_gateway_invitations.example.invitations[0].id 24 | action = "accept" 25 | } 26 | ``` 27 | 28 | ## Argument Reference 29 | 30 | * `subscription_id` - (Required) The ID of the Active-Active subscription. **Modifying this attribute will force creation of a new resource.** 31 | * `region_id` - (Required) The ID of the region within the Active-Active subscription. **Modifying this attribute will force creation of a new resource.** 32 | * `tgw_invitation_id` - (Required) The ID of the Transit Gateway invitation to accept or reject. **Modifying this attribute will force creation of a new resource.** 33 | * `action` - (Required) Accept or reject the invitation. Accepted values are `accept` and `reject`. 34 | 35 | ## Attribute Reference 36 | 37 | * `name` - The name of the resource share 38 | * `resource_share_uid` - The AWS Resource Share ARN 39 | * `aws_account_id` - The AWS account ID that shared the Transit Gateway 40 | * `status` - The status of the invitation 41 | * `shared_date` - The date the resource was shared 42 | 43 | ## Import 44 | 45 | `rediscloud_active_active_transit_gateway_invitation_acceptor` can be imported using the format `{subscription_id}/{region_id}/{tgw_invitation_id}`, e.g. 46 | 47 | ``` 48 | $ terraform import rediscloud_active_active_transit_gateway_invitation_acceptor.example 123456/1/7890 49 | ``` 50 | 51 | Note: The `action` attribute is not stored in the API and will not be populated during import. 52 | -------------------------------------------------------------------------------- /provider/pro/testdata/pro_database_data_source.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_cloud_account = "%s" 3 | rediscloud_subscription_name = "%s" 4 | rediscloud_password = "%s" 5 | } 6 | 7 | data "rediscloud_payment_method" "card" { 8 | card_type = "Visa" 9 | last_four_numbers = "5556" 10 | } 11 | 12 | data "rediscloud_cloud_account" "account" { 13 | exclude_internal_account = true 14 | provider_type = "AWS" 15 | name = local.rediscloud_cloud_account 16 | } 17 | resource "rediscloud_subscription" "example" { 18 | name = local.rediscloud_subscription_name 19 | payment_method_id = data.rediscloud_payment_method.card.id 20 | memory_storage = "ram" 21 | cloud_provider { 22 | provider = data.rediscloud_cloud_account.account.provider_type 23 | cloud_account_id = data.rediscloud_cloud_account.account.id 24 | region { 25 | region = "eu-west-1" 26 | networking_deployment_cidr = "10.0.0.0/24" 27 | preferred_availability_zones = ["eu-west-1a"] 28 | } 29 | } 30 | creation_plan { 31 | memory_limit_in_gb = 1 32 | quantity = 1 33 | replication = false 34 | support_oss_cluster_api = true 35 | throughput_measurement_by = "operations-per-second" 36 | throughput_measurement_value = 1000 37 | modules = ["RediSearch"] 38 | } 39 | } 40 | resource "rediscloud_subscription_database" "example" { 41 | subscription_id = rediscloud_subscription.example.id 42 | name = "tf-database" 43 | protocol = "redis" 44 | memory_limit_in_gb = 1 45 | data_persistence = "none" 46 | throughput_measurement_by = "operations-per-second" 47 | throughput_measurement_value = 1000 48 | password = local.rediscloud_password 49 | support_oss_cluster_api = true 50 | replication = false 51 | enable_default_user = true 52 | query_performance_factor = "2x" 53 | redis_version = "7.4" 54 | modules = [ 55 | { 56 | name : "RediSearch" 57 | } 58 | ] 59 | } 60 | 61 | data "rediscloud_database" "example-by-id" { 62 | subscription_id = rediscloud_subscription.example.id 63 | db_id = rediscloud_subscription_database.example.db_id 64 | } 65 | 66 | data "rediscloud_database" "example-by-name" { 67 | subscription_id = rediscloud_subscription.example.id 68 | name = rediscloud_subscription_database.example.name 69 | } 70 | -------------------------------------------------------------------------------- /provider/datasource_rediscloud_private_service_connect.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "context" 5 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/client" 6 | "strconv" 7 | 8 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 10 | ) 11 | 12 | func dataSourcePrivateServiceConnect() *schema.Resource { 13 | return &schema.Resource{ 14 | Description: "The Private Service Connect data source allows access to an available Private Service Connect Service within your Redis Enterprise Cloud Account.", 15 | ReadContext: dataSourcePrivateServiceConnectRead, 16 | 17 | Schema: map[string]*schema.Schema{ 18 | "subscription_id": { 19 | Description: "The ID of a Pro subscription", 20 | Type: schema.TypeString, 21 | Required: true, 22 | }, 23 | "private_service_connect_service_id": { 24 | Description: "The ID of the Private Service Connect Service relative to the associated subscription", 25 | Type: schema.TypeInt, 26 | Computed: true, 27 | }, 28 | "connection_host_name": { 29 | Description: "The connection host name", 30 | Type: schema.TypeString, 31 | Computed: true, 32 | }, 33 | "service_attachment_name": { 34 | Description: "The service attachment name", 35 | Type: schema.TypeString, 36 | Computed: true, 37 | }, 38 | "status": { 39 | Description: "The Private Service Connect status", 40 | Type: schema.TypeString, 41 | Computed: true, 42 | }, 43 | }, 44 | } 45 | } 46 | 47 | func dataSourcePrivateServiceConnectRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 48 | var diags diag.Diagnostics 49 | api := meta.(*client.ApiClient) 50 | 51 | subId, err := strconv.Atoi(d.Get("subscription_id").(string)) 52 | if err != nil { 53 | return diag.FromErr(err) 54 | } 55 | 56 | pscService, err := api.Client.PrivateServiceConnect.GetService(ctx, subId) 57 | if err != nil { 58 | return diag.FromErr(err) 59 | } 60 | 61 | d.SetId(buildPrivateServiceConnectId(subId, *pscService.ID)) 62 | if err := d.Set("private_service_connect_service_id", pscService.ID); err != nil { 63 | return diag.FromErr(err) 64 | } 65 | if err := d.Set("connection_host_name", pscService.ConnectionHostName); err != nil { 66 | return diag.FromErr(err) 67 | } 68 | if err := d.Set("service_attachment_name", pscService.ServiceAttachmentName); err != nil { 69 | return diag.FromErr(err) 70 | } 71 | if err := d.Set("status", pscService.Status); err != nil { 72 | return diag.FromErr(err) 73 | } 74 | 75 | return diags 76 | } 77 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ main ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ main ] 20 | schedule: 21 | - cron: '35 8 * * 0' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | language: [ 'go' ] 32 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 33 | # Learn more: 34 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 35 | 36 | steps: 37 | - name: Checkout repository 38 | uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 39 | 40 | 41 | # Initializes the CodeQL tools for scanning. 42 | - name: Initialize CodeQL 43 | uses: github/codeql-action/init@v4 44 | with: 45 | languages: ${{ matrix.language }} 46 | # If you wish to specify custom queries, you can do so here or in a config file. 47 | # By default, queries listed here will override any specified in a config file. 48 | # Prefix the list here with "+" to use these queries and those in the config file. 49 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 50 | 51 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 52 | # If this step fails, then you should remove it and run the build manually (see below) 53 | - name: Autobuild 54 | uses: github/codeql-action/autobuild@v4 55 | 56 | # ℹ️ Command-line programs to run using the OS shell. 57 | # 📚 https://git.io/JvXDl 58 | 59 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 60 | # and modify them (or add more) to build your code if your project 61 | # uses a compiled language 62 | 63 | #- run: | 64 | # make bootstrap 65 | # make release 66 | 67 | - name: Perform CodeQL Analysis 68 | uses: github/codeql-action/analyze@v4 69 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_acl_role.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_acl_role" 4 | description: |- 5 | ACL Role resource in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_acl_role 9 | 10 | Creates a Role in your Redis Enterprise Cloud Account. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | resource "rediscloud_acl_rule" "rule-resource" { 16 | name = "my-rule" 17 | rule = "+@read ~cache:*" 18 | } 19 | 20 | resource "rediscloud_acl_role" "role-resource" { 21 | name = "my-role" 22 | rule { 23 | name = rediscloud_acl_rule.rule-resource.name 24 | database { 25 | subscription = rediscloud_subscription.subscription-resource.id 26 | database = rediscloud_subscription_database.database-resource.db_id 27 | } 28 | } 29 | } 30 | ``` 31 | 32 | ## Argument Reference 33 | 34 | The following arguments are supported: 35 | 36 | * `name` - (Required) A meaningful name for the role. Must be unique. 37 | * `rule` - (Required, minimum 1) A set of rule association objects, documented below. 38 | 39 | The `rule` block supports: 40 | 41 | * `name` (Required) - Name of the Rule. 42 | * `database` - (Required, minimum 1) a set of database association objects, documented below. 43 | 44 | The `database` block supports: 45 | 46 | * `subscription` (Required) - ID of the subscription containing the database. 47 | * `database` (Required) - ID of the database to which the Rule should apply. 48 | * `regions` (Optional) - For databases in Active/Active subscriptions only, the regions to which the Rule should apply. 49 | 50 | ### Timeouts 51 | 52 | The `timeouts` block allows you to 53 | specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: 54 | 55 | * `create` - (Defaults to 5 mins) Used when creating the Role. 56 | * `update` - (Defaults to 5 mins) Used when updating the Role. 57 | * `delete` - (Defaults to 5 mins) Used when destroying the Role. 58 | 59 | ## Attribute reference 60 | 61 | * `id` - Identifier of the Role created. 62 | * `name` - The Role's name. 63 | * `rule` - The Rules associated with the Role. 64 | 65 | The `rule` block supports: 66 | 67 | * `name` - Name of the Rule. 68 | * `database` - The Databases the Rule applies to. 69 | 70 | The `database` block supports: 71 | 72 | * `subscription` ID of the subscription containing the database. 73 | * `database` ID of the database to which the Rule should apply. 74 | * `regions` The regions to which the Rule should apply, if appropriate to the database. 75 | 76 | ## Import 77 | 78 | `rediscloud_acl_role` can be imported using the Identifier of the Role, e.g. 79 | 80 | ``` 81 | $ terraform import rediscloud_acl_role.role-resource 123456 82 | ``` 83 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/active_active_sub.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | } 4 | 5 | data "rediscloud_payment_method" "card" { 6 | card_type = "Visa" 7 | last_four_numbers = "5556" 8 | } 9 | 10 | resource "rediscloud_active_active_subscription" "example" { 11 | name = local.rediscloud_subscription_name 12 | payment_method_id = data.rediscloud_payment_method.card.id 13 | cloud_provider = "AWS" 14 | 15 | creation_plan { 16 | memory_limit_in_gb = 1 17 | modules = ["RedisJSON"] 18 | quantity = 1 19 | region { 20 | region = "us-east-1" 21 | networking_deployment_cidr = "192.168.0.0/24" 22 | write_operations_per_second = 1000 23 | read_operations_per_second = 1000 24 | } 25 | region { 26 | region = "us-east-2" 27 | networking_deployment_cidr = "10.0.1.0/24" 28 | write_operations_per_second = 1000 29 | read_operations_per_second = 1000 30 | } 31 | } 32 | 33 | maintenance_windows { 34 | mode = "manual" 35 | window { 36 | start_hour = 22 37 | duration_in_hours = 8 38 | days = ["Monday", "Thursday"] 39 | } 40 | window { 41 | start_hour = 12 42 | duration_in_hours = 6 43 | days = ["Friday", "Saturday", "Sunday"] 44 | } 45 | } 46 | } 47 | 48 | resource "rediscloud_active_active_subscription_database" "example" { 49 | subscription_id = rediscloud_active_active_subscription.example.id 50 | name = local.rediscloud_subscription_name 51 | dataset_size_in_gb = 1 52 | global_data_persistence = "aof-every-1-second" 53 | global_password = "some-random-pass-2" 54 | global_source_ips = ["192.168.0.0/16"] 55 | global_alert { 56 | name = "dataset-size" 57 | value = 40 58 | } 59 | 60 | global_modules = ["RedisJSON"] 61 | 62 | override_region { 63 | name = "us-east-2" 64 | enable_default_user = true 65 | override_global_source_ips = ["192.10.0.0/16"] 66 | } 67 | 68 | override_region { 69 | name = "us-east-1" 70 | override_global_data_persistence = "none" 71 | override_global_password = "region-specific-password" 72 | override_global_alert { 73 | name = "dataset-size" 74 | value = 60 75 | } 76 | } 77 | 78 | tags = { 79 | "environment" = "production" 80 | "cost_center" = "0700" 81 | } 82 | } 83 | 84 | 85 | data "rediscloud_active_active_subscription" "example" { 86 | name = rediscloud_active_active_subscription.example.name 87 | } 88 | 89 | data "rediscloud_active_active_subscription_regions" "example" { 90 | subscription_name = rediscloud_active_active_subscription.example.name 91 | } 92 | 93 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/active_active_sub_redis8.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | } 4 | 5 | data "rediscloud_payment_method" "card" { 6 | card_type = "Visa" 7 | last_four_numbers = "5556" 8 | } 9 | 10 | resource "rediscloud_active_active_subscription" "example" { 11 | name = local.rediscloud_subscription_name 12 | payment_method_id = data.rediscloud_payment_method.card.id 13 | cloud_provider = "AWS" 14 | 15 | creation_plan { 16 | memory_limit_in_gb = 1 17 | quantity = 1 18 | region { 19 | region = "us-east-1" 20 | networking_deployment_cidr = "192.168.0.0/24" 21 | write_operations_per_second = 1000 22 | read_operations_per_second = 1000 23 | } 24 | region { 25 | region = "us-east-2" 26 | networking_deployment_cidr = "10.0.1.0/24" 27 | write_operations_per_second = 1000 28 | read_operations_per_second = 1000 29 | } 30 | } 31 | 32 | maintenance_windows { 33 | mode = "manual" 34 | window { 35 | start_hour = 22 36 | duration_in_hours = 8 37 | days = ["Monday", "Thursday"] 38 | } 39 | window { 40 | start_hour = 12 41 | duration_in_hours = 6 42 | days = ["Friday", "Saturday", "Sunday"] 43 | } 44 | } 45 | } 46 | 47 | resource "rediscloud_active_active_subscription_database" "example" { 48 | subscription_id = rediscloud_active_active_subscription.example.id 49 | name = local.rediscloud_subscription_name 50 | redis_version = "8.2" 51 | dataset_size_in_gb = 1 52 | global_data_persistence = "aof-every-1-second" 53 | global_password = "some-random-pass-2" 54 | global_source_ips = ["192.168.0.0/16"] 55 | global_alert { 56 | name = "dataset-size" 57 | value = 40 58 | } 59 | 60 | override_region { 61 | name = "us-east-2" 62 | enable_default_user = true 63 | override_global_source_ips = ["192.10.0.0/16"] 64 | } 65 | 66 | override_region { 67 | name = "us-east-1" 68 | override_global_data_persistence = "none" 69 | override_global_password = "region-specific-password" 70 | override_global_alert { 71 | name = "dataset-size" 72 | value = 60 73 | } 74 | } 75 | 76 | tags = { 77 | "environment" = "production" 78 | "cost_center" = "0700" 79 | } 80 | } 81 | 82 | 83 | data "rediscloud_active_active_subscription" "example" { 84 | name = rediscloud_active_active_subscription.example.name 85 | } 86 | 87 | data "rediscloud_active_active_subscription_regions" "example" { 88 | subscription_name = rediscloud_active_active_subscription.example.name 89 | } 90 | -------------------------------------------------------------------------------- /provider/utils/get_set.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "github.com/RedisLabs/rediscloud-go-api/redis" 5 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 6 | "time" 7 | ) 8 | 9 | // This timeout is an absolute maximum used in some of the waitForStatus operations concerning creation and updating 10 | // Subscriptions and Databases. Reads and Deletions have their own, stricter timeouts because they consistently behave 11 | // well. The Terraform operation-level timeout should kick in way before we hit this and kill the task. 12 | // Unfortunately there's no "time-remaining-before-timeout" utility, or we could use that in the wait blocks. 13 | const SafetyTimeout = 6 * time.Hour 14 | 15 | // TransitGatewayProvisioningTimeout is used when waiting for Transit Gateway resources to become available during 16 | // subscription provisioning. This is shorter than SafetyTimeout as tests typically complete within 45 minutes. 17 | const TransitGatewayProvisioningTimeout = 40 * time.Minute 18 | 19 | // GetString safely retrieves a string value from schema.ResourceData. 20 | func GetString(d *schema.ResourceData, key string) *string { 21 | if v, ok := d.GetOk(key); ok { 22 | return redis.String(v.(string)) 23 | } 24 | return redis.String("") 25 | } 26 | 27 | // GetBool safely retrieves a bool value from schema.ResourceData. 28 | func GetBool(d *schema.ResourceData, key string) *bool { 29 | if v, ok := d.GetOk(key); ok { 30 | return redis.Bool(v.(bool)) 31 | } 32 | return redis.Bool(false) 33 | } 34 | 35 | // GetInt safely retrieves an int value from schema.ResourceData. 36 | func GetInt(d *schema.ResourceData, key string) *int { 37 | if v, ok := d.GetOk(key); ok { 38 | return redis.Int(v.(int)) 39 | } 40 | return redis.Int(0) 41 | } 42 | 43 | func SetStringIfNotEmpty(d *schema.ResourceData, key string, setter func(*string)) { 44 | if v, ok := d.GetOk(key); ok { 45 | if s, valid := v.(string); valid && s != "" { 46 | setter(redis.String(s)) 47 | } 48 | } 49 | } 50 | 51 | func SetIntIfPositive(d *schema.ResourceData, key string, setter func(*int)) { 52 | if v, ok := d.GetOk(key); ok { 53 | if i, valid := v.(int); valid && i > 0 { 54 | setter(redis.Int(i)) 55 | } 56 | } 57 | } 58 | 59 | func SetInt(d *schema.ResourceData, key string, setter func(*int)) { 60 | if v, ok := d.GetOk(key); ok { 61 | if i, valid := v.(int); valid { 62 | setter(redis.Int(i)) 63 | } 64 | } 65 | } 66 | 67 | func SetFloat64(d *schema.ResourceData, key string, setter func(*float64)) { 68 | if v, ok := d.GetOk(key); ok { 69 | if f, valid := v.(float64); valid { 70 | setter(redis.Float64(f)) 71 | } 72 | } 73 | } 74 | 75 | func SetBool(d *schema.ResourceData, key string, setter func(*bool)) { 76 | if v, ok := d.GetOk(key); ok { 77 | if b, valid := v.(bool); valid { 78 | setter(redis.Bool(b)) 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /provider/privatelink/testdata/pro_private_link.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_cloud_account = "%s" 4 | rediscloud_private_link_share_name = "%s" 5 | rediscloud_database_password = "%s" 6 | } 7 | 8 | data "rediscloud_payment_method" "card" { 9 | card_type = "Visa" 10 | last_four_numbers = "5556" 11 | } 12 | 13 | data "rediscloud_cloud_account" "account" { 14 | exclude_internal_account = true 15 | provider_type = "AWS" 16 | name = local.rediscloud_cloud_account 17 | } 18 | 19 | resource "rediscloud_subscription" "pro_subscription" { 20 | name = local.rediscloud_subscription_name 21 | payment_method_id = data.rediscloud_payment_method.card.id 22 | 23 | cloud_provider { 24 | provider = data.rediscloud_cloud_account.account.provider_type 25 | cloud_account_id = data.rediscloud_cloud_account.account.id 26 | region { 27 | region = "eu-west-1" 28 | networking_deployment_cidr = "10.0.0.0/24" 29 | preferred_availability_zones = ["eu-west-1a"] 30 | } 31 | } 32 | 33 | creation_plan { 34 | dataset_size_in_gb = 1 35 | quantity = 1 36 | replication = true 37 | throughput_measurement_by = "operations-per-second" 38 | throughput_measurement_value = 20000 39 | } 40 | } 41 | 42 | ## this will give some connections and databases in the output 43 | resource "rediscloud_subscription_database" "pro_database" { 44 | subscription_id = rediscloud_subscription.pro_subscription.id 45 | name = "db" 46 | memory_limit_in_gb = 1 47 | password = local.rediscloud_database_password 48 | protocol = "redis" 49 | data_persistence = "none" 50 | throughput_measurement_by = "operations-per-second" 51 | throughput_measurement_value = 10000 52 | } 53 | 54 | 55 | resource "rediscloud_private_link" "pro_private_link" { 56 | subscription_id = rediscloud_subscription.pro_subscription.id 57 | share_name = local.rediscloud_private_link_share_name 58 | 59 | principal { 60 | principal = "123456789012" 61 | principal_type = "aws_account" 62 | principal_alias = "principal 1" 63 | } 64 | 65 | principal { 66 | principal = "234567890123" 67 | principal_type = "aws_account" 68 | principal_alias = "principal 2" 69 | } 70 | 71 | depends_on = [rediscloud_subscription_database.pro_database] 72 | } 73 | 74 | data "rediscloud_private_link" "pro_private_link" { 75 | subscription_id = rediscloud_private_link.pro_private_link.subscription_id 76 | } 77 | 78 | # data "rediscloud_private_link_endpoint_script" "endpoint_script" { 79 | # subscription_id = rediscloud_private_link.pro_private_link.subscription_id 80 | # } 81 | # 82 | # output "endpoint_script" { 83 | # value = data.rediscloud_private_link_endpoint_script.endpoint_script 84 | # } 85 | 86 | 87 | -------------------------------------------------------------------------------- /provider/datasource_rediscloud_acl_user.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "context" 5 | "github.com/RedisLabs/rediscloud-go-api/redis" 6 | "github.com/RedisLabs/rediscloud-go-api/service/access_control_lists/users" 7 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/client" 8 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 10 | "strconv" 11 | ) 12 | 13 | func dataSourceRedisCloudAclUser() *schema.Resource { 14 | return &schema.Resource{ 15 | Description: "The ACL User is an authenticated entity whose permissions are described by an associated Role", 16 | ReadContext: dataSourceRedisCloudAclUserRead, 17 | 18 | Schema: map[string]*schema.Schema{ 19 | "name": { 20 | Description: "A meaningful name to identify the user", 21 | Type: schema.TypeString, 22 | Required: true, 23 | }, 24 | "role": { 25 | Description: "The Role which this User has", 26 | Type: schema.TypeString, 27 | Computed: true, 28 | }, 29 | }, 30 | } 31 | } 32 | 33 | func dataSourceRedisCloudAclUserRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 34 | var diags diag.Diagnostics 35 | api := meta.(*client.ApiClient) 36 | 37 | var filters []func(user *users.GetUserResponse) bool 38 | if v, ok := d.GetOk("name"); ok { 39 | filters = append(filters, func(user *users.GetUserResponse) bool { 40 | return redis.StringValue(user.Name) == v.(string) 41 | }) 42 | } 43 | 44 | list, err := api.Client.Users.List(ctx) 45 | if err != nil { 46 | return diag.FromErr(err) 47 | } 48 | list = filterUsers(list, filters) 49 | 50 | if len(list) == 0 { 51 | return diag.Errorf("Your query returned no results. Please change your search criteria and try again.") 52 | } 53 | 54 | if len(list) > 1 { 55 | return diag.Errorf("Your query returned more than one result. Please change try a more specific search criteria and try again.") 56 | } 57 | 58 | user := list[0] 59 | d.SetId(strconv.Itoa(redis.IntValue(user.ID))) 60 | if err := d.Set("name", redis.StringValue(user.Name)); err != nil { 61 | return diag.FromErr(err) 62 | } 63 | if err := d.Set("role", redis.StringValue(user.Role)); err != nil { 64 | return diag.FromErr(err) 65 | } 66 | 67 | return diags 68 | } 69 | 70 | func filterUsers(list []*users.GetUserResponse, filters []func(*users.GetUserResponse) bool) []*users.GetUserResponse { 71 | var filtered []*users.GetUserResponse 72 | for _, user := range list { 73 | if filterUser(user, filters) { 74 | filtered = append(filtered, user) 75 | } 76 | } 77 | return filtered 78 | } 79 | 80 | func filterUser(rule *users.GetUserResponse, filters []func(*users.GetUserResponse) bool) bool { 81 | for _, filter := range filters { 82 | if !filter(rule) { 83 | return false 84 | } 85 | } 86 | return true 87 | } 88 | -------------------------------------------------------------------------------- /provider/privatelink/testdata/active_active_private_link.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | rediscloud_cloud_account = "%s" 4 | rediscloud_private_link_share_name = "%s" 5 | rediscloud_database_password = "%s" 6 | } 7 | 8 | data "rediscloud_payment_method" "card" { 9 | card_type = "Visa" 10 | last_four_numbers = "5556" 11 | } 12 | 13 | 14 | resource "rediscloud_active_active_subscription" "aa_subscription" { 15 | name = local.rediscloud_subscription_name 16 | payment_method = "credit-card" 17 | payment_method_id = data.rediscloud_payment_method.card.id 18 | cloud_provider = "AWS" 19 | 20 | creation_plan { 21 | memory_limit_in_gb = 1 22 | quantity = 1 23 | region { 24 | region = "eu-west-1" 25 | networking_deployment_cidr = "192.168.0.0/24" 26 | write_operations_per_second = 1000 27 | read_operations_per_second = 1000 28 | } 29 | region { 30 | region = "eu-west-2" 31 | networking_deployment_cidr = "10.0.1.0/24" 32 | write_operations_per_second = 1000 33 | read_operations_per_second = 1000 34 | } 35 | } 36 | } 37 | 38 | resource "rediscloud_active_active_subscription_database" "aa_database" { 39 | subscription_id = rediscloud_active_active_subscription.aa_subscription.id 40 | name = "db" 41 | memory_limit_in_gb = 1 42 | global_data_persistence = "aof-every-1-second" 43 | global_password = local.rediscloud_database_password 44 | } 45 | 46 | data "rediscloud_active_active_subscription_regions" "aa_regions_info" { 47 | subscription_name = rediscloud_active_active_subscription.aa_subscription.name 48 | depends_on = [rediscloud_active_active_subscription_database.aa_database] 49 | } 50 | 51 | 52 | resource "rediscloud_active_active_private_link" "aa_private_link" { 53 | subscription_id = rediscloud_active_active_subscription.aa_subscription.id 54 | region_id = data.rediscloud_active_active_subscription_regions.aa_regions_info.regions[0].region_id 55 | share_name = "private_link testing" 56 | 57 | principal { 58 | principal = "123456789012" 59 | principal_type = "aws_account" 60 | principal_alias = "terraform test aws account" 61 | } 62 | principal { 63 | principal = "688576139039" 64 | principal_type = "aws_account" 65 | principal_alias = "terraform test aws account 2" 66 | } 67 | } 68 | 69 | data "rediscloud_active_active_private_link" "aa_private_link" { 70 | subscription_id = rediscloud_active_active_private_link.aa_private_link.subscription_id 71 | region_id = data.rediscloud_active_active_subscription_regions.aa_regions_info.regions[0].region_id 72 | } 73 | 74 | # data "rediscloud_private_link_endpoint_script" "endpoint_script" { 75 | # subscription_id = rediscloud_private_link.private_link.subscription_id 76 | # } 77 | -------------------------------------------------------------------------------- /provider/activeactive/testdata/active_active_sub_redis7.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | rediscloud_subscription_name = "%s" 3 | } 4 | 5 | data "rediscloud_payment_method" "card" { 6 | card_type = "Visa" 7 | last_four_numbers = "5556" 8 | } 9 | 10 | resource "rediscloud_active_active_subscription" "example" { 11 | name = local.rediscloud_subscription_name 12 | payment_method_id = data.rediscloud_payment_method.card.id 13 | cloud_provider = "AWS" 14 | redis_version = "7.4" 15 | 16 | creation_plan { 17 | memory_limit_in_gb = 1 18 | modules = ["RedisJSON"] 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 | maintenance_windows { 35 | mode = "manual" 36 | window { 37 | start_hour = 22 38 | duration_in_hours = 8 39 | days = ["Monday", "Thursday"] 40 | } 41 | window { 42 | start_hour = 12 43 | duration_in_hours = 6 44 | days = ["Friday", "Saturday", "Sunday"] 45 | } 46 | } 47 | } 48 | 49 | resource "rediscloud_active_active_subscription_database" "example" { 50 | subscription_id = rediscloud_active_active_subscription.example.id 51 | name = local.rediscloud_subscription_name 52 | redis_version = "7.4" 53 | dataset_size_in_gb = 1 54 | global_data_persistence = "aof-every-1-second" 55 | global_password = "some-random-pass-2" 56 | global_source_ips = ["192.168.0.0/16"] 57 | global_alert { 58 | name = "dataset-size" 59 | value = 40 60 | } 61 | 62 | global_modules = ["RedisJSON"] 63 | 64 | override_region { 65 | name = "us-east-2" 66 | enable_default_user = true 67 | override_global_source_ips = ["192.10.0.0/16"] 68 | } 69 | 70 | override_region { 71 | name = "us-east-1" 72 | override_global_data_persistence = "none" 73 | override_global_password = "region-specific-password" 74 | override_global_alert { 75 | name = "dataset-size" 76 | value = 60 77 | } 78 | } 79 | 80 | tags = { 81 | "environment" = "production" 82 | "cost_center" = "0700" 83 | } 84 | } 85 | 86 | 87 | data "rediscloud_active_active_subscription" "example" { 88 | name = rediscloud_active_active_subscription.example.name 89 | } 90 | 91 | data "rediscloud_active_active_subscription_regions" "example" { 92 | subscription_name = rediscloud_active_active_subscription.example.name 93 | } 94 | -------------------------------------------------------------------------------- /provider/datasource_rediscloud_active_active_private_service_connect.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "context" 5 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/client" 6 | "strconv" 7 | 8 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 10 | ) 11 | 12 | func dataSourceActiveActivePrivateServiceConnect() *schema.Resource { 13 | return &schema.Resource{ 14 | Description: "The Active-Active Private Service Connect data source allows access to an available Private Service Connect Service within your Redis Enterprise Cloud Account.", 15 | ReadContext: dataSourceActiveActivePrivateServiceConnectRead, 16 | 17 | Schema: map[string]*schema.Schema{ 18 | "subscription_id": { 19 | Description: "The ID of an Active-Active subscription", 20 | Type: schema.TypeString, 21 | Required: true, 22 | }, 23 | "region_id": { 24 | Description: "The ID of the GCP region", 25 | Type: schema.TypeInt, 26 | Required: true, 27 | }, 28 | "private_service_connect_service_id": { 29 | Description: "The ID of the Private Service Connect Service relative to the associated subscription", 30 | Type: schema.TypeInt, 31 | Computed: true, 32 | }, 33 | "connection_host_name": { 34 | Description: "The connection host name", 35 | Type: schema.TypeString, 36 | Computed: true, 37 | }, 38 | "service_attachment_name": { 39 | Description: "The service attachment name", 40 | Type: schema.TypeString, 41 | Computed: true, 42 | }, 43 | "status": { 44 | Description: "The Private Service Connect status", 45 | Type: schema.TypeString, 46 | Computed: true, 47 | }, 48 | }, 49 | } 50 | } 51 | 52 | func dataSourceActiveActivePrivateServiceConnectRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 53 | var diags diag.Diagnostics 54 | api := meta.(*client.ApiClient) 55 | 56 | subId, err := strconv.Atoi(d.Get("subscription_id").(string)) 57 | if err != nil { 58 | return diag.FromErr(err) 59 | } 60 | 61 | regionId := d.Get("region_id").(int) 62 | pscService, err := api.Client.PrivateServiceConnect.GetActiveActiveService(ctx, subId, regionId) 63 | if err != nil { 64 | return diag.FromErr(err) 65 | } 66 | 67 | d.SetId(buildPrivateServiceConnectActiveActiveId(subId, regionId, *pscService.ID)) 68 | if err := d.Set("private_service_connect_service_id", pscService.ID); err != nil { 69 | return diag.FromErr(err) 70 | } 71 | if err := d.Set("connection_host_name", pscService.ConnectionHostName); err != nil { 72 | return diag.FromErr(err) 73 | } 74 | if err := d.Set("service_attachment_name", pscService.ServiceAttachmentName); err != nil { 75 | return diag.FromErr(err) 76 | } 77 | if err := d.Set("status", pscService.Status); err != nil { 78 | return diag.FromErr(err) 79 | } 80 | 81 | return diags 82 | } 83 | -------------------------------------------------------------------------------- /provider/datasource_rediscloud_acl_rule.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "context" 5 | "github.com/RedisLabs/rediscloud-go-api/redis" 6 | "github.com/RedisLabs/rediscloud-go-api/service/access_control_lists/redis_rules" 7 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/client" 8 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 10 | "strconv" 11 | ) 12 | 13 | func dataSourceRedisCloudAclRule() *schema.Resource { 14 | return &schema.Resource{ 15 | Description: "The ACL Rule (known also as RedisRule) allows fine-grained permissions to be assigned to a subset of ACL Users", 16 | ReadContext: dataSourceRedisCloudAclRuleRead, 17 | 18 | Schema: map[string]*schema.Schema{ 19 | "name": { 20 | Description: "A meaningful name to identify the rule", 21 | Type: schema.TypeString, 22 | Required: true, 23 | }, 24 | "rule": { 25 | Description: "The Rule itself, must comply with Redis' ACL syntax", 26 | Type: schema.TypeString, 27 | Computed: true, 28 | }, 29 | }, 30 | } 31 | } 32 | 33 | func dataSourceRedisCloudAclRuleRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 34 | var diags diag.Diagnostics 35 | api := meta.(*client.ApiClient) 36 | 37 | var filters []func(rule *redis_rules.GetRedisRuleResponse) bool 38 | if v, ok := d.GetOk("name"); ok { 39 | filters = append(filters, func(rule *redis_rules.GetRedisRuleResponse) bool { 40 | return redis.StringValue(rule.Name) == v.(string) 41 | }) 42 | } 43 | 44 | list, err := api.Client.RedisRules.List(ctx) 45 | if err != nil { 46 | return diag.FromErr(err) 47 | } 48 | list = filterRules(list, filters) 49 | 50 | if len(list) == 0 { 51 | return diag.Errorf("Your query returned no results. Please change your search criteria and try again.") 52 | } 53 | 54 | if len(list) > 1 { 55 | return diag.Errorf("Your query returned more than one result. Please change try a more specific search criteria and try again.") 56 | } 57 | 58 | rule := list[0] 59 | d.SetId(strconv.Itoa(redis.IntValue(rule.ID))) 60 | if err := d.Set("name", redis.StringValue(rule.Name)); err != nil { 61 | return diag.FromErr(err) 62 | } 63 | if err := d.Set("rule", redis.StringValue(rule.ACL)); err != nil { 64 | return diag.FromErr(err) 65 | } 66 | 67 | return diags 68 | } 69 | 70 | func filterRules(list []*redis_rules.GetRedisRuleResponse, filters []func(*redis_rules.GetRedisRuleResponse) bool) []*redis_rules.GetRedisRuleResponse { 71 | var filtered []*redis_rules.GetRedisRuleResponse 72 | for _, rule := range list { 73 | if filterRule(rule, filters) { 74 | filtered = append(filtered, rule) 75 | } 76 | } 77 | return filtered 78 | } 79 | 80 | func filterRule(rule *redis_rules.GetRedisRuleResponse, filters []func(*redis_rules.GetRedisRuleResponse) bool) bool { 81 | for _, filter := range filters { 82 | if !filter(rule) { 83 | return false 84 | } 85 | } 86 | return true 87 | } 88 | -------------------------------------------------------------------------------- /docs/data-sources/rediscloud_active_active_subscription.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_active_active_subscription" 4 | description: |- 5 | Active Active Subscription data source in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Data Source: rediscloud_active_active_subscription 9 | 10 | This data source allows access to the details of an existing subscription within your Redis Enterprise Cloud account. 11 | 12 | -> **Note:** This is referring to Active-Active Subscriptions only. See also `rediscloud_subscription` (Pro) and `rediscloud_essentials_subscription`. 13 | 14 | ## Example Usage 15 | 16 | The following example shows how to use the name attribute to locate a subscription within your Redis Enterprise 17 | Cloud account. 18 | 19 | ```hcl 20 | data "rediscloud_active_active_subscription" "example" { 21 | name = "My AA Subscription" 22 | } 23 | output "rediscloud_active_active_subscription" { 24 | value = data.rediscloud_active_active_subscription.example.id 25 | } 26 | ``` 27 | 28 | ## Argument Reference 29 | 30 | * `name` - (Required) The name of the subscription to filter returned subscriptions 31 | 32 | ## Attribute reference 33 | 34 | `id` is set to the ID of the found subscription. 35 | 36 | * `aws_account_id` - AWS account ID that the subscription is deployed in (AWS subscriptions only). 37 | * `payment_method` (Optional) The payment method for the requested subscription, (either `credit-card` 38 | or `marketplace`). If `credit-card` is specified, `payment_method_id` must be defined. Default: 'credit-card'. **( 39 | Changes to) this attribute are ignored after creation.** 40 | * `payment_method_id` - A valid payment method pre-defined in the current account 41 | * `cloud_provider` - The cloud provider used with the subscription, (either `AWS` or `GCP`). 42 | * `number_of_databases` - The number of databases that are linked to this subscription. 43 | * `status` - Current status of the subscription 44 | * `maintenance_windows` - Details about the subscription's maintenance window specification, documented below 45 | * `pricing` - A list of pricing objects, documented below 46 | 47 | The `maintenance_windows` object has these attributes: 48 | 49 | * `mode` - Either `automatic` (Redis specified) or `manual` (User specified) 50 | * `window` - A list of windows (if manual mode) 51 | 52 | The `window` object has these attributes: 53 | 54 | * `start_hour` - What hour in the day (0-23) the window opens 55 | * `duration_in_hours` - How long the window is open 56 | * `days` - A list of weekdays on which the window is open ('Monday', 'Tuesday' etc) 57 | 58 | The `pricing` object has these attributes: 59 | 60 | * `database_name` - The database this pricing entry applies to. 61 | * `type` - The type of cost e.g. 'Shards'. 62 | * `typeDetails` - Further detail e.g. 'micro'. 63 | * `quantity` - Self-explanatory. 64 | * `quantityMeasurement` - Self-explanatory. 65 | * `pricePerUnit` - Self-explanatory. 66 | * `priceCurrency` - Self-explanatory e.g. 'USD'. 67 | * `pricePeriod` - Self-explanatory e.g. 'hour'. 68 | * `region` - Self-explanatory, if the cost is associated with a particular region. 69 | -------------------------------------------------------------------------------- /docs/resources/rediscloud_cloud_account.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "rediscloud" 3 | page_title: "Redis Cloud: rediscloud_cloud_account" 4 | description: |- 5 | Cloud Account resource in the Redis Cloud Terraform provider. 6 | --- 7 | 8 | # Resource: rediscloud_cloud_account 9 | 10 | Creates a Cloud Account resource representing the access credentials to a cloud provider account, (`AWS`). 11 | Redis Enterprise Cloud uses these credentials to provision databases within your infrastructure. 12 | 13 | ## Example Usage 14 | 15 | The following example defines a new AWS Cloud Account that is then used with a Subscription. 16 | 17 | ```hcl-terraform 18 | resource "rediscloud_cloud_account" "example" { 19 | access_key_id = "abcdefg" 20 | access_secret_key = "9876543" 21 | console_username = "username" 22 | console_password = "password" 23 | name = "Example account" 24 | provider_type = "AWS" 25 | sign_in_login_url = "https://1234567890.signin.aws.amazon.com/console" 26 | } 27 | 28 | resource "rediscloud_subscription" "example" { 29 | name = "My Example Subscription" 30 | payment_method_id = data.rediscloud_payment_method.card.id 31 | memory_storage = "ram" 32 | 33 | cloud_provider { 34 | provider = data.rediscloud_cloud_account.example.provider_type 35 | cloud_account_id = data.rediscloud_cloud_account.example.id 36 | # ... 37 | } 38 | # ... 39 | } 40 | 41 | ``` 42 | 43 | ## Argument Reference 44 | 45 | The following arguments are supported: 46 | 47 | * `access_key_id` - (Required) Cloud provider access key. 48 | 49 | * `access_secret_key` - (Required) Cloud provider secret key. 50 | Note that drift cannot currently be detected for this. 51 | 52 | * `console_username` - (Required) Cloud provider management console username. 53 | Note that drift cannot currently be detected for this. 54 | 55 | * `console_password` - (Required) Cloud provider management console password. 56 | Note that drift cannot currently be detected for this. 57 | 58 | * `name` - (Required) Display name of the account. 59 | 60 | * `provider_type` - (Required) Cloud provider type - either `AWS` or `GCP`. 61 | Note that drift cannot currently be detected for this. **Modifying this attribute will force creation of a new resource.** 62 | 63 | * `sign_in_login_url` - (Required) Cloud provider management console login URL. 64 | Note that drift cannot currently be detected for this. 65 | 66 | ### Timeouts 67 | 68 | The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: 69 | 70 | * `create` - (Defaults to 5 mins) Used when creating the Cloud Account 71 | * `update` - (Defaults to 5 mins) Used when updating the Cloud Account 72 | * `delete` - (Defaults to 5 mins) Used when destroying the Cloud Account 73 | 74 | ## Attribute Reference 75 | 76 | `status` is set to the current status of the account - `draft`, `pending` or `active`. 77 | 78 | ## Import 79 | 80 | `rediscloud_cloud_account` can be imported using the ID of the Cloud Account, e.g. 81 | 82 | ``` 83 | $ terraform import rediscloud_cloud_account.example 12345678 84 | ``` 85 | -------------------------------------------------------------------------------- /provider/resource_rediscloud_cloud_account_test.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/RedisLabs/rediscloud-go-api/redis" 7 | client2 "github.com/RedisLabs/terraform-provider-rediscloud/provider/client" 8 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/utils" 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" 10 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 11 | "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" 12 | "os" 13 | "regexp" 14 | "strconv" 15 | "testing" 16 | ) 17 | 18 | func TestAccResourceRedisCloudCloudAccount_basic(t *testing.T) { 19 | 20 | utils.AccRequiresEnvVar(t, "EXECUTE_TESTS") 21 | 22 | if testing.Short() { 23 | t.Skip("Required environment variables currently not available under CI") 24 | } 25 | 26 | name := acctest.RandomWithPrefix(testResourcePrefix) 27 | 28 | tf := fmt.Sprintf(testAccResourceRedisCloudCloudAccount, 29 | os.Getenv("AWS_ACCESS_KEY_ID"), 30 | os.Getenv("AWS_ACCESS_SECRET_KEY"), 31 | os.Getenv("AWS_CONSOLE_USERNAME"), 32 | os.Getenv("AWS_CONSOLE_PASSWORD"), 33 | name, 34 | os.Getenv("AWS_SIGNIN_URL"), 35 | ) 36 | const resourceName = "rediscloud_cloud_account.test" 37 | 38 | resource.ParallelTest(t, resource.TestCase{ 39 | PreCheck: func() { testAccPreCheck(t); testAccAwsCloudAccountPreCheck(t) }, 40 | ProviderFactories: providerFactories, 41 | CheckDestroy: testAccCheckCloudAccountDestroy, 42 | Steps: []resource.TestStep{ 43 | { 44 | Config: tf, 45 | Check: resource.ComposeAggregateTestCheckFunc( 46 | resource.TestMatchResourceAttr( 47 | resourceName, "id", regexp.MustCompile("^\\d*$")), 48 | resource.TestCheckResourceAttr( 49 | resourceName, "status", "active"), 50 | ), 51 | }, 52 | { 53 | ResourceName: resourceName, 54 | ImportState: true, 55 | ImportStateVerify: true, 56 | ImportStateVerifyIgnore: []string{"access_secret_key", "console_username", "console_password", "sign_in_login_url"}, 57 | }, 58 | }, 59 | }) 60 | } 61 | 62 | func testAccCheckCloudAccountDestroy(s *terraform.State) error { 63 | client := testProvider.Meta().(*client2.ApiClient) 64 | 65 | for _, r := range s.RootModule().Resources { 66 | if r.Type != "rediscloud_cloud_account" { 67 | continue 68 | } 69 | 70 | subId, err := strconv.Atoi(r.Primary.ID) 71 | if err != nil { 72 | return err 73 | } 74 | 75 | accounts, err := client.Client.CloudAccount.List(context.TODO()) 76 | if err != nil { 77 | return err 78 | } 79 | 80 | for _, account := range accounts { 81 | if redis.IntValue(account.ID) == subId { 82 | return fmt.Errorf("account %d still exists", subId) 83 | } 84 | } 85 | } 86 | 87 | return nil 88 | } 89 | 90 | const testAccResourceRedisCloudCloudAccount = ` 91 | resource "rediscloud_cloud_account" "test" { 92 | access_key_id = "%s" 93 | access_secret_key = "%s" 94 | console_username = "%s" 95 | console_password = "%s" 96 | name = "%s" 97 | provider_type = "AWS" 98 | sign_in_login_url = "%s" 99 | } 100 | ` 101 | -------------------------------------------------------------------------------- /provider/privatelink/utils_test.go: -------------------------------------------------------------------------------- 1 | package privatelink 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/RedisLabs/rediscloud-go-api/redis" 7 | pl "github.com/RedisLabs/rediscloud-go-api/service/privatelink" 8 | "github.com/stretchr/testify/assert" 9 | ) 10 | 11 | func TestUnitFlattenConnections(t *testing.T) { 12 | // Test that flattenConnections produces keys that match the schema 13 | connections := []*pl.PrivateLinkConnection{ 14 | { 15 | AssociationId: redis.String("assoc-123"), 16 | ConnectionId: redis.String("conn-456"), 17 | Type: redis.String("vpc-endpoint"), 18 | OwnerId: redis.String("owner-789"), 19 | AssociationDate: redis.String("2024-01-01"), 20 | }, 21 | } 22 | 23 | result := flattenConnections(connections) 24 | 25 | assert.Len(t, result, 1) 26 | 27 | conn := result[0] 28 | assert.Contains(t, conn, "association_id") 29 | assert.Contains(t, conn, "connection_id") 30 | assert.Contains(t, conn, "connection_type") 31 | assert.Contains(t, conn, "owner_id") 32 | assert.Contains(t, conn, "association_date") 33 | 34 | assert.Equal(t, "assoc-123", conn["association_id"]) 35 | assert.Equal(t, "conn-456", conn["connection_id"]) 36 | assert.Equal(t, "vpc-endpoint", conn["connection_type"]) 37 | assert.Equal(t, "owner-789", conn["owner_id"]) 38 | assert.Equal(t, "2024-01-01", conn["association_date"]) 39 | } 40 | 41 | func TestUnitFlattenConnectionsEmpty(t *testing.T) { 42 | result := flattenConnections([]*pl.PrivateLinkConnection{}) 43 | assert.Len(t, result, 0) 44 | } 45 | 46 | func TestUnitFlattenDatabases(t *testing.T) { 47 | databases := []*pl.PrivateLinkDatabase{ 48 | { 49 | DatabaseId: redis.Int(12345), 50 | Port: redis.Int(16379), 51 | ResourceLinkEndpoint: redis.String("endpoint.example.com"), 52 | }, 53 | } 54 | 55 | result := flattenDatabases(databases) 56 | 57 | assert.Len(t, result, 1) 58 | 59 | db := result[0] 60 | assert.Contains(t, db, "database_id") 61 | assert.Contains(t, db, "port") 62 | assert.Contains(t, db, "resource_link_endpoint") 63 | 64 | assert.Equal(t, 12345, db["database_id"]) 65 | assert.Equal(t, 16379, db["port"]) 66 | assert.Equal(t, "endpoint.example.com", db["resource_link_endpoint"]) 67 | } 68 | 69 | func TestUnitFlattenPrincipals(t *testing.T) { 70 | principals := []*pl.PrivateLinkPrincipal{ 71 | { 72 | Principal: redis.String("arn:aws:iam::123456789012:root"), 73 | Type: redis.String("aws_account"), 74 | Alias: redis.String("my-account"), 75 | }, 76 | { 77 | Principal: redis.String("arn:aws:iam::987654321098:root"), 78 | Type: redis.String("aws_account"), 79 | Alias: redis.String("another-account"), 80 | }, 81 | } 82 | 83 | result := flattenPrincipals(principals) 84 | 85 | assert.Len(t, result, 2) 86 | 87 | // Verify keys 88 | for _, p := range result { 89 | assert.Contains(t, p, "principal") 90 | assert.Contains(t, p, "principal_type") 91 | assert.Contains(t, p, "principal_alias") 92 | } 93 | 94 | // Results should be sorted by principal 95 | assert.Equal(t, "arn:aws:iam::123456789012:root", result[0]["principal"]) 96 | assert.Equal(t, "arn:aws:iam::987654321098:root", result[1]["principal"]) 97 | } 98 | -------------------------------------------------------------------------------- /provider/transitgateway/datasource_rediscloud_active_active_transit_gateway_invitations.go: -------------------------------------------------------------------------------- 1 | package transitgateway 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "strconv" 7 | 8 | "github.com/RedisLabs/terraform-provider-rediscloud/provider/client" 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 10 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 11 | ) 12 | 13 | func DataSourceRedisCloudActiveActiveTransitGatewayInvitations() *schema.Resource { 14 | return &schema.Resource{ 15 | Description: "Lists AWS Transit Gateway resource share invitations for a specific region in an Active-Active subscription. Invitations are created when you share an AWS Transit Gateway with Redis Cloud via AWS Resource Manager.", 16 | ReadContext: dataSourceRedisCloudActiveActiveTransitGatewayInvitationsRead, 17 | 18 | Schema: map[string]*schema.Schema{ 19 | "subscription_id": { 20 | Description: "The ID of the Active-Active subscription", 21 | Type: schema.TypeString, 22 | Required: true, 23 | }, 24 | "region_id": { 25 | Description: "The region ID", 26 | Type: schema.TypeInt, 27 | Required: true, 28 | }, 29 | "invitations": { 30 | Description: "List of Transit Gateway invitations", 31 | Type: schema.TypeList, 32 | Computed: true, 33 | Elem: &schema.Resource{ 34 | Schema: map[string]*schema.Schema{ 35 | "id": { 36 | Description: "The invitation ID", 37 | Type: schema.TypeInt, 38 | Computed: true, 39 | }, 40 | "name": { 41 | Description: "The name of the resource share", 42 | Type: schema.TypeString, 43 | Computed: true, 44 | }, 45 | "resource_share_uid": { 46 | Description: "The AWS Resource Share ARN", 47 | Type: schema.TypeString, 48 | Computed: true, 49 | }, 50 | "aws_account_id": { 51 | Description: "The AWS account ID", 52 | Type: schema.TypeString, 53 | Computed: true, 54 | }, 55 | "status": { 56 | Description: "The invitation status", 57 | Type: schema.TypeString, 58 | Computed: true, 59 | }, 60 | "shared_date": { 61 | Description: "The date the resource was shared", 62 | Type: schema.TypeString, 63 | Computed: true, 64 | }, 65 | }, 66 | }, 67 | }, 68 | }, 69 | } 70 | } 71 | 72 | func dataSourceRedisCloudActiveActiveTransitGatewayInvitationsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 73 | var diags diag.Diagnostics 74 | api := meta.(*client.ApiClient) 75 | 76 | subId, err := strconv.Atoi(d.Get("subscription_id").(string)) 77 | if err != nil { 78 | return diag.FromErr(err) 79 | } 80 | 81 | regionId := d.Get("region_id").(int) 82 | 83 | invitations, err := api.Client.TransitGatewayAttachments.ListInvitationsActiveActive(ctx, subId, regionId) 84 | if err != nil { 85 | return diag.FromErr(err) 86 | } 87 | 88 | if err := d.Set("invitations", flattenTransitGatewayInvitations(invitations)); err != nil { 89 | return diag.FromErr(err) 90 | } 91 | 92 | d.SetId(fmt.Sprintf("%d/%d", subId, regionId)) 93 | 94 | return diags 95 | } 96 | -------------------------------------------------------------------------------- /RELEASE_PROCESS.md: -------------------------------------------------------------------------------- 1 | # Release Process 2 | 3 | This document describes how to release a new version of `terraform-provider-rediscloud`. 4 | 5 | ## Prerequisites 6 | 7 | You need: 8 | - **Push access to GitHub** - ability to push tags to the repository 9 | - **PR permissions** - ability to submit and merge pull requests 10 | 11 | That's it! The release automation handles everything else (building binaries, GPG signing, publishing to the Terraform Registry). 12 | 13 | ## Release Steps 14 | 15 | ### 1. Open a Pull Request to `main` 16 | 17 | Create a PR with your changes targeting the `main` branch. The PR should: 18 | - Include all the changes you want to release 19 | - Update the CHANGELOG if needed (follow existing format) 20 | - Pass all required checks before merging 21 | 22 | You should get someone to test and review your changes manually before releasing. 23 | 24 | ### 2. Wait for Smoke Tests to Pass 25 | 26 | The PR will automatically run smoke tests via the `Terraform Provider Checks - PR workflow` workflow. 27 | 28 | The smoke tests consist of acceptance tests that will check the major resources to ensure that your changes did not cause any major regressions. They will typically take between 30 and 60 minutes. 29 | 30 | Additionally, these checks must pass: 31 | - `go build` - ensures the provider compiles 32 | - `tfproviderlint` - Terraform provider linting 33 | - `terraform providers schema` - validates schema generation 34 | - `go unit test` - runs unit tests 35 | 36 | **Do not merge until all smoke tests pass.** 37 | 38 | ### 3. Merge the Pull Request 39 | 40 | Once the smoke tests pass, merge the PR to `main`. 41 | 42 | ### 4. Tag and Push 43 | 44 | After merging to `main`: 45 | 46 | ```bash 47 | # Switch to main and pull the merged changes 48 | git checkout main 49 | git pull origin main 50 | 51 | # Create an annotated tag with the version number 52 | # Use semantic versioning: v.. 53 | git tag v1.2.3 54 | 55 | # Push the tag to origin 56 | git push origin v1.2.3 57 | ``` 58 | 59 | **Important:** The tag MUST follow the pattern `v*` (e.g., `v1.2.3`, `v0.5.0`) for the release automation to trigger. 60 | 61 | ### 5. Automation Takes Over 62 | 63 | When you push the tag, the `release` workflow (`.github/workflows/release.yml`) automatically: 64 | 65 | 1. Checks out the tagged commit 66 | 2. Sets up Go using the version from `go.mod` 67 | 3. Imports the GPG signing key from GitHub secrets 68 | 4. Runs [GoReleaser](https://goreleaser.com/) to: 69 | - Build binaries for all supported platforms 70 | - Sign the binaries with GPG 71 | - Create a GitHub release 72 | - Publish to the Terraform Registry 73 | 74 | **No manual intervention required** - just wait for the workflow to complete (usually 5-10 minutes). 75 | 76 | ### 6. Create a GitHub Release 77 | 78 | To do this: 79 | 80 | 2. Go to https://github.com/RedisLabs/terraform-provider-rediscloud/releases 81 | 2. Add a new draft release 82 | 3. Update the description with your entries in the `CHANGELOG.md`. 83 | 84 | **This step is not required for the release to work** - it's just nice to have for users. 85 | 86 | ## Additional Resources 87 | 88 | - [Terraform Registry Provider Publishing](https://www.terraform.io/docs/registry/providers/publishing.html) 89 | - [GoReleaser Documentation](https://goreleaser.com/intro/) 90 | - [Semantic Versioning](https://semver.org/) 91 | --------------------------------------------------------------------------------