-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathaws_ts.ts
177 lines (160 loc) · 4.55 KB
/
aws_ts.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import { action, logger, resource, serveWorkflow } from 'lyra-workflow';
import * as Aws from './types/Aws';
serveWorkflow({
source: __filename,
parameters: { tags: { type: 'StringHash', lookup: 'aws.tags' } },
returns: { aws_vpc_id: 'string' },
steps: {
aws_iam_role: resource({
state: (): Aws.Iam_role => {
return new Aws.Iam_role({
name: "lyra-iam-role",
assume_role_policy: `{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRoleWithSAML",
"Effect": "Allow",
"Condition": {
"StringEquals": {
"SAML:aud": "https://signin.aws.amazon.com/saml"
}
},
"Principal": {
"Federated": "arn:aws:iam::1234567890:saml-provider/myidp"
}
}
]
}
`
});
}
}),
//
// Application of Key_pair succeeds on the first run then fails: see https://github.com/lyraproj/lyra/issues/203
//
// aws_key_pair: resource({
// state: (): Aws.Key_pair => {
// return new Aws.Key_pair({
// key_name: "lyra-test-keypair",
// public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCX363gh/q6DGSL963/LlYcILkYKtEjrq5Ze4gr1BJdY0pqLMIKFt/VMJ5UTyx85N4Chjb/jEQhZzlWGC1SMsXOQ+EnY72fYrpOV0wZ4VraxZAz3WASikEglHJYALTQtsL8RGPxlBhIv0HpgevBkDlHvR+QGFaEQCaUhXCWDtLWYw== nyx-test-keypair-nopassword"
// })
// }
// }),
aws_vpc: resource({
returns: "vpc_id",
state: (tags: { [s: string]: string }): Aws.Vpc => {
return new Aws.Vpc({
cidr_block: "192.168.0.0/16",
instance_tenancy: "default",
tags
});
}
}),
// An example of an action triggered after the VPC is created
vpcDone: action({
do: (vpc_id: string): { vpcOk: boolean } => {
logger.info('created vpc', 'vpc_id', vpc_id);
return { vpcOk: true };
}
}),
aws_route_table: resource({
state: (vpc_id: string): Aws.Route_table => {
return new Aws.Route_table({
vpc_id,
tags: {
"name": "lyra-routetable",
"created_by": "lyra"
},
});
}
}),
//
// Deletion of Internet_gateway fails: see https://github.com/lyraproj/lyra/issues/204
//
// aws_internet_gateway: resource({
// state: (vpc_id: string): Aws.Internet_gateway => {
// return new Aws.Internet_gateway({
// vpc_id: aws_vpc_id,
// })
// }
// }),
aws_security_group: resource({
state: (vpc_id: string): Aws.Security_group => {
return new Aws.Security_group({
name: "lyra",
description: "lyra security group",
vpc_id,
ingress: [{
from_port: 0,
to_port: 0,
protocol: "-1",
cidr_blocks: ["0.0.0.0/0"]
}],
egress: [{
from_port: 0,
to_port: 0,
protocol: "-1",
cidr_blocks: ["0.0.0.0/0"]
}],
});
}
}),
aws_subnet1: resource({
returns: {
"subnet_id1": { alias: "subnet_id" }
},
state: (vpc_id: string): Aws.Subnet => {
return new Aws.Subnet({
vpc_id,
cidr_block: "192.168.1.0/24",
tags: {
"name": "lyra-subnet-1",
"created_by": "lyra"
},
});
}
}),
aws_subnet2: resource({
returns: {
"subnet_id2": { alias: "subnet_id" }
},
state: (vpc_id: string): Aws.Subnet => {
return new Aws.Subnet({
vpc_id,
cidr_block: "192.168.2.0/24",
tags: {
"name": "lyra-subnet-2",
"created_by": "lyra"
},
});
}
}),
aws_instance1: resource({
state: (subnet_id1: string): Aws.Instance => {
return new Aws.Instance({
instance_type: "t2.nano",
ami: "ami-f90a4880",
subnet_id: subnet_id1,
tags: {
"name": "lyra-instance-1",
"created_by": "lyra"
},
});
}
}),
aws_instance2: resource({
state: (aws_subnet_id2: string): Aws.Instance => {
return new Aws.Instance({
instance_type: "t2.nano",
ami: "ami-f90a4880",
subnet_id: aws_subnet_id2,
tags: {
"name": "lyra-instance-2",
"created_by": "lyra"
},
});
}
}),
}
});