Skip to main content

Validate, get validation patterns and generate valid AWS resource names, plus Pydantic v2 models mirroring the boto3 typed-dicts for every AWS service.

Project description

AWS Resource Validator

version PythonSupport GitHub License] github-star-badge issues

aws_resource_validator is a Python package that creates objects to validate, show constraints of common AWS resource names, and generate compatible patterns for tests. This helps ensure that AWS resource names comply with AWS naming rules and can be used for testing and validation purposes.

📜Documentation | Blogs website

Features

  • Validation: Check if a given AWS resource name meets the AWS naming constraints.
  • Constraint Display: Display constraints for different AWS resource names.
  • Pattern Generation: Generate compatible patterns for AWS resource names for testing purposes.

Installation

The core package ships the resource validator and the BaseValidatorModel runtime; per-service Pydantic models are shipped as extras so you only download what you need.

# Core only (validators, generators, BaseValidatorModel).
pip install aws-resource-validator

# One or more individual services.
pip install 'aws-resource-validator[s3,ec2,lambda]'

# A whole domain shard (installs every service in that shard).
pip install 'aws-resource-validator[data]'       # storage, databases, analytics
pip install 'aws-resource-validator[security]'   # IAM, KMS, WAF, ...
pip install 'aws-resource-validator[compute]'    # EC2, Lambda, ECS, EKS, ...
pip install 'aws-resource-validator[ai]'         # Bedrock, SageMaker, ...
pip install 'aws-resource-validator[networking]' # VPC, DNS, CDN, ...
pip install 'aws-resource-validator[integration]' # SNS, SQS, EventBridge, ...
pip install 'aws-resource-validator[management]' # CloudWatch, CloudFormation, ...
pip install 'aws-resource-validator[rest]'       # Media, IoT, gaming, long tail

# Everything.
pip install 'aws-resource-validator[all]'

# Regenerate models yourself (maintainers only).
pip install 'aws-resource-validator[generator]'

See docs/packaging.md for the full list of standalone service packages, shard membership, and the detailed install matrix.

Usage Example

Here's a simple example demonstrating how to use aws_resource_validator:

from aws_resource_validator.class_definitions import Acm, class_registry

# Use type hint so that you can use `api_registry` with full class definitions
acm: Acm = class_registry.Acm

print(acm.Arn.pattern)
print(acm.Arn.type)
print(acm.Arn.validate("example-arn"))
print(acm.Arn.generate())

Using Pydantic models for boto3 models:

import boto3

from aws_resource_validator.pydantic_models.dynamodb.dynamodb_classes import ListTablesOutput

dynamodb = boto3.client('dynamodb')

def list_dynamo_tables() -> List[str]:
    return ListTablesOutput(**dynamodb.list_tables()).TableNames


if __name__ == "__main__":
    tables: List[str] = list_dynamo_tables()
    print("DynamoDB Tables:", tables)

Contributing

We welcome contributions from everyone. Please see our CONTRIBUTING.md for more details.

Security

For information on reporting security vulnerabilities, please see our SECURITY.md.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

If you have any questions, feel free to reach out to us:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

aws_resource_validator-2.0.2-py3-none-any.whl (218.8 kB view details)

Uploaded Python 3

File details

Details for the file aws_resource_validator-2.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_resource_validator-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8b24aacf838023406287c72f15db7c488aa44dab9444cbe4a20c15b989ebc088
MD5 baee8792aa84fbf1693b2ee61fd166ff
BLAKE2b-256 3e83fd1151edff05beae291c444f0451e552f5c9e1fa19a3b0926d92ee655f56

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