Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan de Jesus committed Apr 5, 2021
0 parents commit 73e95e3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM vault:latest

RUN apk add --update jq

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Vault AWS Action
13 changes: 13 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# action.yml
name: 'Vault Pipeline Auth'
description: 'Retreive aws role credentials using a vault token'
outputs:
access_key:
description: 'access key of role credential set'
secret_key:
description: 'secret key of role credential set'
session_token:
description: 'session token of role credential set'
runs:
using: 'docker'
image: 'Dockerfile'
26 changes: 26 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh -l

set -e

if [ -z "$VAULT_TOKEN" ]; then
echo "VAULT_TOKEN is not set. Quitting."
exit 1
fi

if [ -z "$VAULT_ROLE" ]; then
echo "VAULT_ROLE is not set. Quitting."
exit 1
fi

if [ -z "$VAULT_ADDR" ]; then
VAULT_ADDR=https://vault.24g.dev
fi

vault read -address=$VAULT_ADDR aws/sts/$VAULT_ROLE ttl=30m --format=json >creds.json
AWS_ACCESS_KEY_ID=$(jq -r '.data.access_key' creds.json)
AWS_SECRET_ACCESS_KEY=$(jq -r '.data.secret_key' creds.json)
AWS_SESSION_TOKEN=$(jq -r '.data.security_token' creds.json)

echo "::set-output name=access_key::$AWS_ACCESS_KEY_ID"
echo "::set-output name=secret_key::$AWS_SECRET_ACCESS_KEY"
echo "::set-output name=session_token::$AWS_SESSION_TOKEN"

0 comments on commit 73e95e3

Please sign in to comment.