This page describes how to add a parameter version. A parameter version stores the actual value of the parameter, whether it's a string, a number, or more complex data.
By creating parameter versions, you can do the following:
- Track changes to your parameter values over time.
- Rollback to previous values when required.
- Maintain an audit trail to see who made changes to the parameters and when.
Required roles
To get the permissions that
you need to add a parameter version,
ask your administrator to grant you the Parameter Manager Parameter Version Adder
( roles/parametermanager.parameterVersionAdder
)
IAM role on the parameter.
For more information about granting roles, see Manage access to projects, folders, and organizations
.
You might also be able to get the required permissions through custom roles or other predefined roles .
Add a parameter version
Parameter Manager lets you create multiple versions of a parameter. The version contains the actual data or value associated with the parameter. In the context of Parameter Manager, we'll call this data the parameter payload .
To add a new version, use one of the following methods:
Global parameters
Console
-
In the Google Cloud console, go to the Secret Manager page.
-
Click Parameter Manager to go to the Parameter Manager page. You'll see the list of parameters for that project.
-
Select the parameter for which you want to add the new version.
-
Click the Actions menu associated with that parameter, and then click Add new version . The Create parameter version page appears.
-
Enter the version name. Parameter version names must be 63 characters or less and consist only of alphanumeric characters (A-Z, a-z, 0-9), dashes (-), and underscores (_). Names cannot begin with a dash.
-
In the Payload section, enter a value for the parameter. Alternatively, you can upload a file containing the parameter value, and then edit the values in the payload editor. The parameter value must be in the format specified for the parameter.
-
Click Create .
gcloud
Before using any of the command data below, make the following replacements:
- PARAMETER_VERSION_ID : the ID that you want to assign to the parameter version. Parameter version IDs must be 63 characters or less and consist only of alphanumeric characters (A-Z, a-z, 0-9), dashes (-), and underscores (_). IDs cannot begin with a dash.
- PARAMETER_ID : the name of the parameter.
- PARAMETER_PAYLOAD : the data, in plaintext, that you want to store within the parameter.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud parametermanager parameters versions create PARAMETER_VERSION_ID --parameter = PARAMETER_ID --location = global --payload-data = " PARAMETER_PAYLOAD "
Windows (PowerShell)
gcloud parametermanager parameters versions create PARAMETER_VERSION_ID --parameter = PARAMETER_ID --location = global --payload-data = " PARAMETER_PAYLOAD "
Windows (cmd.exe)
gcloud parametermanager parameters versions create PARAMETER_VERSION_ID --parameter = PARAMETER_ID --location = global --payload-data = " PARAMETER_PAYLOAD "
You should receive a response similar to the following:
Created parameterVersion [set1].
REST
Encode the raw parameter data to Base64 format.
$ PARAMETER_PAYLOAD=$(echo "a: b" | base64 -w0)
Before using any of the request data, make the following replacements:
- PROJECT_ID : the Google Cloud project ID.
- PARAMETER_ID : the name of parameter.
- PARAMETER_VERSION_ID : the ID that you want to assign to the parameter version. Parameter version IDs must be 63 characters or less and consist only of alphanumeric characters (A-Z, a-z, 0-9), dashes (-), and underscores (_). IDs cannot begin with a dash.
- PARAMETER_PAYLOAD : the Base64 encoded string corresponding to the data that you want to store within the parameter.
HTTP method and URL:
POST https://parametermanager.googleapis.com/v1/projects/ PROJECT_ID /locations/global/parameters/ PARAMETER_ID /versions?parameter_version_id= PARAMETER_VERSION_ID
Request JSON body:
{"payload": {"data": " PARAMETER_PAYLOAD "}}
To send your request, choose one of these options:
curl
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://parametermanager.googleapis.com/v1/projects/ PROJECT_ID /locations/global/parameters/ PARAMETER_ID /versions?parameter_version_id= PARAMETER_VERSION_ID "
PowerShell
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://parametermanager.googleapis.com/v1/projects/ PROJECT_ID /locations/global/parameters/ PARAMETER_ID /versions?parameter_version_id= PARAMETER_VERSION_ID " | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/production-1/locations/global/parameters/intrusion_detection_rules/versions/set1", "createTime": "2024-11-12T10:26:44.168165094Z", "updateTime": "2024-11-12T10:26:44.168165094Z", "payload": { "data": "QSBzdHJpbmcgYmxvYiBjYW4gYmUgc3RvcmVkIGluIHRoZSB1bmZvcm1hdHRlZCBwYXJhbWV0ZXIu" } }
C#
To run this code, first set up a C# development environment and install the Parameter Manager C# SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
Go
To run this code, first set up a Go development environment and install the Parameter Manager Go SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
Java
To run this code, first set up a Java development environment and install the Parameter Manager Java SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
Node.js
To run this code, first set up a Node.js development environment and install the Parameter Manager Node.js SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
PHP
To run this code, first learn about using PHP on Google Cloud and install the Parameter Manager PHP SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
Python
To run this code, first set up a Python development environment and install the Parameter Manager Python SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
Ruby
To run this code, first set up a Ruby development environment and install the Parameter Manager Ruby SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
Regional parameters
Console
-
In the Google Cloud console, go to the Secret Manager page.
-
Click Parameter Manager to go to the Parameter Manager page. You'll see the list of parameters for that project.
-
Select the parameter for which you want to add the new version.
-
Click the Actions menu associated with that parameter, and then click Add new version . The Create parameter version page appears.
-
Enter the version name. Parameter version names must be 63 characters or less and consist only of alphanumeric characters (A-Z, a-z, 0-9), dashes (-), and underscores (_). Names cannot begin with a dash.
-
In the Payload section, enter a value for the parameter. Alternatively, you can upload a file containing the parameter value, and then edit the values in the payload editor. The parameter value must be in the format specified for the parameter.
-
Click Create .
gcloud
Before using any of the command data below, make the following replacements:
- PARAMETER_VERSION_ID : the ID that you want to assign to the parameter version. Parameter version IDs must be 63 characters or less and consist only of alphanumeric characters (A-Z, a-z, 0-9), dashes (-), and underscores (_). IDs cannot begin with a dash.
- PARAMETER_ID : the name of the parameter.
- LOCATION : the Google Cloud location of the parameter.
- PARAMETER_PAYLOAD : the data, in plaintext, that you want to store within the parameter.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud parametermanager parameters versions create PARAMETER_VERSION_ID --parameter = PARAMETER_ID --location = LOCATION --payload-data = " PARAMETER_PAYLOAD "
Windows (PowerShell)
gcloud parametermanager parameters versions create PARAMETER_VERSION_ID --parameter = PARAMETER_ID --location = LOCATION --payload-data = " PARAMETER_PAYLOAD "
Windows (cmd.exe)
gcloud parametermanager parameters versions create PARAMETER_VERSION_ID --parameter = PARAMETER_ID --location = LOCATION --payload-data = " PARAMETER_PAYLOAD "
You should receive a response similar to the following:
Created parameterVersion [set1].
REST
Encode the raw parameter data to Base64 format.
$ PARAMETER_PAYLOAD=$(echo "a: b" | base64 -w0)
Before using any of the request data, make the following replacements:
- LOCATION : the Google Cloud location of the parameter.
- PROJECT_ID : the Google Cloud project ID.
- PARAMETER_ID : the name of the parameter.
- PARAMETER_VERSION_ID : the ID that you want to assign to the parameter version. Parameter version IDs must be 63 characters or less and consist only of alphanumeric characters (A-Z, a-z, 0-9), dashes (-), and underscores (_). IDs cannot begin with a dash.
- PARAMETER_PAYLOAD : the Base64 encoded string corresponding to the data that you want to store within the parameter.
HTTP method and URL:
POST https://parametermanager. LOCATION .rep.googleapis.com/v1/projects/ PROJECT_ID /locations/ LOCATION /parameters/ PARAMETER_ID /versions?parameter_version_id= PARAMETER_VERSION_ID
Request JSON body:
{"payload": {"data": " PARAMETER_PAYLOAD "}}
To send your request, choose one of these options:
curl
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://parametermanager. LOCATION .rep.googleapis.com/v1/projects/ PROJECT_ID /locations/ LOCATION /parameters/ PARAMETER_ID /versions?parameter_version_id= PARAMETER_VERSION_ID "
PowerShell
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://parametermanager. LOCATION .rep.googleapis.com/v1/projects/ PROJECT_ID /locations/ LOCATION /parameters/ PARAMETER_ID /versions?parameter_version_id= PARAMETER_VERSION_ID " | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/production-1/locations/us-central1/parameters/intrusion_detection_rules/versions/set1", "createTime": "2024-10-30T05:27:51.206825427Z", "updateTime": "2024-10-30T05:27:51.206825427Z", "payload": { "data": "YTogYgo=" } }
C#
To run this code, first set up a C# development environment and install the Parameter Manager C# SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
Go
To run this code, first set up a Go development environment and install the Parameter Manager Go SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
Java
To run this code, first set up a Java development environment and install the Parameter Manager Java SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
Node.js
To run this code, first set up a Node.js development environment and install the Parameter Manager Node.js SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
PHP
To run this code, first learn about using PHP on Google Cloud and install the Parameter Manager PHP SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
Python
To run this code, first set up a Python development environment and install the Parameter Manager Python SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
Ruby
To run this code, first set up a Ruby development environment and install the Parameter Manager Ruby SDK . On Compute Engine or GKE, you must authenticate with the cloud-platform scope .
If you're using the gcloud CLI or the REST API, you can pass a payload file containing the parameter data directly in the create version command. Following is an example of uploading a payload file using the REST API:
Sample command
echo
"{\"payload\": { \"data\": \"
$(
cat
PAYLOAD_FILE
.yaml
|
base64
-w0 )
\"}}"
|
\
curl
-X
POST
\
-H
"Authorization: Bearer
$(
gcloud
auth
print-access-token )
"
\
-H
"Content-Type: application/json"
\
-d
@-
\
"https://parametermanager.googleapis.com/v1/projects/ PROJECT_ID
/locations/global/parameters/ PARAMETER_ID
/versions?parameter_version_id= PARAMETER_VERSION_ID
"
Replace the following:
- PAYLOAD_FILE : the payload file containing the parameter data.
- PROJECT_ID : the Google Cloud project ID.
- PARAMETER_ID : the name of the parameter.
- PARAMETER_VERSION_ID : the ID of the parameter version. Don't use latest (uppercase or lowercase) when naming your parameter version resources, because it's a reserved keyword. Reserved keywords have special meanings within the API and can't be used for other purposes.
Sample response
{
"name"
:
"projects/production-1/locations/global/parameters/db_connection_string_prod/versions/v1"
,
"createTime"
:
"2024-10-15T08:39:05.191747694Z"
,
"updateTime"
:
"2024-10-15T08:39:05.191747694Z"
}