-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlocals.tf
96 lines (84 loc) · 3.27 KB
/
locals.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
resource "random_string" "id" {
length = 4
special = false
upper = false
}
locals {
name = "portworx-${random_string.id.result}"
custom_namespace = try(var.helm_config["set"][index(var.helm_config.set.*.name, "namespace")], null)
namespace = local.custom_namespace != null ? local.custom_namespace["value"] : "kube-system"
create_namespace_flag = try(var.helm_config["set"][index(var.helm_config.set.*.name, "createNamespace")], null)
create_namespace = local.create_namespace_flag != null ? local.create_namespace_flag["value"] : false
service_account_name = "${local.name}-sa-${random_string.id.result}"
aws_marketplace_config = try(var.helm_config["set"][index(var.helm_config.set.*.name, "aws.marketplace")], null)
use_aws_marketplace = local.aws_marketplace_config != null ? local.aws_marketplace_config["value"] : false
default_helm_config = {
name = local.name
description = "A Helm chart for portworx"
chart = "portworx"
repository = "https://raw.githubusercontent.com/portworx/eks-blueprint-helm/main/repo/stable"
version = "2.13.5"
namespace = local.namespace
values = local.default_helm_values
}
helm_config = merge(
local.default_helm_config,
var.helm_config
)
irsa_iam_policies_list = local.use_aws_marketplace != false ? [aws_iam_policy.portworx_eksblueprint_metering[0].arn] : []
irsa_config = {
create_kubernetes_namespace = local.create_namespace
kubernetes_namespace = local.namespace
create_kubernetes_service_account = true
kubernetes_service_account = "${local.service_account_name}"
irsa_iam_policies = local.irsa_iam_policies_list
}
default_helm_values = [templatefile("${path.module}/values.yaml", {
imageVersion = "2.13.5"
clusterName = local.name
drives = "type=gp2+size=200"
useInternalKVDB = true
kvdbDevice = "type=gp2,size=150"
pxOperatorImageVersion = "23.4.0"
envVars = ""
maxStorageNodesPerZone = 3
useOpenshiftInstall = false
etcdEndPoint = ""
dataInterface = ""
managementInterface = ""
useStork = true
storkVersion = "23.4.0"
customRegistryURL = ""
registrySecret = ""
licenseSecret = ""
monitoring = false
enableCSI = true
enableAutopilot = false
KVDBauthSecretName = ""
eksServiceAccount = "${local.service_account_name}"
awsAccessKeyId = ""
awsSecretAccessKey = ""
deleteType = "Uninstall"
awsProduct = "PX-ENTERPRISE"
namespace = "kube-system"
createNamespace = false
}
)]
}
resource "aws_iam_policy" "portworx_eksblueprint_metering" {
count = try(local.use_aws_marketplace, false) ? 1 : 0
name = "portworx_eksblueprint_metering-${random_string.id.result}"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"aws-marketplace:MeterUsage",
"aws-marketplace:RegisterUsage"
],
Effect = "Allow",
Resource = "*"
},
]
})
}