Skip to main content

Local AWS Mock for Python – Mock SSM Parameter Store and extendable AWS services

Project description

Local AWS Mock - Python Package (pyawsmock)

A lightweight Python package that mocks AWS services locally for development and testing. Currently, supports AWS Systems Manager (SSM) Parameter Store.

This package extends boto3 and automatically delegates calls to real AWS when the region is not a local mock region.

Key Features

  • Local vs AWS Delegation
    • Regions starting with local-* use the local mock store.
    • Other regions delegate calls directory to boto3 for real AWS services.
  • Persistent or Temporary Storage
    • Persistent Mode: Provide a directory path to store the configurations for local mock across sessions.
    • Temporary Mode: Uses a temporary directory (tempfile) and supports cleanup() to remove temporary data.
  • Versioning & Labels
    • Supports multiple versions per SSM parameter.
    • Mock implementation of labels per version.
    • Tracks modification history for audit purposes.
  • SecureString Support
    • Values are stored as base64 encoded strings.
    • Supports WithDecryption=True for retrieval.
  • Filters & Pagination
    • Supports filters (Type, KeyId, Label) for relevant SSM operations.
    • Handles MaxResults and NextToken for paginated responses.
  • Audit History
    • Tracks the IAM user/role performing operations (currently defaults to mock-user).
    • Timestamps modifications for audit purposes.
  • ARNs & Account IDs
    • Uses arn:mock instead of arn:aws to clearly differentiate local mock resources.
    • Default AWS Account ID is 000000000000 for all mock ARNs.

Current Limitations

  • Unsupported AWS Features
    • Config
    • CloudTrail
    • IAM (Users, Groups, Roles, Policies - permissions are not enforced)
    • Authentication
  • Default Assumptions
    • All operations assume a single mock IAM user (mock-user).
    • Regions are either local-* for mock or real AWS regions for delegation.

These limitations may be addressed in future versions.

Supported Services (Current)

Service Methods
SSM (Parameter Store) put_parameter, get_parameter, get_parameters, delete_parameter, label_parameter_version, unlabel_parameter_version, describe_parameters, get_parameters_by_path, get_parameter_history

Additional AWS services will be supported in future releases.

Installation

From PyPI

pip install pyawsmock

From GitHub

pip install git+https://github.com/coldsofttech/pyawsmock.git

Dependencies

  • boto3~=1.40.55
  • filelock~=3.20.0

boto3 is required to delegate calls to real AWS.

Usage Example

from pyawsmock import configure_mock, client, cleanup_mock

configure_mock(mode="persistent", path="./local_aws")  # Persistent storage example
configure_mock(mode="temporary")  # Temporary storage example

ssm = client("ssm", region_name="local-eu-west-1")  # eu-west-1 region local mock for SSM
ssm.put_parameter(
    Name="/test/key",
    Value="test_value",
    Type="String"
)

response = ssm.get_parameter(Name="/test/key")
print(response["Parameter"]["Value"])  # Output: test_value

cleanup_mock()  # Only applicable for 'temporary' mode

Future Plans

  • Extend to additional AWS services such as:
    • DynamoDB, S3, Lambda, CloudWatch, etc.
  • Improved IAM user/role matching and permission enforcement.
  • Enhanced logging, auditing, and multi-account support.
  • Full AWS API coverage for supported services.
  • Support for Config, CloudTrail, and authentication workflows.

License

MIT License

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

pyawsmock-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyawsmock-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pyawsmock-0.1.0.tar.gz.

File metadata

  • Download URL: pyawsmock-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for pyawsmock-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0e0ec6d6698eafc29242140bec13690d283eaf5d93b56bf567c6806bf41e403e
MD5 70400e46698b8ea910c7352069139aa9
BLAKE2b-256 71c3cbb02120c46d612f71dbd4a752ecc48a16e6982c2dcd9c86705dc7b4b192

See more details on using hashes here.

File details

Details for the file pyawsmock-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyawsmock-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for pyawsmock-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50f65f42d4dbc5550f4a873cd2176698cdbe01b1469db0732fa383a8b6dac023
MD5 62692f15991302d7d5b664a3f10df380
BLAKE2b-256 35ebc3514e203b7efd4986a03c39c33be9bcda7cbb128d5f308f20507f570ed3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page