Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOP-2325][DEV-12391][DEV-12396][DOP-2328] EKS cluster module update, IAM module introduction #349

Merged
merged 95 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
1e61263
First run
ashmuck Oct 16, 2024
865b1f5
Update node groups as well
ashmuck Oct 16, 2024
04a9cad
Update provider version
ashmuck Oct 16, 2024
de77498
Remove aws auth variables from eks module
ashmuck Oct 16, 2024
4ca6437
Removing aws auth output from cluster module
ashmuck Oct 16, 2024
9c6c091
Added reference to cluster service cidr
ashmuck Oct 16, 2024
c7129b9
Node role arn instead of node role name
ashmuck Oct 16, 2024
ea947db
Update the cluster node role name to see if transition is better
ashmuck Oct 16, 2024
3e25c73
Revert back and try building cluster from scratch
ashmuck Oct 17, 2024
8b92f87
deprecated resolve_conflicts on aws eks addon
ashmuck Oct 17, 2024
35b1029
Remove quotes around depends_on resource
ashmuck Oct 17, 2024
16f8828
Don't create the cluster access entry every time
ashmuck Oct 17, 2024
4b11ccd
Updated aws-auth and implemented additional users
ashmuck Oct 17, 2024
3412340
Updated aws-auth and implemented additional users
ashmuck Oct 17, 2024
0bb948c
Duplicate data block
ashmuck Oct 17, 2024
73cdf58
Use different method to check set length for aws-auth roles
ashmuck Oct 17, 2024
d98f815
Fix set indexing in cluster module
ashmuck Oct 17, 2024
49e263c
aws-auth users is a list, not dict
ashmuck Oct 17, 2024
9c210b0
Using aws eks access entry to start the process of setting aws-auth
ashmuck Oct 17, 2024
0c80d59
Add aws-auth dependency, remove kubernetes group section of eks acces…
ashmuck Oct 17, 2024
9df60bd
Added a policy assocaition to the access entry
ashmuck Oct 17, 2024
bf91f3c
Added a policy assocaition to the access entry, fix reference
ashmuck Oct 17, 2024
fee6922
Create aws-auth cm
ashmuck Oct 17, 2024
a327619
Give original user clusteradmin access
ashmuck Oct 17, 2024
a091cc0
Switch off of using aws-auth completely
ashmuck Oct 17, 2024
b1d660b
Added in a few unused variable declarations to reduce terraform warnings
ashmuck Oct 17, 2024
5994d32
Removing the argo-registration warnings
ashmuck Oct 17, 2024
e750767
Added extra variables that were undeclared
ashmuck Oct 17, 2024
785750b
More variables
ashmuck Oct 17, 2024
cd05d5e
More variables
ashmuck Oct 18, 2024
e407f70
More variables
ashmuck Oct 18, 2024
0ce9dc2
More variables
ashmuck Oct 18, 2024
7a606aa
Remove access entry for all except node role
ashmuck Oct 18, 2024
d0b6f94
All roles have access entries, user does not
ashmuck Oct 18, 2024
48e9505
Access entry created for terraform-sa
ashmuck Oct 21, 2024
3cfcf3c
[DOP-2325] Increase bucket module version
ltellesfl Oct 22, 2024
912f29a
test moved block
ltellesfl Oct 24, 2024
ef1b8f9
test moved block
ltellesfl Oct 24, 2024
7ea2bb4
test moved block
ltellesfl Oct 24, 2024
9b70b27
test moved block
ltellesfl Oct 24, 2024
4b84e1d
test moved block
ltellesfl Oct 24, 2024
9122bc7
test moved block
ltellesfl Oct 24, 2024
8ea7578
test moved block
ltellesfl Oct 24, 2024
991e52c
Add variables to load buckets
ltellesfl Oct 25, 2024
67c9ff6
Update s3 storage variables
ltellesfl Oct 28, 2024
9af0b3c
Add output pgbackup_s3_bucket_name
ltellesfl Oct 29, 2024
6668b4f
Adding iam module
ashmuck Nov 15, 2024
ff9dc58
Updated module versions
ashmuck Nov 15, 2024
1698c1f
Updated aws provider for cluster module
ashmuck Nov 15, 2024
d48ec35
Updated the bucket name
ashmuck Nov 15, 2024
5846ae6
Merged
ashmuck Nov 15, 2024
d115602
Merged in changes for the s3 module as well
ashmuck Nov 15, 2024
0d0ac12
Added variables that didn't have declarations
ashmuck Nov 15, 2024
7d69318
Committed
ashmuck Nov 15, 2024
9753284
updated override variable for buckets
ashmuck Nov 15, 2024
c453966
Updated modules
ashmuck Nov 15, 2024
a26eb61
removed output
ashmuck Nov 15, 2024
74dc929
Bucket variable
ashmuck Nov 15, 2024
e1dda1e
chnaged references to node role
ashmuck Nov 15, 2024
0116eae
Updated modules
ashmuck Nov 15, 2024
c156c38
Updated the s3 module to handle bucket name overrides
ashmuck Nov 15, 2024
7f1fefd
Updated the s3 storage module to pull in the arn of the s3 replicatio…
ashmuck Nov 15, 2024
feb920d
s3 module doesn't take in any values relating to s3 cross-region repl…
ashmuck Nov 15, 2024
029a230
Updated encryption policy handling
ashmuck Nov 15, 2024
566efe7
Formatting issue, create_kms_key should be false
ashmuck Nov 15, 2024
0ba559a
Now allow the cluster to generate kms key by default
ashmuck Nov 15, 2024
c84178a
Added moved blocks for IAM resources
ashmuck Nov 15, 2024
d0a62d0
Fixed the state to make it easier to transfer
ashmuck Nov 15, 2024
9d6538a
Updated the module to better handle state migration
ashmuck Nov 15, 2024
324d9c8
Issue with the policy attachments?
ashmuck Nov 15, 2024
f309e42
Removing all aws_iam_policy_attachment move blocks
ashmuck Nov 15, 2024
4550f47
bumpedversion of wrong module
ashmuck Nov 15, 2024
8955453
Upgrade module
ashmuck Nov 15, 2024
0282ef4
Always sort the output of keys
ashmuck Nov 15, 2024
b08166b
Fix the ordering of the move
ashmuck Nov 15, 2024
233d587
[DOP-2328] (#364)
ltellesfl Nov 27, 2024
a4e6264
Merge branch 'main' into eks-cluster-update
ltellesfl Nov 27, 2024
94067a9
Update iam version
ltellesfl Dec 2, 2024
2dcc340
Remove unused bucket variables from iam module
ltellesfl Dec 2, 2024
0b41ed5
Remove empty strings from iam bucket list
ltellesfl Dec 2, 2024
b3c697f
Add moved block to iam policy
ltellesfl Dec 2, 2024
56e1dca
Remove moved block
ltellesfl Dec 2, 2024
d3e28ab
Update iam version
ltellesfl Dec 2, 2024
1013d3e
Add moved block to iam policy
ltellesfl Dec 2, 2024
55aab56
Disable wait sync from ipa argocd_application
ltellesfl Dec 3, 2024
e38cb16
Wait wait sync from ipa argocd_application
ltellesfl Dec 3, 2024
dbaf44d
Remove sync policy from argocd resource and add selfHeal to argo appl…
ltellesfl Dec 3, 2024
6fdd1ec
Remove ServerSideApply from ipa application
ltellesfl Dec 3, 2024
a5e8353
Revert "Remove ServerSideApply from ipa application"
ltellesfl Dec 3, 2024
43af31b
Revert "Remove sync policy from argocd resource and add selfHeal to a…
ltellesfl Dec 3, 2024
d7eb64a
Enable self_heal and add ServerSideApply=true to deploy-ipa application
ltellesfl Dec 3, 2024
9e46968
Increase cluster module version
ltellesfl Dec 4, 2024
b329506
Enable self_heal and add ServerSideApply=true to deploy-ipa applicati…
ltellesfl Dec 3, 2024
8fb01cb
[DEV-12398] Added permissions for EFS dynamic volume provisioning.
NathanOkolita Dec 6, 2024
e3d939e
Merge branch 'main' into eks-cluster-update
ltellesfl Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion aws_specific_modules.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ resource "aws_eks_addon" "guardduty" {
]
count = var.eks_addon_version_guardduty != null ? 1 : 0


cluster_name = var.label
addon_name = "aws-guardduty-agent"
addon_version = "v1.7.1-eksbuild.1"
Expand Down
4 changes: 2 additions & 2 deletions ipa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ crunchy-postgres:
repo1-retention-full: '5'
repo1-s3-key-type: auto
repo1-s3-kms-key-id: "${module.kms_key.key_arn}"
repo1-s3-role: ${module.cluster.s3_role_id}
repo1-s3-role: ${module.iam.node_role_name}
repos:
- name: repo1
s3:
Expand Down Expand Up @@ -869,7 +869,7 @@ crunchy-postgres:
repo1-retention-full: '5'
repo1-s3-key-type: auto
repo1-s3-kms-key-id: "${module.kms_key.key_arn}"
repo1-s3-role: ${module.cluster.s3_role_id}
repo1-s3-role: ${module.iam.node_role_name}
repos:
- name: repo1
s3:
Expand Down
148 changes: 81 additions & 67 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.68.0"
version = "5.74.0"
}
time = {
source = "hashicorp/time"
Expand Down Expand Up @@ -100,24 +100,13 @@ data "aws_caller_identity" "current" {}
# define the networking module we're using locally
locals {
network = var.network_module == "public_networking" ? module.public_networking : module.networking
aws_usernames = [
"svc_jenkins",
"terraform-sa"
]
eks_users = {
for user in local.aws_usernames : user => {
userarn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:user/${user}"
username = user
groups = ["system:masters"]
}
}

argo_app_name = lower("${var.aws_account}.${var.region}.${var.label}-ipa")
argo_smoketest_app_name = lower("${var.aws_account}.${var.region}.${var.label}-smoketest")
argo_cluster_name = "${var.aws_account}.${var.region}.${var.label}"

chart_version_parts = split("-", var.ipa_version)
chart_suffix = trimprefix(var.ipa_version, local.chart_version_parts[0])
chart_suffix = trimprefix(var.ipa_version, local.chart_version_parts[0])
}

resource "tls_private_key" "pk" {
Expand Down Expand Up @@ -167,12 +156,16 @@ module "networking" {
}

module "sqs_sns" {
count = var.sqs_sns == true ? 1 : 0
source = "app.terraform.io/indico/indico-aws-sqs-sns/mod"
version = "1.2.0"
region = var.region
label = var.label
kms_master_key_id = module.kms_key.key.id
count = var.sqs_sns == true ? 1 : 0
source = "app.terraform.io/indico/indico-aws-sqs-sns/mod"
version = "2.0.0"
region = var.region
label = var.label
kms_master_key_id = module.kms_key.key.id
sqs_sns_type = var.sqs_sns_type
ipa_sns_topic_name = var.ipa_sns_topic_name
ipa_sqs_queue_name = var.ipa_sqs_queue_name
indico_sqs_sns_policy_name = var.indico_sqs_sns_policy_name
}

module "lambda-sns-forwarder" {
Expand Down Expand Up @@ -211,18 +204,21 @@ module "security-group" {
network_module = var.network_module
}


module "s3-storage" {
source = "app.terraform.io/indico/indico-aws-buckets/mod"
version = "3.3.1"
force_destroy = true # allows terraform to destroy non-empty buckets.
label = var.label
kms_key_arn = module.kms_key.key.arn
submission_expiry = var.submission_expiry
uploads_expiry = var.uploads_expiry
include_rox = var.include_rox
enable_backup = var.enable_s3_backup
enable_access_logging = var.enable_s3_access_logging
source = "app.terraform.io/indico/indico-aws-buckets/mod"
version = "4.1.1"
force_destroy = true # allows terraform to destroy non-empty buckets.
label = var.label
kms_key_arn = module.kms_key.key.arn
submission_expiry = var.submission_expiry
uploads_expiry = var.uploads_expiry
include_rox = var.include_rox
enable_backup = var.enable_s3_backup
enable_access_logging = var.enable_s3_access_logging
bucket_type = var.bucket_type
data_s3_bucket_name_override = var.data_s3_bucket_name_override
api_models_s3_bucket_name_override = var.api_models_s3_bucket_name_override
pgbackup_s3_bucket_name_override = var.pgbackup_s3_bucket_name_override
}


Expand Down Expand Up @@ -310,39 +306,57 @@ module "fsx-storage" {
fsx_rox_arn = var.fsx_rox_arn
}

module "iam" {
source = "app.terraform.io/indico/indico-aws-iam/mod"
version = "0.0.9"

# EKS node role
create_node_role = var.create_node_role
eks_cluster_nodes_iam_role = var.node_role_name_override == null ? "${var.label}-${var.region}-node-role" : var.node_role_name_override
label = var.label
region = var.region
cluster_node_policies = var.cluster_node_policies
aws_primary_dns_role_arn = var.aws_primary_dns_role_arn
efs_filesystem_id = [var.include_efs == true ? module.efs-storage[0].efs_filesystem_id : ""]
fsx_arns = [var.include_rox ? module.fsx-storage[0].fsx-rox.arn : "", var.include_fsx == true ? module.fsx-storage[0].fsx-rwx.arn : ""]
s3_buckets = compact([module.s3-storage.data_s3_bucket_name, var.include_pgbackup ? module.s3-storage.pgbackup_s3_bucket_name : "", var.include_rox ? module.s3-storage.api_models_s3_bucket_name : "", lower("${var.aws_account}-aws-cod-snapshots"), var.performance_bucket ? "indico-locust-benchmark-test-results" : ""])
kms_key_arn = module.kms_key.key_arn
# s3 replication
enable_s3_replication = var.enable_s3_replication
create_s3_replication_role = var.create_s3_replication_role
s3_replication_role_name = var.s3_replication_role_name_override == null ? "s3-bucket-replication-${var.label}" : var.s3_replication_role_name_override
s3_replication_destination_kms_key_arn = var.destination_kms_key_arn
s3_replication_data_destination_bucket_name = var.data_destination_bucket
s3_replication_api_model_destination_bucket_name = var.api_model_destination_bucket
}

module "cluster" {
cod_snapshots_enabled = true
allow_dns_management = true
aws_account_name = var.aws_account
oidc_enabled = false
source = "app.terraform.io/indico/indico-aws-eks-cluster/mod"
version = "8.2.3"
label = var.label
additional_tags = var.additional_tags
region = var.region
map_users = values(local.eks_users)
vpc_id = local.network[0].indico_vpc_id
security_group_id = var.network_module == "networking" ? local.network[0].all_subnets_sg_id : module.security-group.all_subnets_sg_id
source = "app.terraform.io/indico/indico-aws-eks-cluster/mod"
version = "9.0.31"
label = var.label
region = var.region
cluster_version = var.k8s_version
default_tags = merge(coalesce(var.default_tags, {}), coalesce(var.additional_tags, {}))

kms_key_arn = module.kms_key.key_arn

vpc_id = local.network[0].indico_vpc_id
az_count = var.az_count
subnet_ids = flatten([local.network[0].private_subnet_ids])

node_groups = var.node_groups
node_role_name = module.iam.node_role_name
node_role_arn = module.iam.node_role_arn
instance_volume_size = var.instance_volume_size
instance_volume_type = var.instance_volume_type

additional_users = var.additional_users

public_endpoint_enabled = var.cluster_api_endpoint_public == true ? true : false
private_endpoint_enabled = var.network_allow_public == true ? false : true

cluster_security_group_id = var.network_module == "networking" ? local.network[0].all_subnets_sg_id : module.security-group.all_subnets_sg_id
cluster_additional_security_group_ids = var.network_module == "networking" ? [local.network[0].all_subnets_sg_id] : []
subnet_ids = flatten([local.network[0].private_subnet_ids])
node_groups = var.node_groups
cluster_node_policies = var.cluster_node_policies
eks_cluster_iam_role = var.eks_cluster_iam_role
eks_cluster_nodes_iam_role = "${var.label}-${var.region}-node-role"
fsx_arns = [var.include_rox ? module.fsx-storage[0].fsx_rox_arn : "", var.include_fsx == true ? module.fsx-storage[0].fsx_rwx_arn : ""]
kms_key_arn = module.kms_key.key_arn
az_count = var.az_count
key_pair = aws_key_pair.kp.key_name
snapshot_id = var.snapshot_id
default_tags = var.default_tags
s3_buckets = [module.s3-storage.data_s3_bucket_name, var.include_pgbackup ? module.s3-storage.pgbackup_s3_bucket_name : "", var.include_rox ? module.s3-storage.api_models_s3_bucket_name : "", lower("${var.aws_account}-aws-cod-snapshots"), var.performance_bucket ? "indico-locust-benchmark-test-results" : ""]
cluster_version = var.k8s_version
efs_filesystem_id = [var.include_efs == true ? module.efs-storage[0].efs_filesystem_id : ""]
aws_primary_dns_role_arn = var.aws_primary_dns_role_arn
private_endpoint_enabled = var.network_allow_public == true ? false : true
public_endpoint_enabled = var.cluster_api_endpoint_public == true ? true : false
instance_volume_size = var.instance_volume_size
instance_volume_type = var.instance_volume_type
}

locals {
Expand Down Expand Up @@ -379,13 +393,13 @@ provider "argocd" {
}

data "aws_eks_cluster" "local" {
depends_on = [ module.cluster.kubernetes_host ]
name = var.label
depends_on = [module.cluster.kubernetes_host]
name = var.label
}

data "aws_eks_cluster_auth" "local" {
depends_on = [ module.cluster.kubernetes_host ]
name = var.label
depends_on = [module.cluster.kubernetes_host]
name = var.label
}

provider "kubernetes" {
Expand Down Expand Up @@ -462,7 +476,7 @@ module "argo-registration" {
}

source = "app.terraform.io/indico/indico-argo-registration/mod"
version = "1.2.2"
version = "1.3.0"
cluster_name = var.label
region = var.region
argo_password = var.argo_password
Expand Down
14 changes: 14 additions & 0 deletions moved.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
moved {
from = module.cluster.aws_iam_policy.cluster_node_ebs_iam_policy
to = module.iam.module.create_eks_node_role[0].aws_iam_policy.policies[0]
}

moved {
from = module.cluster.aws_iam_policy.cluster_node_iam_policy
to = module.iam.module.create_eks_node_role[0].aws_iam_policy.policies[1]
}

moved {
from = module.cluster.aws_iam_role.node_role
to = module.iam.module.create_eks_node_role[0].aws_iam_role.role
}
4 changes: 2 additions & 2 deletions on_prem_test.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ YAML
data "local_file" "nfs_ip" {
count = var.on_prem_test == true ? 1 : 0
filename = "${path.module}/nfs_server_ip.txt"
depends_on = ["null_resource.get_nfs_server_ip"]
depends_on = [null_resource.get_nfs_server_ip]
}


Expand Down Expand Up @@ -183,4 +183,4 @@ resource "null_resource" "update_storage_class" {
provisioner "local-exec" {
command = "./kubectl patch storageclass nfs-client -p '{\"metadata\": {\"annotations\":{\"storageclass.kubernetes.io/is-default-class\":\"true\"}}}'"
}
}
}
7 changes: 3 additions & 4 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ output "data_s3_bucket_name" {
value = module.s3-storage.data_s3_bucket_name
}

output "s3_role_id" {
description = "ID of the S3 role"
value = module.cluster.s3_role_id
output "pgbackup_s3_bucket_name" {
description = "Name of the pgbackup s3 bucket"
value = module.s3-storage.pgbackup_s3_bucket_name
}


output "efs_filesystem_id" {
description = "ID of the EFS filesystem"
value = var.include_efs == true ? module.efs-storage[0].efs_filesystem_id : ""
Expand Down
26 changes: 26 additions & 0 deletions tf-smoketest-variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,32 @@ resource "kubernetes_config_map" "terraform-variables" {
vpc_flow_logs_iam_role_arn = "${jsonencode(var.vpc_flow_logs_iam_role_arn)}"
instance_volume_size = "${jsonencode(var.instance_volume_size)}"
instance_volume_type = "${jsonencode(var.instance_volume_type)}"
additional_users = "${jsonencode(var.additional_users)}"
aws_account_name = "${jsonencode(var.aws_account_name)}"
access_key = "${jsonencode(var.access_key)}"
secret_key = "${jsonencode(var.secret_key)}"
cluster_type = "${jsonencode(var.cluster_type)}"
argo_bcrypt_password = "${jsonencode(var.argo_bcrypt_password)}"
harbor_admin_password = "${jsonencode(var.harbor_admin_password)}"
azure_indico_io_client_secret_id = "${jsonencode(var.azure_indico_io_client_secret_id)}"
az_readapi_subscription_id = "${jsonencode(var.az_readapi_subscription_id)}"
az_readapi_client_id = "${jsonencode(var.az_readapi_client_id)}"
az_readapi_client_secret_id = "${jsonencode(var.az_readapi_client_secret_id)}"
aws_account_ids = "${jsonencode(var.aws_account_ids)}"
ipa_smoketest_cronjob_enabled = "${jsonencode(var.ipa_smoketest_cronjob_enabled)}"
local_registry_harbor_robot_account_name = "${jsonencode(var.local_registry_harbor_robot_account_name)}"
bucket_type = "${jsonencode(var.bucket_type)}"
data_s3_bucket_name_override = "${jsonencode(var.data_s3_bucket_name_override)}"
api_models_s3_bucket_name_override = "${jsonencode(var.api_models_s3_bucket_name_override)}"
pgbackup_s3_bucket_name_override = "${jsonencode(var.pgbackup_s3_bucket_name_override)}"
enable_s3_replication = "${jsonencode(var.enable_s3_replication)}"
create_s3_replication_role = "${jsonencode(var.create_s3_replication_role)}"
s3_replication_role_name_override = "${jsonencode(var.s3_replication_role_name_override)}"
destination_kms_key_arn = "${jsonencode(var.destination_kms_key_arn)}"
data_destination_bucket = "${jsonencode(var.data_destination_bucket)}"
api_model_destination_bucket = "${jsonencode(var.api_model_destination_bucket)}"
create_node_role = "${jsonencode(var.create_node_role)}"
node_role_name_override = "${jsonencode(var.node_role_name_override)}"
fsx_deployment_type = "${jsonencode(var.fsx_deployment_type)}"
fsx_type = "${jsonencode(var.fsx_type)}"
fsx_rwx_id = "${jsonencode(var.fsx_rwx_id)}"
Expand Down
Loading
Loading