-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmain.dhall
81 lines (66 loc) · 2.05 KB
/
main.dhall
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--
-- Usage:
--
-- Generate resources in the terraform JSON syntax
--
-- $ dhall-to-json <<< ./main.dhall > main.tf.json
--
-- Run terraform to create the given resources.
--
-- $ terraform init
-- $ terraform plan
let JSON =
https://raw.githubusercontent.com/dhall-lang/dhall-lang/8098184d17c3aecc82674a7b874077a7641be05a/Prelude/JSON/package.dhall sha256:0c3c40a63108f2e6ad59f23b789c18eb484d0e9aebc9416c5a4f338c6753084b
let AwsS3Bucket = ./../lib/aws/resources/aws_s3_bucket.dhall
let AwsVPC = ./../lib/aws/resources/aws_vpc.dhall
let AwsEbsVolume = ./../lib/aws/resources/aws_ebs_volume.dhall
let AwsProvider = ./../lib/aws/provider/provider.dhall
let mkRes =
λ(a : Type) → λ(name : Text) → λ(body : a) → JSON.keyValue a name body
let jsonType
: Type → Type
= λ(a : Type) → { mapKey : Text, mapValue : a }
let groupBlocks =
λ(key : Text)
→ λ(a : Type)
→ λ(body : List (jsonType a))
→ [ { mapKey = key, mapValue = body } ]
let groupResources =
λ(key : Text)
→ λ(a : Type)
→ λ(body : List (jsonType a))
→ { resource = {} }
let vol =
mkRes
AwsEbsVolume.Type
"volume_c1"
AwsEbsVolume::{ availability_zone = "us-east-1a" }
let mainVPC = mkRes AwsVPC.Type "main" AwsVPC::{ cidr_block = "10.0.0.0/16" }
let imagesBucket =
mkRes
AwsS3Bucket.Type
"images"
AwsS3Bucket::{
, tags = Some [ { mapKey = "content", mapValue = "images" } ]
, region = Some "us-east-1"
}
let filesBucket =
mkRes
AwsS3Bucket.Type
"files"
AwsS3Bucket::{
, tags = Some [ { mapKey = "content", mapValue = "files" } ]
, region = Some "us-east-1"
}
let awsProvider =
mkRes
AwsProvider.Type
"aws"
AwsProvider::{ region = "us-east-1", version = Some "2.34.0" }
in { provider = [ awsProvider ]
, resource =
{ aws_vpc = [ mainVPC ]
, aws_s3_bucket = [ imagesBucket, filesBucket ]
, aws_ebs_volume = [ vol ]
}
}