Using paths to create hierarchies in Parameter Store

Josh Sherman
1 min read
Software Development AWS Node.js

Parameter Store only supports a limited number of character for the parameter name. As per the error message you’re presented with, Only a mix of letters, numbers and the following 3 symbols .-_ are allowed.

What that error fails to mention is that you can actually use a fourth symbol, the forward slash, /.

That particular special character also unlocks some additional functionality within AWS Parameter Store. When you utilize the / character, you are creating a path, similar to paths on a Linux or Unix-based operating system.

This allows you to do things like group parameters for different environments, or whatever sort of hierarchy you’d like to impose on your Parameter Store parameters:

/Dev/External/StripeAPIKey
/Staging/Data_Stores/Redis_Elasticache/Host
/Prod/Whatever/You/Want/To/Call/It

When you use the / you can still fetch the parameters with getParameter and getParameters but the real magic happens when you use getParametersByPath.

When getting parameters by their path, you can get all of the parameters at the depth of the path of your choosing:

import * as AWS from 'aws-sdk';

const ssm = new AWS.SSM();

const staging = await ssm.getParametersByPath({
	Path: '/Staging/',
	WithDecryption: true,
}).promise();

const stagingDataStores = await ssm.getParametersByPath({
	Path: '/Staging/Data_Stores/',
	WithDecryption: true,
}).promise();

const stagingDataStoreRedis = await ssm.getParametersByPath({
	Path: '/Staging/Data_Store/Redis_Elasticache',
	WithDecryption: true,
}).promise();
Join the Conversation

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

Currently Reading

Parasie Eve

Previous Reads

Buy Me a Coffee Become a Sponsor

Related Articles