-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
534 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#------------------------------------------------------------------------ | ||
# EKS Addons | ||
#------------------------------------------------------------------------ | ||
module "eks_blueprints_addons" { | ||
# Users should pin the version to the latest available release | ||
# tflint-ignore: terraform_module_pinned_source | ||
source = "aws-ia/eks-blueprints-addons/aws" | ||
version = "~> 1.2" | ||
|
||
cluster_name = module.eks.cluster_name | ||
cluster_endpoint = module.eks.cluster_endpoint | ||
cluster_version = module.eks.cluster_version | ||
oidc_provider_arn = module.eks.oidc_provider_arn | ||
|
||
#--------------------------------------- | ||
# Amazon EKS Managed Add-ons | ||
#--------------------------------------- | ||
eks_addons = { | ||
aws-ebs-csi-driver = { | ||
service_account_role_arn = module.ebs_csi_driver_irsa.iam_role_arn | ||
} | ||
coredns = { | ||
preserve = true | ||
} | ||
vpc-cni = { | ||
preserve = true | ||
} | ||
kube-proxy = { | ||
preserve = true | ||
} | ||
} | ||
|
||
enable_metrics_server = true | ||
enable_cluster_autoscaler = true | ||
|
||
tags = local.tags | ||
} | ||
|
||
#--------------------------------------------------------------- | ||
# IRSA for EBS CSI Driver | ||
#--------------------------------------------------------------- | ||
module "ebs_csi_driver_irsa" { | ||
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks" | ||
version = "~> 5.20" | ||
role_name = format("%s-%s", local.name, "ebs-csi-driver") | ||
attach_ebs_csi_policy = true | ||
oidc_providers = { | ||
main = { | ||
provider_arn = module.eks.oidc_provider_arn | ||
namespace_service_accounts = ["kube-system:ebs-csi-controller-sa"] | ||
} | ||
} | ||
tags = local.tags | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
set -o pipefail | ||
|
||
targets=( | ||
"module.emr_containers" | ||
"module.eks_blueprints_addons" | ||
"module.eks" | ||
"module.mwaa" | ||
) | ||
|
||
#------------------------------------------- | ||
# Helpful to delete the stuck in "Terminating" namespaces | ||
# Rerun the cleanup.sh script to detect and delete the stuck resources | ||
#------------------------------------------- | ||
terminating_namespaces=$(kubectl get namespaces --field-selector status.phase=Terminating -o json | jq -r '.items[].metadata.name') | ||
|
||
# If there are no terminating namespaces, exit the script | ||
if [[ -z $terminating_namespaces ]]; then | ||
echo "No terminating namespaces found" | ||
fi | ||
|
||
for ns in $terminating_namespaces; do | ||
echo "Terminating namespace: $ns" | ||
kubectl get namespace $ns -o json | sed 's/"kubernetes"//' | kubectl replace --raw "/api/v1/namespaces/$ns/finalize" -f - | ||
done | ||
|
||
#------------------------------------------- | ||
# Terraform destroy per module target | ||
#------------------------------------------- | ||
for target in "${targets[@]}" | ||
do | ||
terraform destroy -auto-approve | ||
destroy_output=$(terraform destroy -auto-approve 2>&1) | ||
if [[ $? -eq 0 && $destroy_output == *"Destroy complete!"* ]]; then | ||
echo "SUCCESS: Terraform destroy of $target completed successfully" | ||
else | ||
echo "FAILED: Terraform destroy of $target failed" | ||
exit 1 | ||
fi | ||
done | ||
|
||
#------------------------------------------- | ||
# Terraform destroy full | ||
#------------------------------------------- | ||
terraform destroy -auto-approve | ||
destroy_output=$(terraform destroy -auto-approve 2>&1) | ||
if [[ $? -eq 0 && $destroy_output == *"Destroy complete!"* ]]; then | ||
echo "SUCCESS: Terraform destroy of all targets completed successfully" | ||
else | ||
echo "FAILED: Terraform destroy of all targets failed" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.