Skip to content

Instantly share code, notes, and snippets.

@glennschler
Last active July 23, 2021 00:30
Show Gist options
  • Save glennschler/1bae837a85fd43e322abd217e9fd75a5 to your computer and use it in GitHub Desktop.
Save glennschler/1bae837a85fd43e322abd217e9fd75a5 to your computer and use it in GitHub Desktop.
Algo VPN
#!/usr/bin/env bash
set -e
# Get secrets from ansible vault
ec2credentials=$(ansible-vault view ./aws-secrets.vault.yml | sed -E "s/aws_access_key = ([^ ]+)|aws_secret_key = ([^ ]+)|aws_mfa_serial = ([^ ]+)/\1\2\3/g")
export AWS_ACCESS_KEY_ID=$(echo $ec2credentials | cut -d' ' -f1)
export AWS_SECRET_ACCESS_KEY=$(echo $ec2credentials | cut -d' ' -f2)
exec ./algo $1 -e "aws_mfa_serial=$(echo $ec2credentials | cut -d' ' -f3)"
# have the algo playbook prompt for the vault password
# vault should store the aws secrets
./algo --vault-id @prompt -e @vars/aws_secrets.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment