@anvil-cloud/sdk
v0.0.16
Published
Anvil — secure-by-default cloud infrastructure components
Readme
@anvil-cloud/sdk
Cloud infrastructure that's secure by default — not by accident.
Anvil wraps raw cloud resources into opinionated, production-ready components. No 200-line Terraform modules. No copy-pasting security configs. Just declare what you need and Anvil handles the rest.
Built on Pulumi.
Install
npm install @anvil-cloud/sdkSecure 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 new 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 fromanvil.yamlctx.export(name, value)— export stack outputsctx.providers— named cloud providers for multi-region / multi-account
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:
export default new App({
run(ctx) {
const bucket = new anvil.aws.Bucket('uploads', {
dataClassification: 'sensitive',
});
const fn = new 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/*'] });
},
});What Anvil does under the hood:
- Creates an IAM
RolePolicyscoped 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:
export default new App({
run(ctx) {
const site = new anvil.aws.SvelteKitSite('web', {
domain: 'myapp.com',
});
ctx.export('url', site.url);
},
});Overrides
Every component accepts a transform argument to override the underlying resource config when you need to break from the defaults:
const bucket = new anvil.aws.Bucket('custom', {
dataClassification: 'non-sensitive',
transform: {
bucket: { forceDestroy: true, tags: { env: 'dev' } },
},
});Links
License
Apache-2.0
