Creating a Parameter Store parameter using the AWS CLI
You can use the AWS Command Line Interface (AWS CLI) to create String,
StringList, and SecureString
parameter types. After deleting a parameter, wait for at least 30 seconds to
create a parameter with the same name.
Parameters can't be referenced or nested in the values of other parameters. You
can't include {{}} or
{{ssm: in a parameter
value.parameter-name}}
Note
Parameters are only available in the AWS Region where they were created.
Topics
Creating a String parameter using the AWS CLI
Install and configure the AWS Command Line Interface (AWS CLI), if you haven't already.
For information, see Installing or updating the latest version of the AWS CLI.
-
Run the following command to create a
String-type parameter. Replace eachexample resource placeholderwith your own information.-or-
Run the following command to create a parameter that contains an Amazon Machine Image (AMI) ID as the parameter value.
The
--nameoption supports hierarchies. For information about hierarchies, see Working with parameter hierarchies in Parameter Store.The
--data-typeoption must be specified only if you are creating a parameter that contains an AMI ID. It validates that the parameter value you enter is a properly formatted Amazon Elastic Compute Cloud (Amazon EC2) AMI ID. For all other parameters, the default data type istextand it's optional to specify a value. For more information, see Using native parameter support in Parameter Store for Amazon Machine Image IDs.Important
If successful, the command returns the version number of the parameter. Exception: If you have specified
aws:ec2:imageas the data type, a new version number in the response doesn't mean that the parameter value has been validated yet. For more information, see Using native parameter support in Parameter Store for Amazon Machine Image IDs.The following example adds two key-value pair tags to a parameter.
The following example uses a parameter hierarchy in the name to create a plaintext
Stringparameter. It returns the version number of the parameter. For more information about parameter hierarchies, see Working with parameter hierarchies in Parameter Store. -
Run the following command to view the latest parameter value and verify the details of your new parameter.
aws ssm get-parameters --names "/Test/IAD/helloWorld"The system returns information like the following.
{ "InvalidParameters": [], "Parameters": [ { "Name": "/Test/IAD/helloWorld", "Type": "String", "Value": "My updated parameter value", "Version": 2, "LastModifiedDate": "2020-02-25T15:55:33.677000-08:00", "ARN": "arn:aws:ssm:us-east-2:123456789012:parameter/Test/IAD/helloWorld" } ] }
Run the following command to change the parameter value. It returns the version number of the parameter.
aws ssm put-parameter --name "/Test/IAD/helloWorld" --value "My updated 1st parameter" --type String --overwrite
Run the following command to view the parameter value history.
aws ssm get-parameter-history --name "/Test/IAD/helloWorld"
Run the following command to use this parameter in a command.
aws ssm send-command --document-name "AWS-RunShellScript" --parameters '{"commands":["echo {{ssm:/Test/IAD/helloWorld}}"]}' --targets "Key=instanceids,Values=instance-ids"
Run the following command if you only want to retrieve the parameter Value.
aws ssm get-parameter --name testDataTypeParameter --query "Parameter.Value"
Run the following command if you only want to retrieve the parameter Value
using get-parameters.
aws ssm get-parameters --names "testDataTypeParameter" --query "Parameters[*].Value"
Run the following command to view the parameter metadata.
aws ssm describe-parameters --filters "Key=Name,Values=/Test/IAD/helloWorld"
Note
Name must be capitalized.
The system returns information like the following.
{ "Parameters": [ { "Name": "helloworld", "Type": "String", "LastModifiedUser": "arn:aws:iam::123456789012:user/JohnDoe", "LastModifiedDate": 1494529763.156, "Version": 1, "Tier": "Standard", "Policies": [] } ] }
Creating a StringList parameter using the AWS CLI
Install and configure the AWS Command Line Interface (AWS CLI), if you haven't already.
For information, see Installing or updating the latest version of the AWS CLI.
-
Run the following command to create a parameter. Replace each
example resource placeholderwith your own information.Note
If successful, the command returns the version number of the parameter.
This example adds two key-value pair tags to a parameter. (Depending on the operating system type on your local machine, run one of the following commands. The version to run from a local Windows machine includes the escape characters ("\") that you need to run the command from your command line tool.)
Here is a
StringListexample that uses a parameter hierarchy.Note
Items in a
StringListmust be separated by a comma (,). You can't use other punctuation or special characters to escape items in the list. If you have a parameter value that requires a comma, then use theStringtype. -
Run the
get-parameterscommand to verify the details of the parameter. For example:aws ssm get-parameters --name "/IAD/ERP/Oracle/addUsers"
Creating a SecureString parameter using the AWS CLI
Use the following procedure to create a SecureString
parameter. Replace each example resource
placeholder with your own information.
Only the value of a SecureString parameter is
encrypted. Parameter names, descriptions, and other properties aren't
encrypted.
Important
Parameter Store only supports symmetric encryption KMS keys. You can't use an asymmetric encryption KMS key to encrypt your parameters. For help determining whether a KMS key is symmetric or asymmetric, see Identifying symmetric and asymmetric KMS keys in the AWS Key Management Service Developer Guide
Install and configure the AWS Command Line Interface (AWS CLI), if you haven't already.
For information, see Installing or updating the latest version of the AWS CLI.
-
Run one of the following commands to create a parameter that uses the
SecureStringdata type.