Skip to main content

Service Control Policy (SCP) preprocessor

A command line tool that takes a single JSON file and outputs a collection of valid service control policies. This allows you to organize your SCPs logically and write statements in a way that makes sense to you without directly worrying about size constraints. The tool will then handle optimization and bin packing of your single JSON file into a collection of SCPs that fit the size limits. The tool also introduces some new SCP language concepts that are explained below.

The resultant SCPs are written to std out as an array of SCPs.

Getting Started

Installation:

Python 3.6+ is supported.

pip install service-control-policy-preprocessor

Basic usage:

scp-pre process file://my-single-scp > output.json

Available Commands

process

scp-pre process file://my-single-scp.json
Arguments Description
--enable-logging Enables log output to stdout. Turn off if you want to use the SCP output which is also output to stdout.
--retain-sid Retain the SID element of the policy in the SCP output
--basic Basic transformation. Skips the wildcarding of IAM actions that outputs the shortest possible action prefix to save space.
--pretty-print Keep whitespace to make output readable. Useful for debugging.

New language constructs for IAM actions

Exclude a particular action from the resulting action list

Must be an exact action name, does not support globbing. Useful when there are only a few exemptions.

Example:

{
  ...
  "Action": [
    "iam:*User*",
    "iam:{Exclude:ListUsers}"
  ]
}

Resulting SCP will contain all actions matching iam:*User* except for iam:ListUsers.

Adds support for wildcards in all parts of IAM action name

Example:

{
  ...
  "Action": [
    "service:*PartOfActionName*"
  ]
}

Regular SCP syntax only supports wildcards at the end of the action name. The resulting SCP will have all actions that match this wildcard pattern expanded.

Adds support for comment element in SCPs

Example:

{
  ...
  "Action": [
    "service:Action"
  ],
  "Comment": "This will be stripped off before deployment, but can be helpful when left in a source repository."
}

Comments are stripped during preproccessing. This is a helpful place to store a short explanation of the policy statement.

Transformations that are done to your SCP (in order)

  1. SIDs and Comments are removed from all statements
  2. Wildcards are expanded
  3. Actions are excluded if using the {Exclude} syntax
  4. Statements with the same Effect, Resource, and Condition are merged together
  5. Actions are wildcarded to save space. This can be disabled with the --basic flag.
    1. Example: iam:SetSecurityTokenServicePreferences -> iam:SetS*
    2. You will want to run this transformation periodically (e.g. daily) if you use this feature. This is because new IAM actions are added over time that the transformation has not taken into account when shortening these action names.
  6. Statements are bin packed to fit SCP size quotas

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

Metadata

Release files for service-control-policy-preprocessor 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for service-control-policy-preprocessor 0.0.2
File Size Uploaded
service_control_policy_preprocessor-0.0.2.tar.gz 12.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for service-control-policy-preprocessor 0.0.2
File Interpreter ABI Platform
service_control_policy_preprocessor-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.1 kB

Release files / service_control_policy_preprocessor-0.0.2.tar.gz

Download URL service_control_policy_preprocessor-0.0.2.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6e4ca1527d96a7c63167dd3dad28fe8aaed068f9c73e8bc9ecc93b90d30f25c9
BLAKE2b-256 checksum
How to use checksums
071e94f49fd1dba8b10a09bd6d4589e31543747f2067b58d645a1971f86d4f19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2025.

Transparency log

Release files / service_control_policy_preprocessor-0.0.2-py3-none-any.whl

Download URL service_control_policy_preprocessor-0.0.2-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5fa082334cb7ff59cfec39d8252cb3b87b2004c3eaeaff98b7d39d5d9405b32
BLAKE2b-256 checksum
How to use checksums
44e1310dd9ff0c3e28e2af8cae2c2f6fc5cab09a50591b3116f3ed8eb77f7e7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page