Skip to content

Commit

Permalink
initial changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Bostrom committed Jan 11, 2024
1 parent 45ccd89 commit 86f5f86
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions create-k8s-chained-sessions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function createLeappSession {
parent_session_name=$1
parent_role_name=$2
chained_role_name=$3
k8s_version=$4
# check if the parent session exists for the role. We do this because
# regular developers won't have the AWSAdministratorAccess role, so we
# don't want to create a chained session for them.
Expand All @@ -30,22 +31,22 @@ function createLeappSession {
return
fi

chained_session_name="${parent_session_name}-${chained_role_name}"
chained_session_name="${parent_session_name}-${chained_role_name}-${k8s_version}"

green_echo " looking for existing session ${chained_session_name}"
chained_session_id=$(leappSessionId "$chained_session_name" "$chained_role_name")
chained_session_id=$(leappSessionId "$chained_session_name" "${chained_role_name}-${k8s_version}")

if [[ -z "${chained_session_id}" ]]; then
green_echo " no existing session found; starting session for ${parent_session_name} to get role arn"

# use the parent session to get the role arn
# so we don't have to hard-code account ids
leapp session start --sessionId "$parent_session_id" > /dev/null 2> >(logStdErr)
role_arn=$(aws iam get-role --role-name "$chained_role_name" --query Role.Arn | tr -d '"')
role_arn=$(aws iam get-role --role-name "${chained_role_name}-${k8s_version}" --query Role.Arn | tr -d '"')
leapp session stop --sessionId "$parent_session_id" > /dev/null 2> >(logStdErr)

green_echo " creating new profile"
profile_id=$(createLeappProfile "$parent_session_name")
profile_id=$(createLeappProfile "${parent_session_name}-${chained_role_name}")

green_echo " creating new session"
leapp session add --providerType aws --sessionType awsIamRoleChained \
Expand Down Expand Up @@ -90,7 +91,8 @@ PARENT_SESSION_NAMES="panorama-k8s-playground panorama-k8s-playground-2 panorama

for session in $PARENT_SESSION_NAMES
do
createLeappSession "$session" "AWSAdministratorAccess" "eks-admin-1.24"
createLeappSession "$session" "PanoramaK8sEngineeringDefault" "panorama-dev-writer-1.24"
createLeappSession "$session" "PanoramaK8sEngineeringDefault" "panorama-dev-reader-1.24"
createLeappSession "$session" "AWSAdministratorAccess" "eks" "admin" "1.24"
createLeappSession "$session" "PanoramaK8sEngineeringDefault" "panorama" "dev-writer" "1.24"
createLeappSession "$session" "PanoramaK8sEngineeringDefault" "panorama" "dev-reader" "1.24"
createLeappSession "$session" "PanoramaK8sDSAR" "panorama" "dsar-tester" "1.24"
done

0 comments on commit 86f5f86

Please sign in to comment.