Setting/Getting SSM Values in AWS with the CLI

Amazon Web Services (AWS) offers a service called Systems Manager Parameter Store (often called SSM Parameter Store). This service allows you to securely store and manage important configuration data, like passwords, database strings, or whatever else you want to store to configure your applications.

Here's a simple guide on how to set values in the SSM Parameter Store using the AWS Command Line Interface (CLI).

Prerequisites

Before we start, ensure you have:

  • AWS CLI installed.
  • Configured the AWS CLI with the necessary credentials (aws configure).
  • IAM permissions to put parameters in SSM.

Setting a Parameter

The basic command to add (or update) a value in the Parameter Store is:

aws ssm put-parameter --name "YourParameterName" --value "YourParameterValue" --type "String"

Replace YourParameterName with the name you want to give the parameter and YourParameterValue with the actual value you want to store.

Parameter Types

The --type option can take three values:

  • String: For plain text values.
  • StringList: For a series of string values separated by commas.
  • SecureString: For sensitive data that needs to be encrypted.

For example, if you have a password to store securely, you might use:

aws ssm put-parameter --name "DatabasePassword" --value "YourSecretPassword" --type "SecureString"

Overwriting Existing Parameters

If a parameter with the same name already exists and you want to overwrite it, add the --overwrite flag:

aws ssm put-parameter --name "YourParameterName" --value "NewParameterValue" --type "String" --overwrite

Retrieving the Parameter

To check that you've set the parameter correctly, you can retrieve it using:

aws ssm get-parameter --name "YourParameterName"

If it's a SecureString, and you want to see the decrypted value, add --with-decryption:

aws ssm get-parameter --name "DatabasePassword" --with-decryption

Happy coding! 🌀

Aws
Avatar for Niall Maher

Written by Niall Maher

Founder of Codú - The web developer community! I've worked in nearly every corner of technology businesses; Lead Developer, Software Architect, Product Manager, CTO and now happily a Founder.

Loading

Fetching comments

Hey! 👋

Got something to say?

or to leave a comment.