forked from hashicorp/terraform-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cs
64 lines (58 loc) · 1.94 KB
/
Main.cs
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using google;
using Constructs;
using Hashicorp.Cdktf;
namespace MyCompany.MyApp
{
class MyApp : TerraformStack
{
public MyApp(Construct scope, string id) : base(scope, id)
{
string credentials = File.Exists("google.json") ? File.ReadAllText("google.json", Encoding.UTF8) : "{}";
new GoogleProvider(this, "Google", new GoogleProviderConfig {
Region = "us-central1",
Zone = "us-central1-c",
Project = "terraform-cdk",
Credentials = credentials
});
ComputeNetwork network = new ComputeNetwork(this, "Network", new ComputeNetworkConfig {
Name = "cdktf-network"
});
new ComputeInstance(this, "ComputeInstance", new ComputeInstanceConfig {
Name = "cdktf-instance",
MachineType = "f1-micro",
BootDisk = new [] {
new ComputeInstanceBootDisk {
InitializeParams = new [] {
new ComputeInstanceBootDiskInitializeParams {
Image = "debian-cloud/debian-9"
}
}
}
},
NetworkInterface = new [] {
new ComputeInstanceNetworkInterface {
Network = network.Name
}
},
Tags = new [] {
"web",
"dev"
},
DependsOn = new [] {
network
}
});
}
public static void Main(string[] args)
{
App app = new App();
new MyApp(app, "google");
app.Synth();
Console.WriteLine("App synth complete");
}
}
}