Skip to content
This repository has been archived by the owner on Jun 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #106 from otakup0pe/aws-creds-template
Browse files Browse the repository at this point in the history
add a builtin aws credentials file template
  • Loading branch information
otakup0pe authored Jun 13, 2017
2 parents bc555e4 + 882ea0a commit 690019a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aomi/templates/aws-credentials-help.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: AWS Credentials Profile
help: This template will generate an AWS credentials file compatible with the CLI and other supported tools. The profile will be named as the AWS path, without the sts/creds element, joined by underscores. Note that any/all hyphens in the path will also be converted to underscores. Also note that this template is really only suitable for AWS secret backends.
16 changes: 16 additions & 0 deletions aomi/templates/aws-credentials.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% set w_account = {"hax": ""} -%}
{% for key, secret in aomi_items.iteritems() -%}
{% set path_bits = key.split("_") -%}
{% set account = path_bits[0:path_bits|length - 2] -%}
{% set key = path_bits[path_bits|length - 2] -%}
{% if account != w_account.hax -%}
{% if w_account.update({"hax": account}) -%}# terrible hacks https://stackoverflow.com/questions/9486393/jinja2-change-the-value-of-a-variable-inside-a-loop{% endif -%}
[{{account|reject("equalto", "creds")|reject("equalto", "sts")|join("_")}}]
{% endif -%}
{% if key == "access" -%}
aws_access_key_id = {{secret}}
{% endif -%}
{% if key == "secret" -%}
aws_secret_access_key = {{secret}}
{% endif -%}
{% endfor -%}

0 comments on commit 690019a

Please sign in to comment.