Skip to navigationSkip to main contentSkip to footerScaleway Docs

Creating a database credentials secret type

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:

  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
Still need help?

Create a support ticket
No Results