Working with multiple AWS accounts

Using multiple AWS accounts under an Organization umbrella can be useful even at a personal level, for learning AWS features and self-training, it helps keep various projects partitioned. However, working with multiple accounts at a time can get complex, and on more than one occasion I’ve lost track of which account I’m actually working with.

If you’re working with api keypairs and don’t know which account the keypair is for, the following aws cli command is useful:

aws sts get-caller-identity

It shows you the following info:

{
  "UserId" : ... key id ...,
  "Account" : ... account id ...,
  "Arn" : ... the IAM ARN for the current userid

Samsung Picture by Picture (PBP) screen resolution support with MacOS

I recently just got a 4k Samsung monitor that supports Picture in Picture (PiP) and Picture By Picture (PBP) modes from multiple input sources, which is awesome because I tinker with a bunch of stuff on different machines at the same time. My 2015 MacBook Pro has no problem recognizing the unusual PBP resolution of half the width of a 4k display, but for my older 2008 Mac Pro that I use as my daily driver while I’m at my desk it stretches the resolution vertically which is not good. From this Samsung post here here it mentions the side by side resolution for 2 BPB inputs is 1920 x 2160. That’s definitely not a normal resolution, but the Nvidia web driver in my Mac Pro with a Nvidia 750ti doesn’t offer that resolution:

How to configure PIP/PBP size?

The way round this is to use SwitchResX to define a custom resolution. I’m running Mac OS X 10.11 on this Mac Pro, so I also need to follow these steps to temporarily disable SIP protection first in order to save the configs for the custom resolution.

To set a custom resolution of 1920 x 2160 – here I selected ‘Use simplified settings’ (which disabled a number of settings) and changed only the height/width and left all the other settings as default:

By default this set the vertical sync as 60hz and after rebooting the Display prefs didn’t pick this one up as a valid option. Dropping it to 30hz works through.

I also set a lower res to be more easily readable:

Save from menu bar, then it prompts to reboot to become active. After rebooting, open the Display settings in System Prefs, and now under the Scaled options for the monitor in PBP mode you’ll see the new custom resolutions available:

1920×2160 is almost too tiny to be readable for my eyes, but 1600×1800 is a comfortable resolution.

pip install error inside Docker container: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

Trying to install some Python packages with pip inside a Docker container I ran into this issue:

# pip3 install pytest
Collecting pytest
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7feb52c30630>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/pytest/

At first I thought this something to do with network restrictions since I’m running this on a Linux AWS Workspace, but I have internet access enabled. Running the command on the Workspace itself works as expected, so this is something specific to the Docker container. Next I thought this might be something to do with the specific container image I was using, but after trying a few others I had the same error on any container.

Searching for the error “Failed to establish a new connection: [Errno -3] Temporary failure in name resolution” online I found this question and answer, and suggested to run the Docker container with the host networking option.

So instead of running bash in the container like this:

$ docker run -it tensorflow/tensorflow:1.12.0-py3 bash

Pass in the network=host option like this:

$ docker run --network=host -it tensorflow/tensorflow:1.12.0-py3 bash
# pip3 install pytest
Collecting pytest
  Downloading https://files.pythonhosted.org/packages/b1/ee/53945d50284906adb1e613fabf2e1b8b25926e8676854bb25b93564c0ce7/pytest-6.1.2-py3-none-any.whl (272kB)
    100% |################################| 276kB 9.4MB/s 

Problem solved!