NavigationContentFooter
Suggest an edit

Creating a database credentials secret type

Reviewed on 28 August 2024Published on 05 April 2024

This documentation shows you how to create a database credentials secret type, with a version matching this type, using the Secret Manager API.

Before you start

To complete the actions presented below, you must have:

  • A Scaleway account logged into the console
  • Owner status or IAM permissions allowing you to perform actions in the intended Organization
  • A valid API key
  1. Open a terminal and run the following command to create your database credentials secret type. Make sure that you replace $SECRET_KEY and $SCW_PROJECT_ID with your own values.
    curl -q \
    -H "X-Auth-Token: $SECRET_KEY" \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
    "name": "my-secret",
    "project_id": "'$SCW_PROJECT_ID'",
    "type": "database_credentials"
    }' \
    https://api.scaleway.com/secret-manager/v1beta1/regions/fr-par/secrets
  2. Run the following command to encode the content of your secret version in bytes. Make sure that you add your own values.
    echo '{
    "engine": "mysql",
    "username": "username",
    "password": "my-super-secure-password",
    "host": "<instance host name/resolvable DNS name/IP address>",
    "dbname": "my-database",
    "port": "8080"
    }' | base64
    An output similar to the following should display:
    ewogICAgImVuZ2luZSI6ICJteXNxbCIsCiAgICAidXNlcm5hbWUiOiAidXNlcm5hbWUiLAogICAgInBhc3N3b3JkIjogIm15LXN1cGVyLXNlY3VyZS1wYXNzd29yZCIsCiAgICAiaG9zdCI6ICI8aW5zdGFuY2UgaG9zdCBuYW1lL3Jlc29sdmFibGUgRE5TIG5hbWU+IgogICAgImRibmFtZSI6ICJteS1kYXRhYmFzZSIsCiAgICAicG9ydCI6ICI4MDgwIgp9
  3. Run the following command to create a secret version matching your database_credentials secret type. Make sure that you add your own values and that you paste the output from the step above in the data field.
    curl -q \
    -H "X-Auth-Token: $SECRET_KEY" \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
    "data": "ewogICAgImVuZ2luZSI6ICJteXNxbCIsCiAgICAidXNlcm5hbWUiOiAidXNlcm5hbWUiLAogICAgInBhc3N3b3JkIjogIm15LXN1cGVyLXNlY3VyZS1wYXNzd29yZCIsCiAgICAiaG9zdCI6ICI8aW5zdGFuY2UgaG9zdCBuYW1lL3Jlc29sdmFibGUgRE5TIG5hbWU+IgogICAgImRibmFtZSI6ICJteS1kYXRhYmFzZSIsCiAgICAicG9ydCI6ICI4MDgwIgp9",
    "description": "my-secret-description",
    }' \
    https://api.scaleway.com/secret-manager/v1beta1/regions/fr-par/secrets/{secret_id}/versions
Tip

Find out about other secret types and the expected JSON format for them.

Was this page helpful?
API DocsScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCareers
© 2023-2024 – Scaleway