Skip to content
Merged
Changes from 1 commit
Commits
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
23 changes: 15 additions & 8 deletions test/deploy-eks-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ if [[ -z "${EKS_CLUSTER_K8_VERSION}" ]]; then
fi

function deleteCluster() {
echo "Cleanup role, security-group, open-id ${TEST_CLUSTER_NAME}"
rolename=$(echo ${TEST_CLUSTER_NAME} | awk -F- '{print "EBS_" $(NF-1) "_" $(NF)}')
role_attached_policies=$(aws iam list-attached-role-policies --role-name $rolename --query 'AttachedPolicies[*].PolicyArn' --output text)
for policy_arn in ${role_attached_policies};
do
aws iam detach-role-policy --role-name ${rolename} --policy-arn ${policy_arn}
done

aws iam delete-role --role-name ${rolename}
oidc_id=$(aws eks describe-cluster --name ${TEST_CLUSTER_NAME} --query "cluster.identity.oidc.issuer" --output text | cut -d '/' -f 5)
aws iam delete-open-id-connect-provider --open-id-connect-provider-arn arn:aws:iam::${account_id}:oidc-provider/${oidc_id}
security_group_id=$(aws eks describe-cluster --name ${TEST_CLUSTER_NAME} --query "cluster.resourcesVpcConfig.securityGroupIds[0]" --output text)
aws ec2 delete-security-group --group-id ${security_group_id}
echo "Cleanup remaining PVC on the EKS Cluster ${TEST_CLUSTER_NAME}"

echo "Cleanup remaining PVC on the EKS Cluster ${TEST_CLUSTER_NAME}"
tools/cleanup.sh
NODE_GROUP=$(eksctl get nodegroup --cluster=${TEST_CLUSTER_NAME} | sed -n 4p | awk '{ print $2 }')
Expand All @@ -35,14 +50,6 @@ function deleteCluster() {
echo "Unable to delete cluster - ${TEST_CLUSTER_NAME}"
return 1
fi
rolename=$(echo ${TEST_CLUSTER_NAME} | awk -F- '{print "EBS_" $(NF-1) "_" $(NF)}')
role_attached_policies=$(aws iam list-attached-role-policies --role-name $rolename --query 'AttachedPolicies[*].PolicyArn' --output text)
for policy_arn in ${role_attached_policies};
do
aws iam detach-role-policy --role-name ${rolename} --policy-arn ${policy_arn}
done

aws iam delete-role --role-name ${rolename}

return 0
}
Expand Down