Skip to content

Commit 0400a7b

Browse files
authored
Merge pull request #309 from sassoftware/staging
8.6.0 - October 31, 2024
2 parents 9b15158 + 4205afc commit 0400a7b

File tree

9 files changed

+58
-25
lines changed

9 files changed

+58
-25
lines changed

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
ARG TERRAFORM_VERSION=1.8.5
2-
ARG AWS_CLI_VERSION=2.16.5
3-
FROM hashicorp/terraform:$TERRAFORM_VERSION as terraform
1+
ARG TERRAFORM_VERSION=1.9.6
2+
ARG AWS_CLI_VERSION=2.17.58
3+
FROM hashicorp/terraform:$TERRAFORM_VERSION AS terraform
44

55
FROM amazon/aws-cli:$AWS_CLI_VERSION
6-
ARG KUBECTL_VERSION=1.29.7
6+
ARG KUBECTL_VERSION=1.29.8
77

88
WORKDIR /viya4-iac-aws
99

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ The following are also required:
4747

4848
#### Terraform Requirements:
4949

50-
- [Terraform](https://www.terraform.io/downloads.html) v1.8.3
51-
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) - v1.29.7
50+
- [Terraform](https://www.terraform.io/downloads.html) v1.9.6
51+
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) - v1.29.8
5252
- [jq](https://stedolan.github.io/jq/) v1.6
53-
- [AWS CLI](https://aws.amazon.com/cli) (optional; useful as an alternative to the AWS Web Console) v2.15.46
53+
- [AWS CLI](https://aws.amazon.com/cli) (optional; useful as an alternative to the AWS Web Console) v2.17.58
5454

5555
#### Docker Requirements:
5656

container-structure-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ commandTests:
1717
- name: "terraform version"
1818
command: "terraform"
1919
args: ["--version"]
20-
expectedOutput: ["Terraform v1.8.5"]
20+
expectedOutput: ["Terraform v1.9.6"]
2121
- name: "aws-cli version"
2222
command: "sh"
2323
args:
2424
- -c
2525
- |
2626
aws --version
27-
expectedOutput: ["aws-cli/2.16.5"]
27+
expectedOutput: ["aws-cli/2.17.58"]
2828

2929
metadataTest:
3030
workdir: "/viya4-iac-aws"

main.tf

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ provider-selections: ${data.external.iac_tooling_version.result["provider_select
5050
outdated: ${data.external.iac_tooling_version.result["terraform_outdated"]}
5151
EOT
5252
}
53+
54+
depends_on = [module.kubeconfig.kube_config]
5355
}
5456

5557
# EKS Provider
@@ -91,7 +93,7 @@ module "vpc" {
9193
# EKS Setup - https://github.com/terraform-aws-modules/terraform-aws-eks
9294
module "eks" {
9395
source = "terraform-aws-modules/eks/aws"
94-
version = "~> 19.0"
96+
version = "~> 20.0"
9597
cluster_name = local.cluster_name
9698
cluster_version = var.kubernetes_version
9799
cluster_enabled_log_types = [] # disable cluster control plan logging
@@ -163,6 +165,36 @@ module "eks" {
163165
create_iam_role = var.cluster_iam_role_arn == null ? true : false
164166
iam_role_arn = var.cluster_iam_role_arn
165167

168+
# Cluster access entry
169+
# To add the current caller identity as an administrator
170+
enable_cluster_creator_admin_permissions = true
171+
172+
access_entries = {
173+
# access entry with cluster and namespace scoped policies
174+
cluster_creator = {
175+
kubernetes_groups = ["rbac.authorization.k8s.io"]
176+
principal_arn = data.aws_caller_identity.terraform.arn
177+
user_name = local.aws_caller_identity_user_name
178+
type = "STANDARD"
179+
180+
policy_associations = {
181+
cluster_creator_assoc = {
182+
policy_arn = "arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy"
183+
access_scope = {
184+
type = "cluster"
185+
}
186+
},
187+
namespace_creator_assoc = {
188+
policy_arn = "arn:aws:eks::aws:cluster-access-policy/AmazonEKSAdminPolicy"
189+
access_scope = {
190+
type = "namespace"
191+
namespaces = ["kube-system"]
192+
}
193+
}
194+
},
195+
},
196+
}
197+
166198
iam_role_additional_policies = {
167199
"additional" : "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
168200
}
@@ -222,7 +254,7 @@ module "kubeconfig" {
222254
ca_crt = local.kubeconfig_ca_cert
223255
sg_id = local.cluster_security_group_id
224256

225-
depends_on = [module.eks.cluster_name] # The name/id of the EKS cluster. Will block on cluster creation until the cluster is really ready.
257+
depends_on = [module.eks] # Will block on EKS cluster creation until the cluster is completely ready.
226258
}
227259

228260
# Normally, the use of local-exec below is avoided. It is used here to patch the gp2 storage class as the default storage class for EKS 1.30 and later clusters.
@@ -233,7 +265,7 @@ resource "terraform_data" "run_command" {
233265
command = "kubectl --kubeconfig=${local.kubeconfig_path} patch storageclass gp2 --patch '{\"metadata\": {\"annotations\":{\"storageclass.kubernetes.io/is-default-class\":\"true\"}}}' "
234266
}
235267

236-
depends_on = [module.kubeconfig]
268+
depends_on = [module.kubeconfig.kube_config]
237269
}
238270

239271
# Database Setup - https://registry.terraform.io/modules/terraform-aws-modules/rds/aws/6.2.0

modules/aws_autoscaling/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ data "aws_iam_policy_document" "worker_autoscaling" {
3333
"autoscaling:SetDesiredCapacity",
3434
"autoscaling:TerminateInstanceInAutoScalingGroup",
3535
"autoscaling:UpdateAutoScalingGroup"
36-
36+
3737
]
3838

3939
resources = ["*"]

modules/aws_vm/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ resource "aws_instance" "vm" {
8181
delete_on_termination = var.os_disk_delete_on_termination
8282
iops = var.os_disk_iops
8383
encrypted = var.enable_ebs_encryption
84-
tags = merge(
85-
{
86-
Name : "${var.name}-root-vol"
87-
},
88-
var.tags
89-
)
84+
tags = merge(
85+
{
86+
Name : "${var.name}-root-vol"
87+
},
88+
var.tags
89+
)
9090
}
9191

9292
tags = merge(var.tags, tomap({ Name : "${var.name}-vm" }))

modules/aws_vpc/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ locals {
77
vpc_id = var.vpc_id == null ? aws_vpc.vpc[0].id : data.aws_vpc.vpc[0].id
88
existing_subnets = length(var.existing_subnet_ids) > 0 ? true : false
99

10-
existing_public_subnets = local.existing_subnets && contains(keys(var.existing_subnet_ids), "public") ? (length(var.existing_subnet_ids["public"]) > 0 ? true : false) : false
11-
existing_private_subnets = local.existing_subnets && contains(keys(var.existing_subnet_ids), "private") ? (length(var.existing_subnet_ids["private"]) > 0 ? true : false) : false
12-
existing_database_subnets = local.existing_subnets && contains(keys(var.existing_subnet_ids), "database") ? (length(var.existing_subnet_ids["database"]) > 0 ? true : false) : false
10+
existing_public_subnets = local.existing_subnets && contains(keys(var.existing_subnet_ids), "public") ? (length(var.existing_subnet_ids["public"]) > 0 ? true : false) : false
11+
existing_private_subnets = local.existing_subnets && contains(keys(var.existing_subnet_ids), "private") ? (length(var.existing_subnet_ids["private"]) > 0 ? true : false) : false
12+
existing_database_subnets = local.existing_subnets && contains(keys(var.existing_subnet_ids), "database") ? (length(var.existing_subnet_ids["database"]) > 0 ? true : false) : false
1313
existing_control_plane_subnets = local.existing_subnets && contains(keys(var.existing_subnet_ids), "control_plane") ? (length(var.existing_subnet_ids["control_plane"]) > 0 ? true : false) : false
1414

1515
# public_subnets = local.existing_public_subnets ? data.aws_subnet.public : aws_subnet.public # not used keeping for ref
16-
private_subnets = local.existing_private_subnets ? data.aws_subnet.private : aws_subnet.private
16+
private_subnets = local.existing_private_subnets ? data.aws_subnet.private : aws_subnet.private
1717
control_plane_subnets = local.existing_control_plane_subnets ? data.aws_subnet.control_plane : aws_subnet.control_plane
1818

1919
# Use private subnets if we are not creating db subnets and there are no existing db subnets
@@ -53,7 +53,7 @@ resource "aws_vpc_endpoint" "private_endpoints" {
5353
service_name = "com.amazonaws.${var.region}.${each.key}"
5454
vpc_endpoint_type = each.value
5555
security_group_ids = each.value == "Interface" ? [var.security_group_id] : null
56-
private_dns_enabled = each.value == "Interface" ? true : null
56+
private_dns_enabled = each.value == "Interface" ? each.key != "s3" ? true : null : false
5757

5858
tags = merge(
5959
{

modules/aws_vpc/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ variable "vpc_private_endpoints" {
126126
"ec2" = "Interface",
127127
"ecr.api" = "Interface",
128128
"ecr.dkr" = "Interface",
129-
"s3" = "Gateway",
129+
"s3" = "Interface",
130130
"logs" = "Interface",
131131
"sts" = "Interface",
132132
"elasticloadbalancing" = "Interface",

modules/kubeconfig/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ resource "kubernetes_cluster_role_binding" "kubernetes_crb" {
8888

8989
depends_on = [
9090
data.aws_security_group.selected,
91+
local_file.kubeconfig
9192
]
9293
}
9394

0 commit comments

Comments
 (0)