Skip to content

Instantly share code, notes, and snippets.

@scottarthur
scottarthur / ccgcp.fish
Last active March 19, 2019 15:03
Rewrite AWS creds with Staff Access clipboard in 🐟shell
# Usage: click the `Export` button on the staff access credentials page, and then immediately run this script. It does the following:
# 1. Sets an env var (`AWS_CODECOMMIT_PROFILE` below) that determines what AWS profile from ~/.aws/config is used
# 2. Rewrites the last 3 lines of your ~/.aws/credentials file with the new credentials (be sure the creds you want to change are at the bottom of your current credential file!)
#
# requirements: be on a mac, use Fish shell, `brew install coreutils`
function ccgcp --description 'Saves the Staff Access AWS keys in your clipboard to ~/.aws/credentials'
# Don't continue unless clipboard has the creds export command in it
if ! pbpaste | string match -r "export AWS_ACCESS_KEY_ID.*"
echo "Clipboard didn't have credentials"
return 1
@scottarthur
scottarthur / kludge.sh
Created December 19, 2018 02:03
PCSK AWS key clipboard ~> ~./aws/credentials
function ccgcp () {
# Don't continue unless clipboard has the creds export command in it
if [[ ! $(pbpaste) =~ "export AWS_ACCESS_KEY_ID.*" ]]; then
echo "Clipboard didn't have credentials"
return
fi
$(pbpaste)
export AWS_CODECOMMIT_PROFILE=Terraform-GCP
# remove last three lines of file (old creds)
for i in {0..2}; do

Keybase proof

I hereby claim:

  • I am scottarthur on github.
  • I am scottarthur (https://keybase.io/scottarthur) on keybase.
  • I have a public key ASBc7Dl1dJD_1bCbBwzqAoAeEWbRf_fQou5YAjeTfUo6igo

To claim this, I am signing this object:

@scottarthur
scottarthur / s3curl.sh
Created November 29, 2016 17:09
Script to pull file from S3 via curl. Adapted from https://curl.haxx.se/mail/archive-2014-10/0006.html
#!/bin/bash
set -x
file='thirdparty/pool/main/d/datadog-agent/datadog-agent_1%3a5.10.0-1_amd64.deb'
bucket='sfdc-matrix-aptrepo'
resource="/${bucket}/${file}"
contentType="application/x-debian-package"
dateValue="`date +'%a, %d %b %Y %H:%M:%S %z'`"
stringToSign="GET
${contentType}
${dateValue}