forked from hashicorp/terraform-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cs
60 lines (51 loc) · 1.86 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
using System;
using System.Collections.Generic;
using System.Linq;
using aws;
using Constructs;
using Hashicorp.Cdktf;
namespace MyCompany.MyApp
{
class MyApp : TerraformStack
{
public MyApp(Construct scope, string id) : base(scope, id)
{
new AwsProvider(this, "aws", new AwsProviderConfig {
Region = "eu-central-1"
});
DataAwsRegion region = new DataAwsRegion(this, "region");
DynamodbTable table = new DynamodbTable(this, "Hello", new DynamodbTableConfig {
Name = $"my-first-table-{region.Name}",
HashKey = "temp",
Attribute = new [] {
new DynamodbTableAttribute {
Name = "id",
Type = "S"
}
},
BillingMode = "PAY_PER_REQUEST"
});
table.AddOverride("hash_key", "id");
table.AddOverride("lifecycle", new Dictionary<string, object> { ["create_before_destroy"] = true });
const int topicCount = 1;
List<SnsTopic> topics = Enumerable.Range(0, topicCount).Select(i => new SnsTopic(this, $"Topic{i}", new SnsTopicConfig {
DisplayName = $"my-first-sns-topic{i}"
})).ToList();
new TerraformOutput(this, "table_name", new TerraformOutputConfig {
Value = table.Name
});
for (int i = 0; i < topics.Count; i++) {
new TerraformOutput(this, $"sns_topic{i}", new TerraformOutputConfig {
Value = topics[i].Name
});
}
}
public static void Main(string[] args)
{
App app = new App();
new MyApp(app, "aws");
app.Synth();
Console.WriteLine("App synth complete");
}
}
}