terraform-state-in-typescript
TypeScript icon, indicating that this package has built-in type declarations

0.2.5 • Public • Published

terraform-state-in-typescript

Define your Terraform state in Typescript

Usage

  1. Write a Terraform definition in Typescript, using your custom building blocks.
// my-infrastructure.ts

import { composite, resource } from "terraform-state-in-typescript";

// Define your custom building blocks
const domain = (id: string, name: string) =>
  resource("aws_route53_zone", id, { name });

const storage = (id: string, name: string) =>
  resource("aws_s3_bucket", id, { name });

const cdn = (id: string, domain: string) =>
  resource("aws_cloudfront_distribution", id, { alias: [domain] });

const website = (id: string, address: string) =>
  composite(
    domain(id, address),
    storage(id, address),
    cdn(id, address)
  );

// Export your infrastructure
export default composite(
   website("my_primary_website", "example.com"),
   website("my_customer_portal", "example2.com"),
)

  1. Add a line to your package.json
// package.json

"scripts": {
    "build": "terraform-state-in-typescript ./src/my-infrastructure.ts ./my-infrastructure.tf",
    ...
  },
  1. Transpile your Typescript infrastructure to Terraform and execute
// command window
> yarn build
> terraform apply

Done! You have deployed two websites in the cloud!

Readme

Keywords

none

Package Sidebar

Install

npm i terraform-state-in-typescript

Weekly Downloads

0

Version

0.2.5

License

MIT

Unpacked Size

22.8 kB

Total Files

28

Last publish

Collaborators

  • glingt