Skip to content

Commit 70cfd10

Browse files
authored
Groundwork new workflows (#143)
* Groundwork new workflows * fix regex
1 parent 814a2f4 commit 70cfd10

File tree

5 files changed

+20
-70
lines changed

5 files changed

+20
-70
lines changed

examples/complete/main.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ locals {
2222
# https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/deploy/subnet_discovery.md
2323
tags = { "kubernetes.io/cluster/${module.label.id}" = "shared" }
2424

25-
# required tags to make ALB ingress work https://docs.aws.amazon.com/eks/latest/userguide/alb-ingress.html
26-
public_subnets_additional_tags = {
27-
"kubernetes.io/role/elb" : 1
28-
}
29-
private_subnets_additional_tags = {
30-
"kubernetes.io/role/internal-elb" : 1
31-
}
32-
3325
allow_all_ingress_rule = {
3426
key = "allow_all_ingress"
3527
type = "ingress"

examples/complete/variables.tf

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,6 @@ variable "cluster_log_retention_period" {
3131
description = "Number of days to retain cluster logs. Requires `enabled_cluster_log_types` to be set. See https://docs.aws.amazon.com/en_us/eks/latest/userguide/control-plane-logs.html."
3232
}
3333

34-
variable "map_additional_aws_accounts" {
35-
description = "Additional AWS account numbers to add to `config-map-aws-auth` ConfigMap"
36-
type = list(string)
37-
default = []
38-
}
39-
40-
variable "map_additional_iam_roles" {
41-
description = "Additional IAM roles to add to `config-map-aws-auth` ConfigMap"
42-
43-
type = list(object({
44-
rolearn = string
45-
username = string
46-
groups = list(string)
47-
}))
48-
49-
default = []
50-
}
51-
52-
variable "map_additional_iam_users" {
53-
description = "Additional IAM users to add to `config-map-aws-auth` ConfigMap"
54-
55-
type = list(object({
56-
userarn = string
57-
username = string
58-
groups = list(string)
59-
}))
60-
61-
default = []
62-
}
63-
6434
variable "oidc_provider_enabled" {
6535
type = bool
6636
default = true
@@ -125,18 +95,6 @@ variable "min_size" {
12595
description = "The minimum size of the AutoScaling Group"
12696
}
12797

128-
variable "launch_template_id" {
129-
type = string
130-
description = "The ID of a custom launch template to use for the EKS node group."
131-
default = null
132-
}
133-
134-
variable "launch_template_version" {
135-
type = string
136-
description = "A specific version of the above specific launch template"
137-
default = null
138-
}
139-
14098
variable "before_cluster_joining_userdata" {
14199
type = string
142100
default = ""

iam.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
locals {
22
create_role = local.enabled && length(var.node_role_arn) == 0
3-
aws_policy_prefix = local.create_role ? format("arn:%s:iam::aws:policy", join("", data.aws_partition.current.*.partition)) : ""
3+
aws_policy_prefix = local.create_role ? format("arn:%s:iam::aws:policy", join("", data.aws_partition.current[*].partition)) : ""
44
node_role_policy_arns = sort(var.node_role_policy_arns)
55
}
66

@@ -25,27 +25,27 @@ data "aws_iam_policy_document" "assume_role" {
2525
resource "aws_iam_role" "default" {
2626
count = local.create_role ? 1 : 0
2727
name = module.label.id
28-
assume_role_policy = join("", data.aws_iam_policy_document.assume_role.*.json)
28+
assume_role_policy = join("", data.aws_iam_policy_document.assume_role[*].json)
2929
permissions_boundary = var.node_role_permissions_boundary
3030
tags = module.label.tags
3131
}
3232

3333
resource "aws_iam_role_policy_attachment" "amazon_eks_worker_node_policy" {
3434
count = local.create_role ? 1 : 0
3535
policy_arn = format("%s/%s", local.aws_policy_prefix, "AmazonEKSWorkerNodePolicy")
36-
role = join("", aws_iam_role.default.*.name)
36+
role = join("", aws_iam_role.default[*].name)
3737
}
3838

3939
resource "aws_iam_role_policy_attachment" "amazon_ec2_container_registry_read_only" {
4040
count = local.create_role ? 1 : 0
4141
policy_arn = format("%s/%s", local.aws_policy_prefix, "AmazonEC2ContainerRegistryReadOnly")
42-
role = join("", aws_iam_role.default.*.name)
42+
role = join("", aws_iam_role.default[*].name)
4343
}
4444

4545
resource "aws_iam_role_policy_attachment" "existing_policies_for_eks_workers_role" {
4646
count = local.create_role ? length(var.node_role_policy_arns) : 0
4747
policy_arn = local.node_role_policy_arns[count.index]
48-
role = join("", aws_iam_role.default.*.name)
48+
role = join("", aws_iam_role.default[*].name)
4949
}
5050

5151
# Create a CNI policy that is a merger of AmazonEKS_CNI_Policy and required IPv6 permissions
@@ -79,7 +79,7 @@ data "aws_iam_policy_document" "ipv6_eks_cni_policy" {
7979
"ec2:CreateTags"
8080
]
8181
resources = [
82-
"arn:${join("", data.aws_partition.current.*.partition)}:ec2:*:*:network-interface/*"
82+
"arn:${join("", data.aws_partition.current[*].partition)}:ec2:*:*:network-interface/*"
8383
]
8484
}
8585
}
@@ -88,13 +88,13 @@ resource "aws_iam_policy" "ipv6_eks_cni_policy" {
8888
count = local.create_role && var.node_role_cni_policy_enabled ? 1 : 0
8989

9090
name = "${module.this.id}-CNI_Policy"
91-
policy = join("", data.aws_iam_policy_document.ipv6_eks_cni_policy.*.json)
91+
policy = join("", data.aws_iam_policy_document.ipv6_eks_cni_policy[*].json)
9292
}
9393

9494
resource "aws_iam_role_policy_attachment" "ipv6_eks_cni_policy" {
9595
count = local.create_role && var.node_role_cni_policy_enabled ? 1 : 0
9696

97-
policy_arn = join("", aws_iam_policy.ipv6_eks_cni_policy.*.arn)
98-
role = join("", aws_iam_role.default.*.name)
97+
policy_arn = join("", aws_iam_policy.ipv6_eks_cni_policy[*].arn)
98+
role = join("", aws_iam_role.default[*].name)
9999
}
100100

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ locals {
7171
is_windows = can(regex("WINDOWS", var.ami_type))
7272
ng = {
7373
cluster_name = var.cluster_name
74-
node_role_arn = local.create_role ? join("", aws_iam_role.default.*.arn) : try(var.node_role_arn[0], null)
74+
node_role_arn = local.create_role ? join("", aws_iam_role.default[*].arn) : try(var.node_role_arn[0], null)
7575
# Keep sorted so that change in order does not trigger replacement via random_pet
7676
subnet_ids = sort(var.subnet_ids)
7777
# Always supply instance types via the node group, not the launch template,
@@ -202,7 +202,7 @@ resource "aws_eks_node_group" "default" {
202202
# except for count, lifecycle, and node_group_name.
203203
resource "aws_eks_node_group" "cbd" {
204204
count = local.enabled && var.create_before_destroy ? 1 : 0
205-
node_group_name = format("%v%v%v", module.label.id, module.label.delimiter, join("", random_pet.cbd.*.id))
205+
node_group_name = format("%v%v%v", module.label.id, module.label.delimiter, join("", random_pet.cbd[*].id))
206206

207207
lifecycle {
208208
create_before_destroy = true

outputs.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
output "eks_node_group_role_arn" {
22
description = "ARN of the worker nodes IAM role"
3-
value = join("", aws_iam_role.default.*.arn)
3+
value = join("", aws_iam_role.default[*].arn)
44
}
55

66
output "eks_node_group_role_name" {
77
description = "Name of the worker nodes IAM role"
8-
value = join("", aws_iam_role.default.*.name)
8+
value = join("", aws_iam_role.default[*].name)
99
}
1010

1111
output "eks_node_group_id" {
1212
description = "EKS Cluster name and EKS Node Group name separated by a colon"
13-
value = join("", aws_eks_node_group.default.*.id, aws_eks_node_group.cbd.*.id)
13+
value = join("", aws_eks_node_group.default[*].id, aws_eks_node_group.cbd[*].id)
1414
}
1515

1616
output "eks_node_group_arn" {
1717
description = "Amazon Resource Name (ARN) of the EKS Node Group"
18-
value = join("", aws_eks_node_group.default.*.arn, aws_eks_node_group.cbd.*.arn)
18+
value = join("", aws_eks_node_group.default[*].arn, aws_eks_node_group.cbd[*].arn)
1919
}
2020

2121
output "eks_node_group_resources" {
2222
description = "List of objects containing information about underlying resources of the EKS Node Group"
23-
value = local.enabled ? (var.create_before_destroy ? aws_eks_node_group.cbd.*.resources : aws_eks_node_group.default.*.resources) : []
23+
value = local.enabled ? (var.create_before_destroy ? aws_eks_node_group.cbd[*].resources : aws_eks_node_group.default[*].resources) : []
2424
}
2525

2626
output "eks_node_group_status" {
2727
description = "Status of the EKS Node Group"
28-
value = join("", aws_eks_node_group.default.*.status, aws_eks_node_group.cbd.*.status)
28+
value = join("", aws_eks_node_group.default[*].status, aws_eks_node_group.cbd[*].status)
2929
}
3030

3131
output "eks_node_group_remote_access_security_group_id" {
3232
description = "The ID of the security group generated to allow SSH access to the nodes, if this module generated one"
33-
value = join("", module.ssh_access.*.id)
33+
value = join("", module.ssh_access[*].id)
3434
}
3535

3636
output "eks_node_group_cbd_pet_name" {
3737
description = "The pet name of this node group, if this module generated one"
38-
value = join("", random_pet.cbd.*.id)
38+
value = join("", random_pet.cbd[*].id)
3939
}
4040

4141
output "eks_node_group_launch_template_id" {
@@ -45,7 +45,7 @@ output "eks_node_group_launch_template_id" {
4545

4646
output "eks_node_group_launch_template_name" {
4747
description = "The name of the launch template used for this node group"
48-
value = local.enabled ? (local.fetch_launch_template ? join("", data.aws_launch_template.this.*.name) : join("", aws_launch_template.default.*.name)) : null
48+
value = local.enabled ? (local.fetch_launch_template ? join("", data.aws_launch_template.this[*].name) : join("", aws_launch_template.default[*].name)) : null
4949
}
5050

5151
output "eks_node_group_tags_all" {

0 commit comments

Comments
 (0)