#!/bin/bash BASEDIR=$(dirname "$0") nflag=false usage () { echo " -h -- Opens up this help message -t -- Token used for EFS creation -n -- Application namespace "; } options=':t:n:dh' while getopts $options option do case "$option" in t ) FS_TOKEN=${OPTARG-$FS_TOKEN};; n ) nflag=true; APP_NAMESPACE=${OPTARG-$APP_NAMESPACE};; h ) usage; exit;; \? ) echo "Unknown option: -$OPTARG" >&2; exit 1;; : ) echo "Missing option argument for -$OPTARG" >&2; exit 1;; * ) echo "Unimplemented option: -$OPTARG" >&2; exit 1;; esac done ####################################### # Treating parameters FS_TOKEN="$(sed -e 's/[[:space:]]*$//' <<<${FS_TOKEN})" if [ -z "${FS_TOKEN// }" ] then echo "-t nor FS_TOKEN env variable specified. Please inform the token used in the EFS creation..." >&2 exit 99 fi APP_NAMESPACE="$(sed -e 's/[[:space:]]*$//' <<<${APP_NAMESPACE})" if ! $nflag then echo "-n nor APP_NAMESPACE env variable specified, using poc-efs-eks-fargate for k8s application namespace..." >&2 APP_NAMESPACE="poc-efs-eks-fargate" fi # Getting the EFS File System ID FS_ID=`aws efs describe-file-systems \ --creation-token ${FS_TOKEN} \ | jq --raw-output '.FileSystems[] | .FileSystemId'` if [ -z "${FS_ID// }" ]; then echo "EFS File System ID was not found for this file system creation token ${FS_TOKEN}." exit 98 fi echo "Working with EFS File System ID: ${FS_ID}" # Deleting the application components kubectl delete pod poc-app2 -n $APP_NAMESPACE kubectl delete pod poc-app1 -n $APP_NAMESPACE kubectl delete pvc poc-app-pvc -n $APP_NAMESPACE kubectl delete pv poc-app-pv # Deploying the PV needed by validation story cat <