Skip to main content

anvil-cloud

Cloud infrastructure that's secure by default — not by accident.

Anvil wraps raw cloud resources into opinionated, production-ready components. No boilerplate. No copy-pasting security configs. Just declare what you need.

Built on Pulumi.

Install

pip install anvil-cloud

Secure by default

Every Anvil component ships with defaults aligned to production from day one — public access blocked, encryption enforced, cost tags applied. The goal isn't to make compliance automatic, but to make it a platform you can actually build on.

The App class

Every Anvil program starts with anvil.App(). The run callback receives a Context with:

  • ctx.stage — current deployment stage (defaults to your OS username for dev isolation)
  • ctx.project — project name from anvil.yaml
  • ctx.export(name, value) — export stack outputs
  • ctx.providers — named cloud providers for multi-region / multi-account
  • ctx.ref(id) — reference a resource declared elsewhere (see below)

Forward references (ctx.ref)

Normally you reference a resource through the variable it's assigned to, which means it must be declared first. ctx.ref("id") lets you reference a resource by its logical name — even one declared later in the program:

def infra(ctx: anvil.Context):
    fn = anvil.aws.Lambda("processor",
        runtime=LambdaRuntime.NODEJS20_X,
        handler="index.handler",
        environment={
            # forward reference — `db` is declared below
            "DSQL_ENDPOINT": ctx.ref("db").endpoint,
        },
    )

    db = anvil.aws.DSQL("db", schemas=[...])

ctx.ref("db").endpoint resolves to the same output as db.endpoint — they're interchangeable.

This is an escape hatch for cases where declaration order is awkward; most code references resources directly. Two things to know:

  • Keep references flowing one direction. Because you can point either way, you can accidentally create a cycle (A references B's output and B references A's). That deadlocks the deploy rather than erroring cleanly — so don't do it.
  • A typo or never-declared id fails with a clear error before anything deploys.

Running locally: anvil deploy uses whatever python3 is on your PATH, so activate your project venv first (source .venv/bin/activate) or the program can't import pulumi.

Grants

Grants are how Anvil wires permissions between resources. Instead of writing IAM policies by hand, you call .grant() on a resource and Anvil handles both the IAM role policy and the environment variable injection automatically.

A Lambda reading from a Bucket:

import anvil_cloud as anvil

def infra(ctx: anvil.Context):
    bucket = anvil.aws.Bucket("uploads",
        data_classification="sensitive",
    )

    fn = anvil.aws.Lambda("processor",
        runtime="nodejs20.x",
        handler="index.handler",
        code="./src",
    )

    # Grants the Lambda read access to the bucket and scopes down to specific bucket paths.
    # Anvil creates the IAM policy and injects UPLOADS_BUCKET_NAME
    # into the Lambda's environment automatically.
    bucket.grant(fn, actions=["read"], path=["user/*"])

anvil.App(run=infra)

What Anvil does under the hood:

  • Creates an IAM RolePolicy scoped to the exact actions requested
  • Injects the resource identifier as an environment variable on the target (e.g. UPLOADS_BUCKET_NAME)
  • No manual ARN wiring, no forgotten permissions

SvelteKit deployment

Deploy a SvelteKit app to AWS with a single component. Anvil provisions S3, CloudFront, ACM, Lambda (via Lambda Web Adapter), and Route53 — with HTTPS and a custom domain out of the box:

import anvil_cloud as anvil

def infra(ctx: anvil.Context):
    site = anvil.aws.SvelteKitSite("web",
        path="web",  # the SvelteKit project folder — Anvil runs the build
        domain="myapp.com",
    )
    ctx.export("url", site.url)

anvil.App(run=infra)

Overrides

Every component accepts a transform argument to override the underlying resource config when you need to break from the defaults:

bucket = anvil.aws.Bucket("custom",
    data_classification="non-sensitive",
    transform=anvil.aws.BucketTransformArgsArgs(
        overrides=anvil.aws.BucketOverridesArgs(
            force_destroy=True,
            tags={"env": "dev"},
        ),
    ),
)

Requirements

  • Python >= 3.8
  • Pulumi >= 3.0.0
  • Anvil CLI: curl -fsSL https://raw.githubusercontent.com/anvil-cloud/anvil/master/install.sh | sh

License

Apache-2.0

Metadata

Release files for anvil-cloud 0.1.19

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

Source distribution (sdist)

Source distribution for anvil-cloud 0.1.19
File Size Uploaded
anvil_cloud-0.1.19.tar.gz 117.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anvil-cloud 0.1.19
File Interpreter ABI Platform
anvil_cloud-0.1.19-py3-none-any.whl Python 3 none any Details

Total release size: 260.4 kB

Release files / anvil_cloud-0.1.19.tar.gz

Download URL anvil_cloud-0.1.19.tar.gz
Size 117.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c3b1b3364fb44504c9bdc78be46de350410b2f8e5b57aa4c9517b12de542e2cf
BLAKE2b-256 checksum
How to use checksums
92ae8d21fe48f379f831bd83abeb87ec5071ab33ec35a84677e18beadeb5a4c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 13, 2026.

Transparency log

Release files / anvil_cloud-0.1.19-py3-none-any.whl

Download URL anvil_cloud-0.1.19-py3-none-any.whl
Size 142.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac3d84643f87bfa8af5f1cb3d7dd76c884e13a0a82e57b08bedc68eeced38d14
BLAKE2b-256 checksum
How to use checksums
b70bedc751ffe8097f6cc06cf05c576a7d0df2f319db867f3cd6c37dcb9bd83f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.19 This release

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.15

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

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