You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Check if SSO session is still valid by trying to export credentials
150
+
local creds=$(aws configure export-credentials --profile "$profile" --format process 2>/dev/null)
151
+
152
+
# If credentials export failed, we need to login
153
+
if [ $?-ne 0 ] || [ -z"$creds" ];then
154
+
echo"SSO session expired or invalid, logging in..."
155
+
aws sso login --sso-session orcid 2>&1| grep -v "Attempting to automatically open\|If the browser does not open\|https://\|Then enter the code\|Successfully logged into"
156
+
157
+
# Try exporting credentials again after login
158
+
creds=$(aws configure export-credentials --profile "$profile" --format process 2>/dev/null)
159
+
160
+
if [ $?-ne 0 ] || [ -z"$creds" ];then
161
+
echo"✗ Failed to export credentials after login"
162
+
return 1
163
+
fi
164
+
fi
165
+
166
+
# Parse the credentials (process format is JSON)
167
+
local access_key=$(echo "$creds"| jq -r '.AccessKeyId')
168
+
local secret_key=$(echo "$creds"| jq -r '.SecretAccessKey')
169
+
local session_token=$(echo "$creds"| jq -r '.SessionToken')
170
+
local expiration=$(echo "$creds"| jq -r '.Expiration')
171
+
172
+
# Write to ~/.aws/credentials as [default] profile (Leapp-style)
173
+
local creds_file=~/.aws/credentials
174
+
175
+
# Create ~/.aws directory if it doesn't exist
176
+
mkdir -p ~/.aws
177
+
178
+
# Backup existing credentials
179
+
if [ -f"$creds_file" ];then
180
+
cp "$creds_file""${creds_file}.bak"
181
+
fi
182
+
183
+
# Remove existing [default] section if it exists
184
+
if grep -q "\[default\]""$creds_file"2>/dev/null;then
185
+
# Remove the [default] section and everything until the next section or EOF
# Prepend new default credentials at the top of the file
191
+
{
192
+
echo"[default]"
193
+
echo"aws_access_key_id = ${access_key}"
194
+
echo"aws_secret_access_key = ${secret_key}"
195
+
echo"aws_session_token = ${session_token}"
196
+
echo"# Profile: ${profile}"
197
+
echo"# Expires: ${expiration}"
198
+
echo""
199
+
cat "$creds_file"2>/dev/null
200
+
} >"${creds_file}.new"
201
+
202
+
mv "${creds_file}.new""$creds_file"
203
+
chmod 600 "$creds_file"
204
+
205
+
# Clear any profile override
206
+
unset AWS_PROFILE
207
+
208
+
echo"✓ Switched to AWS profile: $profile"
209
+
echo"✓ Credentials written to ~/.aws/credentials as [default]"
210
+
echo"✓ Credentials expire: $expiration"
211
+
}
212
+
213
+
# Simpler environment-only version
214
+
sk-aws-sso-env(){
215
+
local profile="${1:-orcid-int}"
216
+
217
+
aws sso login --profile "$profile"2>&1| grep -v "Attempting to automatically open\|If the browser does not open\|https://\|Then enter the code\|Successfully logged into"||return 1
Copy file name to clipboardExpand all lines: lib/sys.sh
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,13 @@ alias pc="pre-commit"
7
7
alias pci="pre-commit install"
8
8
alias pca="sk-pre-commit-all"
9
9
10
+
# FIXME: migrate to asdf
11
+
sk-goreplay(){
12
+
sk_help_noarg "$FUNCNAME: run and install goreplay tool. Example args --input-file solr_09_30_outage.log --output-http http://localhost:8983 ""$@"&&return
13
+
sk-pack-install -b ror -r https://github.com/buger/goreplay/releases/download/1.3.3/gor_1.3.3_amd64.deb -o deb
0 commit comments