HomeSecurity & IdentitySecret ManagerAPI/CLI
Migrating secrets into folders using the CLI and Go
Update content

Migrating secrets into folders using the CLI and Go

Reviewed on 21 November 2023Published on 25 September 2023

This documentation shows you how to migrate your secrets into folders using the Scaleway CLI and the Go programming language. We have created a GitHub repository containing the necessary code to create the folder to which you will migrate your secrets using their IDs.

Security & Identity (IAM):

You may need certain IAM permissions to carry out some actions described on this page. This means:

  • you are the Owner of the Scaleway Organization in which the actions will be carried out, or
  • you are an IAM user of the Organization, with a policy granting you the necessary permission sets
Requirements:
  1. Open a terminal and run the following command to clone the repository containing the code you need to create a folder and migrate your secrets:

    git clone git@github.com:scaleway/tutorial-sem-migration.git
  2. In the same terminal, paste the following commands to export your environment variables. Make sure you add your own variables.

    export SCW_ACCESS_KEY=<Scaleway access key>
    export SCW_SECRET_KEY=<Scaleway secret key>
    export SCW_DEFAULT_ORGANIZATION_ID=<Scaleway default Organization>
    export SCW_DEFAULT_PROJECT_ID=<Scaleway default Project>
    export SCW_DEFAULT_REGION="fr-par"
    export SCW_API_URL="https://api.scaleway.com"
  3. Use the following command to access the tutorial-sem-migration directory:

    cd tutorial-sem-migration
  4. Open a text editor of your choice and open the main.go file inside the tutorial-sem-migration directory.

  5. Replace my-folder, lines 24, 27, and 34 with the name of your folder.

    Important:

    Your folder name can only contain alphanumeric characters, dots, underscores, and dashes.

  6. Replace xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx lines 18, 19 and 20 with the IDs of the secrets you want to migrate. You can find your secrets’ IDs in the secret’s Overview tab.

    Note:

    You can add as many IDs as you need to fit the amount of secrets you want to migrate into your folder.

  7. Save your changes in the main.go file.

  8. Run go run ./main.go to launch the migration.

  9. Optionally, follow the same procedure if you need to migrate other secrets into other folders.