Less terrible way to build policy documents in Python?

Is there an equivalent to the TF aws_iam_policy_document to construct policy documents from objects? For example, I’d like to dynamically generate the principals block below from a list of account IDs.

If I make the below multiline policy text an f-string, I can then interpolate dynamic values, but then I have to double up every curly brace in the policy to escape them.

Surely there must be a better way?

                name + "-cross-account-access",
                    "Version": "2012-10-17",
                    "Statement": [
                        "Sid": "AllowRepositoryRead",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": [
                        "Action": [


I recommend GitHub - udondan/iam-floyd: AWS IAM policy statement generator with fluent interface which is useable with CDKTF with a small wrapper.