Skip to content

Commit

Permalink
use TFCOMMAND or git-root .tf-control
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed May 21, 2022
1 parent 831e208 commit 531fab7
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 12 deletions.
27 changes: 17 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
# Versions

* v1.0.0
## Version 1.x

* 1.0.0
- tag initial release for tf 0.11

* v2.0.0
## Version 2.x

* 2.0.0
- for tf-0.12 support

* v2.0.1
* 2.0.1
- add create_access_key variable, but do not implement
- format
- change saml_role to list

* v2.0.2
* 2.0.2
- do not include groups if groups empty
- add ```service_account``` variable (true|false)
- if service account, use contact vs user

* v2.1
* 2.1
- add pre-commit to generate docs

* v2.2
* 2.2
- add enable_sending_mail to enable email address in SES (this generates a request to the user)

* v2.3
* 2.3
- change default for enable_sending_mail to false

* v2.4.0 -- 20210405
* 2.4.0 -- 20210405
- use `ldap-get-attribute` to get email address

* v2.5.0 -- 20210512
* 2.5.0 -- 20210512
- add `attached_policies` to enable adding policies for an IAM account (generally, just services)

* v2.5.1 -- 20210526
* 2.5.1 -- 20210526
- change computing of output of user_password

* 2.6.0 -- 2022-05-20
- update bin/show-user-info.sh to accept TFCOMMAND for an alternate terraform binary, or to pull from the git root file
49 changes: 48 additions & 1 deletion bin/show-user-info.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/bash

get_git_root()
{
TOP=$(git rev-parse --show-toplevel 2>/dev/null)
if [ -z "$TOP" ]
then
TOP=$HOME
fi
}

VERSION="1.1.0"
if [ ! -x /usr/bin/jq ]
then
echo "* no 'jq' program installed, cannot execute"
Expand All @@ -19,7 +29,44 @@ fi
VARS="user_name user_arn user_password"
declare -A values

jsondata=$(terraform output -json $MODULE)
# path or name of terraform binary
# get from top of git repo or $HOME/.tf-control
get_git_root
if [ -z "$TFCONTROL" ]
then
if [ -r $TOP/.tf-control ]
then
TFCONTROL=$TOP/.tf-control
elif [ -r $HOME/.tf-control ]
then
TFCONTROL=$HOME/.tf-control
fi
fi
if [ ! -z "$TFCONTROL" ]
then
source $TFCONTROL
fi

if [ -z $TFCOMMAND ]
then
TFCOMMAND="terraform"
fi

# look for config file
if [ -z "$TF_CLI_CONFIG_FILE" ]
then
if [ -r $TOP/.tf-control.tfrc ]
then
export TF_CLI_CONFIG_FILE=$TOP/.tf-control.tfrc
elif [ -r $HOME/.tf-control.tfrc ]
then
export TF_CLI_CONFIG_FILE=$HOME/.tf-control.tfrc
else
unset TF_CLI_CONFIG_FILE
fi
fi

jsondata=$($TERRAFORM output -json $MODULE)
echo "# $(date +%Y%m%d)"
for k in $VARS
do
Expand Down
2 changes: 1 addition & 1 deletion version.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
locals {
_module_version = "2.5.1"
_module_version = "2.6.0"
}

0 comments on commit 531fab7

Please sign in to comment.