forked from gbrembati/terraform-cloudguard-gke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onboard-main.tf
144 lines (134 loc) · 4.48 KB
/
onboard-main.tf
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
terraform {
required_providers {
dome9 = {
source = "dome9/dome9"
version = ">= 1.20.5"
}
}
}
# API credentials to connect to your CSPM account
provider "dome9" {
dome9_access_id = var.cspm-key-id
dome9_secret_key = var.cspm-key-secret
}
# Create a dedicated Org-unit under the root one
resource "dome9_organizational_unit" "my-org-unit" {
name = var.cspm-org-unit
parent_id = "00000000-0000-0000-0000-000000000000"
}
# Onboarding of your Azure Accounts
resource "dome9_cloudaccount_azure" "onboard-az-account" {
count = var.azure-onboard ? length(var.azure-accounts) : 0
name = lookup(var.azure-accounts,count.index)[0]
operation_mode = var.azure-op-mode
subscription_id = lookup(var.azure-accounts,count.index)[1]
tenant_id = lookup(var.azure-accounts,count.index)[2]
client_id = lookup(var.azure-accounts,count.index)[3]
client_password = lookup(var.azure-accounts,count.index)[4]
organizational_unit_id = dome9_organizational_unit.my-org-unit.id
depends_on = [dome9_organizational_unit.my-org-unit]
}
# Onboarding of your AWS Accounts
resource "dome9_cloudaccount_aws" "onboard-aws-account" {
count = var.aws-onboard ? length(var.aws-accounts) : 0
name = lookup(var.aws-accounts, count.index)[0]
credentials {
arn = lookup(var.aws-accounts, count.index)[1]
secret = lookup(var.aws-accounts, count.index)[2]
type = "RoleBased"
}
organizational_unit_id = dome9_organizational_unit.my-org-unit.id
net_sec {
regions {
new_group_behavior = var.aws-op-mode
region = "us_east_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "us_west_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "eu_west_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "ap_southeast_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "ap_northeast_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "us_west_2"
}
regions {
new_group_behavior = var.aws-op-mode
region = "sa_east_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "ap_southeast_2"
}
regions {
new_group_behavior = var.aws-op-mode
region = "eu_central_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "ap_northeast_2"
}
regions {
new_group_behavior = var.aws-op-mode
region = "ap_south_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "us_east_2"
}
regions {
new_group_behavior = var.aws-op-mode
region = "ca_central_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "eu_west_2"
}
regions {
new_group_behavior = var.aws-op-mode
region = "eu_west_3"
}
regions {
new_group_behavior = var.aws-op-mode
region = "eu_north_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "ap_east_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "me_south_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "af_south_1"
}
regions {
new_group_behavior = var.aws-op-mode
region = "eu_south_1"
}
}
depends_on = [dome9_organizational_unit.my-org-unit]
}
resource "dome9_cloudaccount_kubernetes" "onboard-k8s-clusters" {
count = var.k8s-onboard ? length(var.k8s-clusters) : 0
name = lookup(var.k8s-clusters, count.index)
organizational_unit_id = dome9_organizational_unit.my-org-unit.id
depends_on = [dome9_organizational_unit.my-org-unit]
}
output "onboard-k8s-instruction" {
value = join("\n\n",formatlist(" Use this command on K8s Cluster: %s \n helm repo add checkpoint https://raw.githubusercontent.com/CheckPointSW/charts/master/repository/ \n helm install asset-mgmt checkpoint/cp-resource-management --set credentials.user=${var.cspm-key-id} --set credentials.secret=${var.cspm-key-secret} --set clusterID=%s --namespace checkpoint --create-namespace", flatten(values(var.k8s-clusters)), dome9_cloudaccount_kubernetes.onboard-k8s-clusters[*].id))
depends_on = [dome9_cloudaccount_kubernetes.onboard-k8s-clusters]
}