aws_utils_ssm
AWS SSM utilities for getting parameter values from AWS Systems Manager Parameter Store.
Features
- Simple interface for retrieving SSM parameters
- Support for encrypted parameters with automatic decryption
- Custom error handling with detailed error types
- Support for custom AWS endpoints (useful for testing with LocalStack)
- Automatic fallback to dummy credentials for testing environments
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage
Basic Example
use ;
async
Using Custom Endpoint
use ;
async
Getting Raw Parameter Output
use ;
async
API Reference
Functions
make_client(endpoint_url: Option<String>) -> Client
Creates an AWS SSM client with optional custom endpoint URL.
endpoint_url: Optional custom endpoint URL for testing (e.g., LocalStack)- Returns: Configured AWS SSM Client
get_parameter(client: &Client, name: &str) -> Result<String, Error>
Retrieves a parameter value as a string with automatic decryption.
client: AWS SSM clientname: Parameter name (e.g., "/my/parameter/name")- Returns: Parameter value as String
get_parameter_raw(client: &Client, name: Option<impl Into<String>>, with_decryption: Option<bool>) -> Result<GetParameterOutput, Error>
Retrieves raw parameter output from AWS SSM.
client: AWS SSM clientname: Optional parameter namewith_decryption: Whether to decrypt the parameter value- Returns: Raw GetParameterOutput from AWS SDK
Error Types
The crate defines custom error types:
Error::BuildError: AWS SDK build errorsError::AwsSdk: AWS SDK service errorsError::ValidationError: Validation errorsError::NotFound: Parameter not found
Testing
The crate includes tests that require specific environment variables:
# Required for tests to run
# Optional: Custom SSM endpoint (e.g., LocalStack)
# Optional: Test parameter name (defaults to "/test/parameter")
# Run tests
Test Commands
# Run all tests
# Run with logging
RUST_LOG=info
# Run specific test
Environment Variables
The crate automatically sets dummy AWS credentials if they're not present:
AWS_ACCESS_KEY_ID: Set to "dummy_access_key" if not presentAWS_SECRET_ACCESS_KEY: Set to "dummy_secret_key" if not presentAWS_REGION: Set to "us-west-2" if not present
This makes it easy to use in testing environments without requiring real AWS credentials.
License
MIT