A Pythonic wrapper library for AWS SSM Parameter Store with enhanced error handling, existence testing, idempotent operations, and comprehensive tag management.
Project description
Welcome to simple_aws_ssm_parameter_store Documentation
simple_aws_ssm_parameter_store is a Pythonic wrapper library for AWS SSM Parameter Store that enhances the standard boto3 client with better error handling, existence testing, idempotent operations, and comprehensive tag management. Instead of dealing with exceptions for missing parameters or complex tag operations, this library provides intuitive functions that return meaningful values and handle edge cases gracefully.
Quick Tutorial
1. Parameter Existence Testing
Check if a parameter exists without handling exceptions. The function returns None for non-existent parameters instead of raising ParameterNotFound exceptions.
import boto3
from simple_aws_ssm_parameter_store.api import get_parameter
ssm_client = boto3.client("ssm")
# Test if parameter exists
param = get_parameter(ssm_client, "/app/database/host")
if param is not None:
print(f"Parameter exists with value: {param.value}")
else:
print("Parameter does not exist")
2. Idempotent Parameter Deletion
Delete parameters safely without worrying about whether they exist. The function returns True if deletion occurred, False if the parameter didn’t exist.
from simple_aws_ssm_parameter_store import delete_parameter
# Safe to call multiple times
deleted = delete_parameter(ssm_client, "/app/temp/config")
if deleted:
print("Parameter was deleted")
else:
print("Parameter didn't exist")
# Call again - no exception raised
deleted = delete_parameter(ssm_client, "/app/temp/config")
print(f"Second deletion attempt: {deleted}")
3. Comprehensive Tag Management
Manage parameter tags with intuitive functions for getting, updating, and replacing tags.
from simple_aws_ssm_parameter_store.api import (
get_parameter_tags,
update_parameter_tags,
put_parameter_tags,
remove_parameter_tags
)
# Get all tags (returns empty dict if no tags)
tags = get_parameter_tags(ssm_client, "/app/config")
print(f"Current tags: {tags}")
# Add/update specific tags (partial update)
update_parameter_tags(ssm_client, "/app/config", {
"Environment": "production",
"Team": "platform"
})
# Replace all tags (full replacement)
put_parameter_tags(ssm_client, "/app/config", {
"Environment": "production",
"Owner": "alice"
})
# Remove specific tags
remove_parameter_tags(ssm_client, "/app/config", ["Team"])
# Remove all tags
put_parameter_tags(ssm_client, "/app/config", {})
Expected output progression:
Current tags: {}
After update: {"Environment": "production", "Team": "platform"}
After replacement: {"Environment": "production", "Owner": "alice"}
After removal: {"Environment": "production", "Owner": "alice"}
After clearing: {}
4. Smart Parameter Updates (Version Management)
Avoid unnecessary parameter writes and preserve version history with conditional updates. AWS SSM only keeps the last 100 versions - blindly updating parameters during debugging or deployment can quickly exhaust this limit and make older versions inaccessible.
from simple_aws_ssm_parameter_store.api import put_parameter_if_changed
from simple_aws_ssm_parameter_store.constants import ParameterType
# Smart update - only writes if value actually changed
before, after = put_parameter_if_changed(
ssm_client=ssm_client,
name="/app/database/host",
value="prod-db.example.com",
type=ParameterType.STRING,
overwrite=True
)
# Check what happened
if before is None and after is not None:
print(f"Parameter created: version {after.version}")
elif before is not None and after is None:
print(f"No update needed - value unchanged (version {before.version})")
elif before is not None and after is not None:
print(f"Parameter updated: {before.version} → {after.version}")
Example debugging scenario - avoiding version waste:
# During debugging, you might run this script multiple times
# Without conditional updates, each run would increment the version
# ❌ Bad: Always increments version (wastes version history)
ssm_client.put_parameter(
Name="/app/config/debug",
Value="same-value",
Type="String",
Overwrite=True # This always creates new version
)
# ✅ Good: Only increments version when value actually changes
put_parameter_if_changed(
ssm_client=ssm_client,
name="/app/config/debug",
value="same-value",
type=ParameterType.STRING,
overwrite=True # Only used when value differs
)
Expected output progression:
# First run - parameter doesn't exist
Parameter created: version 1
# Second run - same value
No update needed - value unchanged (version 1)
# Third run - different value
Parameter updated: 1 → 2
# Fourth run - same value again
No update needed - value unchanged (version 2)
5. Working with Parameter Objects
Access parameter metadata through a rich Parameter object with convenient properties.
# Create a parameter first
ssm_client.put_parameter(
Name="/app/database/password",
Value="secret123",
Type="SecureString"
)
# Get parameter with decryption
param = get_parameter(ssm_client, "/app/database/password", with_decryption=True)
print(f"Name: {param.name}")
print(f"Value: {param.value}")
print(f"Type: {param.type}")
print(f"Version: {param.version}")
print(f"Is SecureString: {param.is_secure_string_type}")
print(f"ARN: {param.arn}")
Expected output:
Name: /app/database/password
Value: secret123
Type: SecureString
Version: 1
Is SecureString: True
ARN: arn:aws:ssm:us-east-1:123456789012:parameter/app/database/password
Install
simple_aws_ssm_parameter_store is released on PyPI, so all you need is to:
$ pip install simple-aws-ssm-parameter-store
To upgrade to latest version:
$ pip install --upgrade simple-aws-ssm-parameter-store
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_aws_ssm_parameter_store-0.2.3.tar.gz.
File metadata
- Download URL: simple_aws_ssm_parameter_store-0.2.3.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
232c876f462c843da0312eabd22785bbae2edcea2e057da91f803b88e893a211
|
|
| MD5 |
668a80108f3a6800da1896598f179a3b
|
|
| BLAKE2b-256 |
2a636f2ddf833bb95b4e19f662a827294e25e877833498d60be19c25967e4aac
|
File details
Details for the file simple_aws_ssm_parameter_store-0.2.3-py3-none-any.whl.
File metadata
- Download URL: simple_aws_ssm_parameter_store-0.2.3-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7caa62e8dd8f0019dce98f339ceca4058730c4a9822087467d2f327de370c181
|
|
| MD5 |
ca0a2e6571534ffcfe021311a27a80ed
|
|
| BLAKE2b-256 |
d5b5966f949f4e294e9ffaf5e3f57b02a4887376cf5b54fd09f27d1978a031cb
|