Update Terraform after upgrading Aiven for Caching to Aiven for Valkey™
Update Terraform configuration and state after upgrading from Aiven for Caching to Aiven for Valkey™. Ensure your infrastructure setup accurately reflects the upgraded service for seamless management and deployment.
Prerequisites
- Verify that you have upgraded your Aiven for Caching service to Aiven for Valkey through the Aiven Console or API.
- Ensure you have the latest version of Terraform installed.
- Review the Aiven Redis resource documentation and the Aiven Valkey resource documentation.
Step 1: Modify the Terraform Configuration
-
Replace
aiven_redis
andaiven_redis_user
resources in your configuration withaiven_valkey
andaiven_valkey_user
. -
Update Aiven for Caching-specific configuration parameters to their Aiven for Valkey equivalents. For example, change
redis_timeout
tovalkey_timeout
.Example configuration:
# Before: Aiven for Caching configuration
resource "aiven_redis" "caching_service" {
project = "PROJECT_NAME"
cloud_name = "CLOUD_REGION"
plan = "PLAN_NAME"
service_name = "SERVICE_NAME"
redis_user_config {
redis_timeout = 300
}
}# After: Aiven for Valkey configuration
resource "aiven_valkey" "caching_service" {
project = "PROJECT_NAME"
cloud_name = "CLOUD_REGION"
plan = "PLAN_NAME"
service_name = "SERVICE_NAME"
valkey_user_config {
valkey_timeout = 300
}
}
Step 2: Update the Terraform state
-
Import each Aiven for Valkey resource into the Terraform state:
terraform import aiven_valkey.valkey_service PROJECT_NAME/SERVICE_NAME
-
Import users associated with the Aiven for Valkey service. For each user, run:
terraform import aiven_valkey_user.user PROJECT_NAME/SERVICE_NAME/USERNAME
-
Remove any Aiven for Caching resources from the Terraform state to prevent duplicates:
terraform state rm aiven_redis.caching_service
Step 3: Verify and apply changes
-
Run
terraform plan
to confirm that the state and configuration are aligned:terraform plan
-
Apply the changes to finalize the update:
terraform apply