|
| 1 | +--- |
| 2 | +subcategory: "Databases" |
| 3 | +page_title: "Scaleway: scaleway_rdb_snapshot" |
| 4 | +--- |
| 5 | + |
| 6 | +# Resource: scaleway_rdb_snapshot |
| 7 | + |
| 8 | +Creates and manages Scaleway RDB (Relational Database) Snapshots. |
| 9 | +Snapshots are point-in-time backups of a database instance that can be used for recovery or duplication. |
| 10 | +For more information, refer to [the API documentation](https://www.scaleway.com/en/developers/api/managed-database-postgre-mysql/). |
| 11 | + |
| 12 | +## Example Usage |
| 13 | + |
| 14 | +### Example Basic Snapshot |
| 15 | + |
| 16 | +```terraform |
| 17 | +resource "scaleway_rdb_instance" "main" { |
| 18 | + name = "test-rdb-instance" |
| 19 | + node_type = "db-dev-s" |
| 20 | + engine = "PostgreSQL-15" |
| 21 | + is_ha_cluster = false |
| 22 | + disable_backup = true |
| 23 | + user_name = "my_initial_user" |
| 24 | + password = "thiZ_is_v&ry_s3cret" |
| 25 | + tags = ["terraform-test", "scaleway_rdb_instance", "minimal"] |
| 26 | + volume_type = "bssd" |
| 27 | + volume_size_in_gb = 10 |
| 28 | +} |
| 29 | +
|
| 30 | +resource "scaleway_rdb_snapshot" "test" { |
| 31 | + name = "initial-snapshot" |
| 32 | + instance_id = scaleway_rdb_instance.main.id |
| 33 | + depends_on = [scaleway_rdb_instance.main] |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +### Example with Expiration |
| 38 | + |
| 39 | +```terraform |
| 40 | +resource "scaleway_rdb_snapshot" "snapshot_with_expiration" { |
| 41 | + name = "snapshot-with-expiration" |
| 42 | + instance_id = scaleway_rdb_instance.main.id |
| 43 | + expires_at = "2025-01-31T00:00:00Z" |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +### Example with Multiple Snapshots |
| 48 | + |
| 49 | +```terraform |
| 50 | +resource "scaleway_rdb_snapshot" "daily_snapshot" { |
| 51 | + name = "daily-backup" |
| 52 | + instance_id = scaleway_rdb_instance.main.id |
| 53 | + depends_on = [scaleway_rdb_instance.main] |
| 54 | +} |
| 55 | +
|
| 56 | +resource "scaleway_rdb_snapshot" "weekly_snapshot" { |
| 57 | + name = "weekly-backup" |
| 58 | + instance_id = scaleway_rdb_instance.main.id |
| 59 | + expires_at = "2025-02-07T00:00:00Z" |
| 60 | + depends_on = [scaleway_rdb_instance.main] |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +## Argument Reference |
| 65 | + |
| 66 | +The following arguments are supported: |
| 67 | + |
| 68 | +- `name` - (Required) The name of the snapshot. |
| 69 | +- `instance_id` - (Required) The UUID of the database instance for which the snapshot is created. |
| 70 | +- `snapshot_id` - (Optional, ForceNew) The ID of an existing snapshot. This allows creating an instance from a specific snapshot ID. Conflicts with `engine`. |
| 71 | +- `expires_at` - (Optional) Expiration date of the snapshot in ISO 8601 format (e.g., `2025-01-31T00:00:00Z`). If not set, the snapshot will not expire automatically. |
| 72 | + |
| 73 | +### Additional Computed Attributes |
| 74 | + |
| 75 | +In addition to the arguments above, the following attributes are exported: |
| 76 | + |
| 77 | +- `id` - The unique ID of the snapshot. |
| 78 | +- `created_at` - The timestamp when the snapshot was created, in ISO 8601 format. |
| 79 | +- `updated_at` - The timestamp when the snapshot was last updated, in ISO 8601 format. |
| 80 | +- `status` - The current status of the snapshot (e.g., `ready`, `creating`, `error`). |
| 81 | +- `size` - The size of the snapshot in bytes. |
| 82 | +- `node_type` - The type of the database instance for which the snapshot was created. |
| 83 | +- `volume_type` - The type of volume used by the snapshot. |
| 84 | + |
| 85 | +## Attributes Reference |
| 86 | + |
| 87 | +- `region` - The region where the snapshot is stored. Defaults to the region set in the provider configuration. |
| 88 | + |
| 89 | +## Import |
| 90 | + |
| 91 | +RDB Snapshots can be imported using the `{region}/{snapshot_id}` format. |
| 92 | + |
| 93 | +### Example: |
| 94 | + |
| 95 | +```bash |
| 96 | +terraform import scaleway_rdb_snapshot.example fr-par/11111111-1111-1111-1111-111111111111 |
| 97 | +``` |
| 98 | + |
| 99 | +## Limitations |
| 100 | + |
| 101 | +- Snapshots are tied to the database instance and region where they are created. |
| 102 | +- Expired snapshots are automatically deleted and cannot be restored. |
| 103 | + |
| 104 | +## Notes |
| 105 | + |
| 106 | +- Ensure the `instance_id` corresponds to an existing database instance. |
| 107 | +- Use the `depends_on` argument when creating snapshots right after creating an instance to ensure proper dependency management. |
0 commit comments