-
Notifications
You must be signed in to change notification settings - Fork 133
Labels
documentationpriority:highestBugs filled by customers, security issuesBugs filled by customers, security issuesrdbManaged MySQL and PostgreSQL issues, bugs and feature requestsManaged MySQL and PostgreSQL issues, bugs and feature requests
Description
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform Version
OpenTofu v1.9.0
on linux_amd64
Affected Resource(s)
- scaleway_rdb_instance
- scaleway_rdb_snapshot
Terraform Configuration Files
From discussion in Scaleway ticket 1489943:
The below configuration file works, although not documented:
data "external" "test_db_snapshots" {
program = ["${path.module}/external/scaleway_rdb_snapshot.sh"]
query = {
region = local.scw_region
project_id = data.scaleway_account_project.default.id
rdb_instance_name = "test-db"
datefmt = "1 hour ago"
}
}
resource "scaleway_rdb_instance" "test_db" {
name = "test-db"
node_type = "db-play2-pico"
volume_type = "sbs_15k"
volume_size_in_gb = 10
is_ha_cluster = false
disable_backup = false
backup_schedule_frequency = 1 # every hour
backup_schedule_retention = 30
backup_same_region = false
user_name = "fancyuser"
password = "verysecurepassword"
encryption_at_rest = true
snapshot_id = data.external.test_db_snapshots.result.id
}In contrast to trying as documented:
resource "scaleway_rdb_snapshot" "test_db_autobackup" {
name = "test-db_autobackup"
instance_id = scaleway_rdb_instance.test_db.id
snapshot_id = data.external.test_db_snapshots.result.id
}which gives
$ tofu plan
╷
│ Error: Unsupported argument
│
│ on database.tf line 66, in resource "scaleway_rdb_snapshot" "test_db_autobackup":
│ 66: snapshot_id = data.external.test_db_snapshots.result.id
│
│ An argument named "snapshot_id" is not expected here.
╵The shell script used in the external-block for reference
#! /bin/sh
set -e
region=""
project_id=""
rdb_instance_name=""
datefmt=""
eval "$(jq --raw-output '@sh "region=\(.region) project_id=\(.project_id) rdb_instance_name=\(.rdb_instance_name) datefmt=\(.datefmt)"')"
total_count=""
collected=""
page=1
while true; do
eval "$(
curl -s \
-X GET \
-H "X-Auth-Token: ${SCW_SECRET_KEY}" \
"https://api.scaleway.com/rdb/v1/regions/${region}/snapshots?project_id=${project_id}&page=${page}" |
jq --raw-output '@sh "total_count=\(.total_count) snapshots_count=\(.snapshots | length) snapshots=\(.snapshots | tostring)"'
)"
collected=$((collected + snapshots_count))
page=$((page + 1))
echo "${snapshots}"
[ "${collected}" -ge "${total_count}" ] && break
done |
jq \
--raw-output \
--slurp \
--arg datefmt "$(date --date="${datefmt}" --utc +%s)" \
--arg region "${region}" \
--arg rdb_instance_name "${rdb_instance_name}" \
'
flatten
| map(select(.instance_name == $rdb_instance_name))
| map({
offset: (
(.created_at | sub("\\.\\d+"; "") | fromdateiso8601)
-
($datefmt | tonumber)
) | abs,
id: "\($region)/\(.id)",
name: .name
})
| sort_by(.offset)
| map({id: .id})
| first
'Expected Behavior
The documentation should describe the actual implementation - either by fixing the implementation or updating the documentation.
Actual Behavior
The snapshot_id parameter is documented in the wrong resource.
Steps to Reproduce
terraform plan
References
- Actual implementation of the
snapshot_idparameter in thescaleway_rdb_instanceresource:"snapshot_id": { - Bad documentation in the
scaleway_rdb_snapshotresource: https://github.com/scaleway/terraform-provider-scaleway/blob/c4b3921a374833fdce282a2fdc6798df154290db/docs/resources/rdb_snapshot.md#argument-reference - Missing documentation in the
scaleway_rdb_instanceresource: https://github.com/scaleway/terraform-provider-scaleway/blob/c4b3921a374833fdce282a2fdc6798df154290db/docs/resources/rdb_instance.md#backups - Scaleway ticket 1489943
Metadata
Metadata
Assignees
Labels
documentationpriority:highestBugs filled by customers, security issuesBugs filled by customers, security issuesrdbManaged MySQL and PostgreSQL issues, bugs and feature requestsManaged MySQL and PostgreSQL issues, bugs and feature requests