-
Notifications
You must be signed in to change notification settings - Fork 437
/
terraform-json.ts
62 lines (59 loc) · 1.59 KB
/
terraform-json.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) HashiCorp, Inc
// SPDX-License-Identifier: MPL-2.0
import * as z from "zod";
const remote = z
.object({
organization: z.string(),
hostname: z.string().optional(),
token: z.string().optional(),
workspaces: z.object({
name: z.string().optional(),
prefix: z.string().optional(),
}),
})
.deepPartial();
export const terraformJsonSchema = z
.object({
"//": z
.object({
metadata: z
.object({
version: z.string(),
stackName: z.string(),
backend: z.string(),
})
.nonstrict(),
outputs: z.record(z.any()),
})
.nonstrict(),
terraform: z.object({
backend: z
.object({
// All other backends are here as well, but we don't read them right now
remote,
})
.nonstrict(),
cloud: z
.object({
organization: z.string(),
hostname: z.string().optional(),
token: z.string().optional(),
workspaces: z.union([
z.object({ name: z.string() }),
z.object({ tags: z.array(z.string()) }),
]),
})
.nonstrict(),
required_providers: z.record(
z.object({ source: z.string(), version: z.string() }).nonstrict()
),
required_version: z.string(),
}),
data: z.record(z.any()),
provider: z.record(z.any()),
resource: z.record(z.any()),
})
.deepPartial()
.nonstrict();
export type TerraformStack = z.infer<typeof terraformJsonSchema>;
export type TerraformJsonConfigBackendRemote = z.infer<typeof remote>;