Skip to content
Snippets Groups Projects
Commit bfd0700a authored by nimrod's avatar nimrod
Browse files

Refactor AWS-CLI aliases.

- Add region alias for configured (profile) region.
- Add metadata-region for outputting the region from the EC2 metadata
service, moved from .bashrc (no longer exported as AWS_DEFAULT_REGION,
not an issue since it could only be used in EC2 instances and not for
local use, it was there mainly as a reminder for me).
- Add ecr-login instead of a shell alias, works the same.
parent a5a3b85e
No related branches found
No related tags found
No related merge requests found
[toplevel]
whoami = sts get-caller-identity
region = configure get region
ecr-login = !$(aws ecr get-login --no-include-email)
metadata-region = !python3 << EOF
from urllib.request import urlopen
import json
response = urlopen('http://169.254.169.254/latest/dynamic/instance-identity/document')
print(json.loads(response.read().decode('utf-8'))['region'])
EOF
......@@ -67,7 +67,6 @@ alias ansible-local='ansible localhost -c local -i localhost,'
alias ansible-local-playbook='ansible-playbook -i localhost, -c local'
alias concat="perl -pe 's/\\n/\\\\n/g'"
alias deconcat="perl -pe 's/\\\\n/\\n/g'"
alias ecr-login='eval $(aws ecr get-login --no-include-email)'
alias hostlocal='docker run --rm --privileged --net=host gliderlabs/hostlocal'
alias cadvisor='docker run --rm --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --volume=/dev/disk/:/dev/disk:ro --publish=8080:8080 --detach=true --name=cadvisor google/cadvisor:latest'
alias apt-daily="monitor __apt-daily"
......@@ -173,18 +172,6 @@ cyan () {
printf '\e[0m' || true
}
deduce_aws_region () {
AWS_DEFAULT_REGION="$(python3 << EOF
from urllib.request import urlopen
import json
response = urlopen('http://169.254.169.254/latest/dynamic/instance-identity/document')
print(json.loads(response.read().decode('utf-8'))['region'])
EOF
)"
export AWS_DEFAULT_REGION
echo "$AWS_DEFAULT_REGION"
}
ssh_keyscan_add () {
ssh-keyscan "$@" >> "$HOME/.ssh/known_hosts"
sort -uo "$HOME/.ssh/known_hosts" "$HOME/.ssh/known_hosts"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment