Docs

Extensions

An extension is Rust code you ship in your release that changes what Alien deploys. It can turn on a setting Alien doesn't expose, add a resource type Alien doesn't have, or change a call Alien makes to the cloud.

This one turns on IAM authentication for every Postgres cluster in the CloudFormation template Alien generates:

hooks/src/postgres_iam_auth.rs
use alien_extension_sdk::prelude::*;

pub struct CloudFormation;

impl CloudFormationModifier for CloudFormation {
    fn modify(&self, mut template: CfTemplate) -> Result<CfTemplate> {
        for cluster in template.resources_of_type_mut("AWS::RDS::DBCluster") {
            cluster.set_property("EnableIAMDatabaseAuthentication", true);
        }
        Ok(template)
    }
}

Your stack lists the extensions it uses:

alien.ts
import * as alien from "@alienplatform/core"
import acme from "./acme/generated" // written by alien extensions build

const db = new alien.Postgres("db").build()

export default new alien.Stack("my-app")
  .extensions([acme])
  .add(db, "frozen")
  .build()

What an extension changes

PartWhat it changesExample
Template modifierThe CloudFormation, Terraform, or Helm chart Alien generates for initial setupKeep Postgres backups for 30 days
InterceptorA call Alien's controllers make to the cloud or to Kubernetes, and its responseAdd your tags to the resources Alien's controllers create
Custom resourceAdds a resource type Alien doesn't have, with its own template parts, permissions, and controllerA DNS zone

Which part a setting needs depends on who creates the resource:

  • A frozen resource is created at initial setup, from the setup template, so it needs a template modifier.
  • A live resource is created by Alien's controllers, so it needs an interceptor. The setup CLI doesn't run interceptors, and refuses a release whose extensions ship them.

An extension that sets one value everywhere ships both, as the IAM database authentication example below does.

What your customer sees

Everything an extension adds to initial setup is in the setup template the customer's security team reviews.

  • A modifier can add resources and change their properties. It can't remove or hide a resource Alien emits, and the build fails if it tries.
  • A custom resource's permissions are part of the template. Alien makes its controller's calls as an identity of the extension's own, so the customer's cloud audit log shows them apart from Alien's.
  • Your release pins each extension by digest, and Alien checks the digest before it runs anything.

Security covers what an extension can reach.

Where extension code runs

Extension code is either a hook or a controller:

  • Hooks: modifiers, interceptors, emitters, importers, and links. They need no credentials and no network. They build to one WebAssembly module that runs sandboxed inside whichever Alien process needs it.
  • Controllers: the code that creates and updates a custom resource in the cloud. They build to a second WebAssembly module, which holds no credentials and opens no sockets. Alien signs each cloud call the module makes and sends it to the cloud's own API.

Both modules run sandboxed inside Alien, in the manager, the Operator, and the setup CLI. Only alien dev runs extension code outside the sandbox: a resource's local controller, as a process on your machine. Controllers shows whose credentials sign a controller's calls in each place.

Examples

Next

On this page