From Terraform
Your Terraform describes one cloud account in detail: yours. In alien.ts you declare what the product needs, such as a database, a bucket, or a queue, and each customer's deployment gets its own in their AWS, Google Cloud, or Azure account.
This page is about Terraform you already use for your product. Customers can also run initial setup with a Terraform module that Alien generates; see Frozen and live.
From the repository with your Terraform:
Read the plan
Map the planned resources, with variables resolved. Never apply:
terraform plan -var-file prod.tfvars -out tf.plan
terraform show -json tf.plan > plan.jsonFor CDK, read cdk synth. For Pulumi, read pulumi preview --json.
An example
An RDS Postgres, an S3 bucket, an SQS queue, and a KMS key, used by one service:
import * as alien from "@alienplatform/core"
// Was aws_kms_key. The customer can hold it and revoke it.
const key = new alien.Key("data-key").build()
// Was aws_rds_cluster: Aurora on AWS, Cloud SQL or Flexible Server elsewhere.
const db = new alien.Postgres("db").encryptionKey(key).build()
// Was aws_s3_bucket.
const files = new alien.Storage("files").build()
// Was aws_sqs_queue.
const jobs = new alien.Queue("jobs").build()
// Was the ECS service. See From ECS.
const api = new alien.Container("api")
.code({ type: "image", image: "ghcr.io/acme/api:2.3.0" })
.cpu(1)
.memory("2Gi")
.port(8080)
.link(db)
.link(files)
.link(jobs)
.permissions("api")
.build()
export default new alien.Stack("acme")
.add(key, "frozen")
.add(db, "frozen")
.add(files, "frozen")
.add(jobs, "frozen")
.add(api, "live")
.permissions({
profiles: {
api: {
db: ["postgres/data-access"],
files: ["storage/data-read", "storage/data-write"],
jobs: ["queue/data-read", "queue/data-write"],
},
},
})
.build()The data stores are frozen: the customer's admin creates them once at initial setup, and later releases can't change or delete them. See Frozen and live.
Mapping
AWS names; Google Cloud and Azure resources map the same way.
| Terraform | alien.ts |
|---|---|
aws_rds_cluster, aws_db_instance (Postgres) | alien.Postgres |
aws_s3_bucket | alien.Storage |
aws_sqs_queue | alien.Queue. Its leases replace the visibility timeout; long jobs renew them. |
aws_dynamodb_table read by key or key prefix | alien.Kv |
aws_kms_key | alien.Key |
aws_secretsmanager_secret the product writes | alien.Vault |
aws_secretsmanager_secret set per customer | Inputs and secrets |
aws_elasticache_* | A stateful Container with the stock image, with one node |
aws_lambda_function | A Worker |
aws_ecs_* | Containers: see From ECS |
aws_eks_*, helm_release | Containers: see From a Helm chart |
aws_iam_role and policies for workloads | One permission profile per workload |
aws_vpc, subnets, NAT, security groups | Nothing: the customer's admin picks the network at initial setup. See Networking. |
aws_route53_record, aws_acm_certificate | Public endpoints, with custom domains chosen at initial setup |
aws_cloudwatch_* alarms and log groups | Nothing: Alien reports deployment status and collects logs |
| State buckets, CI roles | Nothing: they belong to your account |
Details to check
- Per-environment variables. Each value in
prod.tfvarsbecomes a constant, a value you set per deployment, or a choice the customer's admin makes. Most become constants. - DynamoDB queries.
Kvhas get, set, conditional writes, TTLs, and prefix scans. A table read through secondary indexes fits Postgres better. - MySQL, DocumentDB, OpenSearch. There's no managed resource for these. Run the stock image as a stateful Container.
- Cross-account roles. A role that lets your account reach into the customer's is the wrong direction. Deployments connect out to your backend. See Backend connections.
Next
- From ECS: the services your Terraform runs.
- Frozen and live: who may change each resource after initial setup.
- Infrastructure: every resource and what it becomes on each cloud.
From ECS
Move a product that runs on Amazon ECS onto Alien, and see where task definitions, load balancers, secrets, autoscaling, and task roles go.
Frozen and live
Choose, per resource, whether the customer's admin creates it once at initial setup or Alien manages it on every release, and what each costs in permissions.