pycfmodel
A python model for Cloud Formation scripts.
pycfmodel makes it easier to work with CloudFormation scripts in Python by creating a model comprised of python objects. Objects have various helper functions which help with performing common tasks related to parsing and inspecting CloudFormation scripts.
pip install pycfmodel
Currently Supported
- AWSTemplateFormatVersion
- Conditions
- Description
- Mappings
- Metadata
- Outputs
- Parameters
- Resources:
- Properties:
- Policy
- Policy Document
- Principal
- Security Group Egress Prop
- Security Group Ingress Prop
- Statement
- Tag
- EC2 VPC Endpoint Policy
- Generic Resource
- IAM Group
- IAM Managed Policy
- IAM Policy
- IAM Role
- IAM User
- KMS Key
- OpenSearch Service (legacy ElasticSearch resource)
- Elasticsearch Domain
- OpenSearch Service
- OpenSearchService Domain
- S3 Bucket
- S3 Bucket Policy
- Security Group
- Security Group Egress
- Security Group Ingress
- SNS Topic Policy
- SQS Queue Policy
- WAFv2 IP Set
- Properties:
- Transform
Example
from pycfmodel import parse
template = {
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {"StarParameter": {"Type": "String", "Default": "*", "Description": "Star Param"}},
"Resources": {
"rootRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {"AWS": {"Fn::Sub": "arn:aws:iam::${AWS::AccountId}:root"}},
"Action": ["sts:AssumeRole"],
}
],
},
"Path": "/",
"Policies": [
{
"PolicyName": "root",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": {"Ref": "StarParameter"},
"Resource": {"Ref": "StarParameter"},
}
],
},
}
],
},
}
},
}
model = parse(template).resolve(extra_params={"AWS::AccountId": "123"})
rootRole = model.Resources["rootRole"]
policy = rootRole.Properties.Policies[0]
statement = policy.PolicyDocument.Statement[0]
assert statement.Action == "*"
assert statement.Resource == "*"
assert rootRole.Properties.AssumeRolePolicyDocument.Statement[0].Principal == {"AWS": "arn:aws:iam::123:root"}
Local Development Commands
This project uses uv for dependency management.
make install-dev # Install all development dependencies
make coverage # Run tests with coverage
make test # Run linting and tests
make lock # Update uv.lock file
make lock-upgrade # Upgrade all dependencies and update uv.lock
Updating CloudFormation Actions
If the test tests/test_constants.py::test_cloudformation_actions is failing, it can be resolved by updating the known
AWS Actions:
make install-cloudformation-update
make cloudformation-update
Metadata
Release files for pycfmodel 2.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pycfmodel-2.1.5.tar.gz | 314.0 kB | Without provenance | Details for pycfmodel-2.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pycfmodel-2.1.5-py3-none-any.whl | Python 3 | none | any | Details for pycfmodel-2.1.5-py3-none-any.whl |
Total release size: 512.3 kB
Release files / pycfmodel-2.1.5.tar.gz
| Download URL | pycfmodel-2.1.5.tar.gz |
|---|---|
| Size | 314.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f145e3df3fdbe56a1244aa4179724e2088a111f31f2cc427b225e37f1fd22a69
|
|
BLAKE2b-256 checksum How to use checksums |
143d8e88972b3e370d35597a1fa4b748dc3cbbc3741590a9869fc3d1c69d3186
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pycfmodel-2.1.5-py3-none-any.whl
| Download URL | pycfmodel-2.1.5-py3-none-any.whl |
|---|---|
| Size | 198.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d54c327f463dec02b5f2b66d3d05842095bee09a69501b8f36a59888153072fb
|
|
BLAKE2b-256 checksum How to use checksums |
9577efa835d1cdf98c7fb3d633a937b4a0c0be0f151217fd1f4b042cebbc8d82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for pycfmodel 2.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.