Skip to content

Instantly share code, notes, and snippets.

@MatteoGioioso
Created August 26, 2021 04:51
Show Gist options
  • Save MatteoGioioso/ed6b9c49df69d39ba87e3d70d9e7aaf9 to your computer and use it in GitHub Desktop.
Save MatteoGioioso/ed6b9c49df69d39ba87e3d70d9e7aaf9 to your computer and use it in GitHub Desktop.
Source aws credentials, this could be useful for using AWS in a container
#!/usr/bin/env sh
AWS_PROFILE="${AWS_PROFILE:-default}"
export AWS_ACCESS_KEY_ID=$(sed -nr "/^\[${AWS_PROFILE}\]/ { :l /^aws_access_key_id[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" "$HOME"/.aws/credentials)
export AWS_SECRET_ACCESS_KEY=$(sed -nr "/^\[${AWS_PROFILE}\]/ { :l /^aws_secret_access_key[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" "$HOME"/.aws/credentials)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment