AWS Parameter Store
The AWS Parameter Store persists encryption keys as SecureString parameters in AWS Systems Manager Parameter Store, encrypted with AWS KMS. It is the recommended choice for applications running on AWS that want native integration with IAM and KMS.
Installation
dotnet add package Tayra.KeyStore.AwsParameterStoreInstall-Package Tayra.KeyStore.AwsParameterStoreBasic Setup
The simplest registration uses the default AWS credentials chain (environment variables, instance profile, IAM role, etc.):
var services = new ServiceCollection();
// Use AWS Systems Manager Parameter Store
// with the default AWS credentials chain
services.AddTayra(opts => opts.LicenseKey = licenseKey)
.UseAwsKeyStore();Configuration Options
Use the options overload to customize the path prefix, KMS key, region, and retry behavior:
var services = new ServiceCollection();
services.AddTayra(opts => opts.LicenseKey = licenseKey)
.UseAwsKeyStore(options =>
{
// Path prefix for parameters (default: "/tayra/")
// Must start and end with '/'
options.PathPrefix = "/myapp/encryption/keys/";
// Optional custom KMS key ID or alias for encrypting SecureString parameters
// When null, the default AWS-managed key (alias/aws/ssm) is used
options.KmsKeyId = "alias/my-custom-key";
// Optional AWS region override (default: from credentials chain)
options.Region = "us-west-2";
// Maximum number of retries for transient errors (default: 3)
options.MaxRetries = 5;
// Base delay for exponential backoff on retries (default: 100ms)
options.RetryBaseDelay = TimeSpan.FromMilliseconds(200);
});Options Reference
| Property | Type | Default | Description |
|---|---|---|---|
PathPrefix | string | "/tayra/" | Path prefix for parameters. Must start and end with /. |
KmsKeyId | string? | null | Optional custom KMS key ID or alias for encrypting SecureString parameters. When null, the default AWS-managed key (alias/aws/ssm) is used. |
Region | string? | null | Optional AWS region override. When null, the region from the default credentials chain is used. |
MaxRetries | int | 3 | Maximum number of retries for transient errors. |
RetryBaseDelay | TimeSpan | 100ms | Base delay for exponential backoff on retries. |
Pre-configured SSM Client
If you already have an IAmazonSimpleSystemsManagement client configured (e.g., with assumed-role credentials), pass it directly:
var services = new ServiceCollection();
var ssmClient = new Amazon.SimpleSystemsManagement.AmazonSimpleSystemsManagementClient(
Amazon.RegionEndpoint.USWest2);
services.AddTayra(opts => opts.LicenseKey = licenseKey)
.UseAwsKeyStore(ssmClient, options =>
{
options.PathPrefix = "/myapp/encryption/keys/";
});PathPrefix Convention
Tayra stores each encryption key as a SecureString parameter. The full parameter name is constructed as:
{path_prefix}{sanitized_key_id}| Component | Value | Source |
|---|---|---|
path_prefix | /tayra/ | PathPrefix option (default: "/tayra/"). Automatically normalized to start and end with /. |
sanitized_key_id | user-123/personal/name | The Tayra key identifier with colons (:) converted to path separators (/) for hierarchical organization. |
For example, with the default prefix /tayra/ and a key ID of user-123:personal:name, the parameter name is:
/tayra/user-123/personal/nameThis hierarchical structure enables:
- Browsing keys by subject in the AWS Console
- Using IAM policies scoped to specific path prefixes
- Efficient prefix-based operations (
DeleteByPrefixAsync,ListKeyIdsAsync)
Organize by Environment
Use path prefixes to separate keys across environments:
options.PathPrefix = "/tayra/production/keys/"; // Production
options.PathPrefix = "/tayra/staging/keys/"; // StagingKMS Key for Encryption
Parameter Store SecureString parameters are encrypted at rest using AWS KMS. You can control which KMS key is used:
- Default (null) -- Uses the AWS-managed key
alias/aws/ssm. This is free and suitable for most use cases. - Custom KMS key -- Specify a key ID, key ARN, alias name, or alias ARN. Use this when you need customer-managed key controls, key rotation policies, or cross-account access.
options.KmsKeyId = "alias/my-custom-key";
// or
options.KmsKeyId = "arn:aws:kms:us-west-2:123456789012:key/12345678-1234-1234-1234-123456789012";IAM Policy Requirements
The IAM role or user must have the following permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:PutParameter",
"ssm:GetParameter",
"ssm:DeleteParameter",
"ssm:DeleteParameters",
"ssm:GetParametersByPath",
"ssm:DescribeParameters"
],
"Resource": "arn:aws:ssm:*:*:parameter/tayra/*"
},
{
"Effect": "Allow",
"Action": [
"kms:Decrypt",
"kms:Encrypt",
"kms:GenerateDataKey"
],
"Resource": "arn:aws:kms:*:*:key/*",
"Condition": {
"StringEquals": {
"kms:ViaService": "ssm.*.amazonaws.com"
}
}
}
]
}Least Privilege
Scope the Resource ARN to match your PathPrefix. The example above uses /tayra/keys/* which matches the default prefix. If you change PathPrefix, update the policy accordingly.
Retry Logic
The AWS Parameter Store key store includes built-in retry logic with exponential backoff for transient errors. The backoff delay doubles on each attempt: for the default settings (base delay = 100ms, max retries = 3), the delays are approximately 100ms, 200ms, and 400ms.
This is in addition to any retry policy configured on the AmazonSimpleSystemsManagementClient itself.
Parameter Store Limits
Be aware of AWS Parameter Store service limits:
| Limit | Value | Notes |
|---|---|---|
| Max parameters per account per region | 10,000 (standard) | Can be increased to 100,000 via AWS Support |
| Max parameter name length | 2,048 characters | Including the path prefix |
| Max parameter value size | 4 KB (standard) | AES-256 keys are 32 bytes, well within this limit |
| GetParameter TPS | 1,000 | Shared across all parameters in the account |
For applications with a very large number of data subjects, consider whether these limits are sufficient or whether a different key store (PostgreSQL, Vault) would be more appropriate.
See Also
- Key Stores Overview -- Comparison of all providers
- Azure Key Vault -- Cloud-native alternative for Azure
- HashiCorp Vault -- Multi-cloud secrets management
- Custom Key Store -- Build your own
IKeyStore
