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:
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:
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
| Part | What it changes | Example |
|---|---|---|
| Template modifier | The CloudFormation, Terraform, or Helm chart Alien generates for initial setup | Keep Postgres backups for 30 days |
| Interceptor | A call Alien's controllers make to the cloud or to Kubernetes, and its response | Add your tags to the resources Alien's controllers create |
| Custom resource | Adds a resource type Alien doesn't have, with its own template parts, permissions, and controller | A 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
IAM database authentication
Template modifiers and interceptors that turn on IAM authentication for the Postgres database on AWS, Google Cloud, and Azure.
Longer backups
A CloudFormation and Terraform modifier that keeps the Postgres cluster's backups for 30 days.
Your own tags
An interceptor that adds your tags to the resources Alien's controllers create.
Budget alert
A small custom resource with CloudFormation and Terraform parts and no controller.
DNS zone
A custom resource with template parts, importers, permission sets, and controllers on AWS, Google Cloud, and Azure.
Next
- Quickstart: write a modifier, see it in the setup template, and release it
- Template modifiers: change what initial setup creates
- Custom resources: add a resource type Alien doesn't have