Terraform / Scaleway / Automated block storage volume snapshots
This module automates the creation of snapshots for Scaleway block storage volumes. Should be used in
conjuction with the Docker image .
Below a complete example of how to use this module in conjunction with the open source modules provided
by Scaleway:
locals {
parameters = {
SCW_ACCESS_KEY = scaleway_iam_api_key.serverless_job_awesome_instance_backup.access_key
SCW_SECRET_KEY = scaleway_iam_api_key.serverless_job_awesome_instance_backup.secret_key
}
}
# Create secrets for the Scaleway access and secret keys
module "secrets_awesome_instance" {
for_each = local. parameters
source = " scaleway-terraform-modules/secrets/scaleway"
version = " 0.1.0"
name = each. key
path = " /infrastructure/serverless/awesome-instance-snapshot"
data = each. value
}
# Create Container Registry Namespace
resource "scaleway_registry_namespace" "awesome" {
name = " my-cr"
description = " My container registry"
is_public = false
}
# The snapshot module
module "volume-snapshot-awesome-instance" {
source = " keepgettingbetter/volume-snapshot/scaleway"
version = " 0.0.1"
name = " awesome-instance"
# See https://github.com/keepgettingbetter/scaleway-volume-snapshot-docker
docker_image = " rg.nl-ams.scw.cloud/my-cr/instance-snapshot:0.0.1"
project_id = data. scaleway_account_project . my-awesome-project . project_id
scw_default_organization_id = data. scaleway_account_project . my-awesome-project . organization_id
scw_default_region = " nl-ams"
scw_default_zone = " nl-ams-1"
volume_id = " XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" # Replace with your actual volume ID
scw_access_key_secret_id = module. secrets_awesome_instance [" SCW_ACCESS_KEY" ]. secret_id
scw_access_key_secret_version = module. secrets_awesome_instance [" SCW_ACCESS_KEY" ]. secret_version
scw_secret_key_secret_id = module. secrets_awesome_instance [" SCW_SECRET_KEY" ]. secret_id
scw_secret_key_secret_version = module. secrets_awesome_instance [" SCW_SECRET_KEY" ]. secret_version
cron_snapshot = {
schedule = " 0 4 * * *"
timezone = " Europe/Amsterdam"
}
cron_clean = {
schedule = " 30 4 * * *"
timezone = " Europe/Amsterdam"
}
}
Name
Description
Type
Default
Required
docker_image
The Docker image URI to be used for the job definitions.
string
n/a
yes
name
The name to be used for the job definitions and resources.
string
n/a
yes
project_id
The ID of the Scaleway project where the job definitions will be created.
string
n/a
yes
scw_access_key_secret_id
The secret ID of the Scaleway access key for the job definition.
string
n/a
yes
scw_access_key_secret_version
The secret version of the Scaleway access key for the job definition.
string
n/a
yes
scw_default_organization_id
SCW_DEFAULT_ORGANIZATION_ID for scw cli.
string
n/a
yes
scw_default_region
SCW_DEFAULT_REGION for scw cli.
string
n/a
yes
scw_default_zone
SCW_DEFAULT_ZONE for scw cli.
string
n/a
yes
scw_secret_key_secret_id
The secret ID of the Scaleway secret key for the job definition.
string
n/a
yes
scw_secret_key_secret_version
The secret version of the Scaleway secret key for the job definition.
string
n/a
yes
volume_id
The ID of the volume to be snapshot.
string
n/a
yes
cron_clean
Cron schedule for the job definition. If not set, the job will not be scheduled.
object({ schedule = string timezone = string })
null
no
cron_snapshot
Cron schedule for the job definition. If not set, the job will not be scheduled.
object({ schedule = string timezone = string })
null
no