Skip the AWS_PROFILE= on ECR docker pulls

Uncategorized No Comments »

I keep forgetting to set AWS_PROFILE=production for every docker pull, and I feel dumb when I forget.

Stopping to bang my head on the desk really breaks the “flow state”

…so I did this:

With a .aws/config that looks like:

[profile production]
...
sso_account_id = 234567890123
...
[profile staging]
...
sso_account_id = 123456789012
...

I configured my .docker/config.json like this:

"credHelpers": {
    "123456789012.dkr.ecr.us-west-2.amazonaws.com": "aws-profile-staging",
    "234567890123.dkr.ecr.us-east-2.amazonaws.com": "aws-profile-production"
  },

Finally, a wrapper that looks like this:

#!/bin/bash
# Name this script "docker-credential-aws-profile-{PROFILE}" in the same dir

# trim off the "docker-credential-aws-profile-", 31 chars, keep suffix
export AWS_PROFILE="$(basename $0 |cut -c31-)"

# "ecr-login" is conventionally a binary in PATH "docker-credential-ecr-login"
$(dirname $0)/docker-credential-ecr-login "$@"

So now, when I do a docker pull 123456789012.dkr.ecr.us-west-2.amazonaws.com/images/bazel:5.3.2, docker looks for the credential helper, sees “aws-profile-staging” remaps to /usr/bin/docker-credential-aws-profile-production, which converts the name to “production” and passes execution to /usr/bin/docker-credential-ecr-login with the proper setting for AWS_PROFILE matching my AWS profile. This works the same as if all my credHelpers were “eco-login”, but I don’t need to give the redundant AWS_PROFILE. docker-credential-ecr-login returns the creds from my current active login with AWS, which passes back through the stack to docker, which should cache the value globally for my user across all my shells/terminals rather than being inconsistent.

Works in Bazel too, and shouldn’t add entropy to env to disrupt cache.

Vim Autocommands

Uncategorized No Comments »

I started using “vi” because it was everywhere, and worked out-of-the-box. It acted the same regardless which server I got to, and even on embedded systems, that’s been fairly consistent.

Emacs was complex, consumed massive memory (“Emacs is an OS”)(“Due to RAM contention on shared systems, USL engineers will not use Emacs”) and it required this configuration out-of-the-box to get anything done.

Whelp, it seems I”ve become enamored with Vi (Vim) configuration. Minimally. I can quit anytime. Honest.

:autocmd BufRead,BufNewFile   *.py      set ts=4 sts=4 sw=4 tw=99 et ai ff=unix

Expanded, this auto-sets Python options to be:

  • tabstop=4
  • softtabstop=4
  • shiftwidth=4
  • textwidth=99 (word-wrap after)
  • expandtab (tabs -> spaces)
  • autoindent
  • fileformat=unix

I’m a bit embarrassed that I haven’t looked into this until now, I kinda didn’t feel the need. Today has been frustrating, so I think this issue has been painted with The Angry Brush for the day.

Anger has a blast radius; I’m using it to fix my editor. Ever so slightly.

Document Accumulation and Indexing

Uncategorized No Comments »