Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions backend/src/terraform/awsSubnet.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {jsonRoot} from "./util";
import {Resource} from "./resource";
import {awsZone, char} from "../types/terraform";

export interface AwsSubnet {
vpc: string;
cidr_block: string;
map_public_ip_on_launch: boolean;
availability_zone: string;
availability_zone: `${awsZone}${char}`;
}

export class AwsSubnet extends Resource<AwsSubnet> implements AwsSubnet {
Expand All @@ -14,7 +15,7 @@ export class AwsSubnet extends Resource<AwsSubnet> implements AwsSubnet {
cidr_block: string,
map_public_ip_on_launch: boolean,
id: string,
availability_zone = "us-west-2a",
availability_zone: `${awsZone}${char}` = "us-west-2a",
autoIam?: boolean,
name?: string
) {
Expand Down
6 changes: 3 additions & 3 deletions backend/src/terraform/gce.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {machineType} from "../types/terraform";
import {machineType, gcpZone} from "../types/terraform";
import {jsonRoot} from "./util";
import {Resource} from "./resource";

export interface Gce {
project: string;
machine_type: machineType;
zone: string;
zone: gcpZone;
disk_image: string;
}
export class Gce extends Resource<Gce> implements Gce {
Expand All @@ -20,7 +20,7 @@ export class Gce extends Resource<Gce> implements Gce {
id: string,
machine_type: machineType,
disk_image: string,
zone = "us-west1-a"
zone: gcpZone = "us-west1-a"
) {
super(id, "Gce");
this.project = project;
Expand Down
16 changes: 9 additions & 7 deletions backend/src/terraform/googleProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import {DatabaseModel, generateSchema} from "../types/database";
import {
named,
NamedRequiredProvider,
RequiredProvider
RequiredProvider,
gcpZone,
gcpRegion
} from "../types/terraform";
import {removeName} from "./util";

export interface GoogleProvider extends named<RequiredProvider, "google"> {
project: string;
region?: string;
zone?: string;
region?: gcpRegion;
zone?: gcpZone;
credentials?: string;
}
export class GoogleProvider
Expand All @@ -20,14 +22,14 @@ export class GoogleProvider
name: "google";

constructor(project: string);
constructor(project: string, region: string);
constructor(project: string, region: string, zone: string);
constructor(project: string, region: gcpRegion);
constructor(project: string, region: gcpRegion, zone: gcpZone);
constructor(
project: string,
source = "hashicorp/google",
version = ">= 4.10.0",
region = "us-west1",
zone: string | null = null,
region: gcpRegion = "us-west1",
zone: gcpZone | null = null,
credentials: string | null = null
) {
super(source, version, "google");
Expand Down
33 changes: 33 additions & 0 deletions backend/src/types/terraform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,39 @@ export interface Firewall {
cidr_blocks?: string[];
}

export type char =
| "a"
| "b"
| "c"
| "d"
| "e"
| "f"
| "g"
| "h"
| "i"
| "j"
| "k"
| "l"
| "m"
| "n"
| "o"
| "p"
| "q"
| "r"
| "s"
| "t"
| "u"
| "v"
| "w"
| "x"
| "y"
| "z";
export type digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
export type countryCode = "us" | "af" | "ap" | "ca" | "eu" | "me" | "sa";
export type awsZone = `${countryCode}-${string}-${digit}`;
export type gcpRegion = `${string}-${string}${digit}`;
export type gcpZone = `${string}-${string}${digit}-${char}`;

// ----------------------------Terraform Root-------------------------------- //

export interface Terraform {
Expand Down