Skip to content

Commit

Permalink
- fix create_profile to edit census-do1 to do2-govcloud
Browse files Browse the repository at this point in the history
- generate only if access_keys enabled
  • Loading branch information
badra001 committed Aug 12, 2022
1 parent d0cb8b7 commit 0aa9a02
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@

* 2.8.0 -- 2022-08-01
- add create-profile.USERNAME.sh generation

* 2.8.1 -- 2022-08-12
- fix create_profile to edit census-do1 to do2-govcloud
- generate only if access_keys enabled
10 changes: 10 additions & 0 deletions access_keys.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,13 @@ resource "null_resource" "access_key_file_decrypt_key" {
command = "${path.module}/bin/decrypt-secret-key.sh ${self.triggers.access_key_file}"
}
}
resource "local_sensitive_file" "user_create_profile" {
count = var.create_access_keys ? 1 : 0
filename = format("%v/access_keys/%v/create-profile.sh", path.root, aws_iam_user.user.name)
file_permission = "0755"
content = templatefile("${path.module}/templates/create-profile.sh.tpl", {
username = aws_iam_user.user.name
source_profile = local.profile
source_region = local.region
})
}
10 changes: 0 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,3 @@ resource "aws_iam_user_policy" "user_policy" {
user = aws_iam_user.user.name
policy = each.value
}

resource "local_sensitive_file" "user_create_profile" {
filename = format("%v/access_keys/%v/create-profile.sh", path.root, aws_iam_user.user.name)
file_permission = "0755"
content = templatefile("${path.module}/templates/create-profile.sh.tpl", {
username = aws_iam_user.user.name
source_profile = local.profile
source_region = local.region
})
}
5 changes: 4 additions & 1 deletion templates/create-assumerole-profile.sh.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION="1.0.2"
VERSION="1.0.3"
SOURCE_PROFILE=$1
if [ -z "$SOURCE_PROFILE" ]
then
Expand All @@ -12,6 +12,9 @@ then
USER="${username}"
fi

# fixup source profile census-do1 -> do2-govcloud
SOURCE_PROFILE=$(echo $SOURCE_PROFILE | sed -e 's/census-do1$/do2-govcloud/')

%{ for group,arn in groups ~}
NEW_PROFILE="${profile_prefix}-${group}"
if [ $(aws configure list-profiles | grep -c ^$NEW_PROFILE$) == 0 ]
Expand Down
5 changes: 4 additions & 1 deletion templates/create-profile.sh.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION="1.0.1"
VERSION="1.0.2"
SOURCE_PROFILE=$1
if [ -z "$SOURCE_PROFILE" ]
then
Expand All @@ -23,6 +23,9 @@ then
exit 1
fi

# fixup source profile census-do1 -> do2-govcloud
SOURCE_PROFILE=$(echo $SOURCE_PROFILE | sed -e 's/census-do1$/do2-govcloud/')

aws_access_key_id=$( grep ^access_key_id: $FILE | sed -e 's/^.*: *//')
aws_secret_access_key=$( grep ^access_secret_key: $FILE | sed -e 's/^.*: *//')

Expand Down
2 changes: 1 addition & 1 deletion version.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
locals {
_module_name = "aws-iam-user"
_module_version = "2.8.0"
_module_version = "2.8.1"
}

0 comments on commit 0aa9a02

Please sign in to comment.