SSM client

This page contains some example usage for SSM. There are other resources that explain authentication and configuration.

The SSM package could be installed with Composer.

composer require async-aws/ssm

Usage

List parameters

use AsyncAws\Ssm\Input\GetParametersByPathRequest; use AsyncAws\Ssm\SsmClient; $ssm = new SsmClient(); $parameters = $ssm->getParametersByPath(new GetParametersByPathRequest([ 'Path' => '/projects/website', 'Recursive' => true, 'WithDecryption' => true, ])); $secrets = []; foreach ($parameters as $parameter) { $secrets[$parameter->getName()] = $parameter->getValue(); }

Store an encrypted parameter

use AsyncAws\Ssm\Enum\ParameterType; use AsyncAws\Ssm\Input\PutParameterRequest; use AsyncAws\Ssm\SsmClient; $ssm = new SsmClient(); $parameters = $ssm->putParameter(new PutParameterRequest([ 'Name' => '/projects/website/database_password', 'Value' => strtr(base64_encode(random_bytes(24)), '+/', '-_'), 'Type' => ParameterType::SECURE_STRING, // 'KeyId' => $customKmsKeyId, ]));