Skip to content

Commit

Permalink
use templatefile function instead of data resource (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: cloudpossebot <[email protected]>
  • Loading branch information
moperacz and cloudpossebot authored Jul 21, 2022
1 parent 343506e commit f31641c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ Available targets:
| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 2.0 |
| <a name="provider_template"></a> [template](#provider\_template) | >= 2.0 |

## Modules

Expand All @@ -174,8 +173,6 @@ Available targets:
| [aws_iam_user.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |
| [aws_iam_user_group_membership.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_group_membership) | resource |
| [aws_iam_user_login_profile.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |
| [template_file.keybase_password_decrypt_command](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
| [template_file.keybase_password_pgp_message](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |

## Inputs

Expand Down
3 changes: 0 additions & 3 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 2.0 |
| <a name="provider_template"></a> [template](#provider\_template) | >= 2.0 |

## Modules

Expand All @@ -28,8 +27,6 @@
| [aws_iam_user.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |
| [aws_iam_user_group_membership.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_group_membership) | resource |
| [aws_iam_user_login_profile.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_login_profile) | resource |
| [template_file.keybase_password_decrypt_command](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
| [template_file.keybase_password_pgp_message](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |

## Inputs

Expand Down
22 changes: 2 additions & 20 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,6 @@ resource "aws_iam_user_group_membership" "default" {
locals {
encrypted_password = join("", aws_iam_user_login_profile.default.*.encrypted_password)
pgp_key_is_keybase = length(regexall("keybase:", var.pgp_key)) > 0 ? true : false
keybase_password_pgp_message = join("", data.template_file.keybase_password_pgp_message.*.rendered)
keybase_password_decrypt_command = join("", data.template_file.keybase_password_decrypt_command.*.rendered)
}

data "template_file" "keybase_password_decrypt_command" {
count = local.pgp_key_is_keybase ? 1 : 0
template = file("${path.module}/templates/keybase_password_decrypt_command.sh")

vars = {
encrypted_password = local.encrypted_password
}
}

data "template_file" "keybase_password_pgp_message" {
count = local.pgp_key_is_keybase ? 1 : 0
template = file("${path.module}/templates/keybase_password_pgp_message.txt")

vars = {
encrypted_password = local.encrypted_password
}
keybase_password_pgp_message = local.pgp_key_is_keybase ? templatefile("${path.module}/templates/keybase_password_pgp_message.txt", { encrypted_password = local.encrypted_password }) : ""
keybase_password_decrypt_command = local.pgp_key_is_keybase ? templatefile("${path.module}/templates/keybase_password_decrypt_command.sh", { encrypted_password = local.encrypted_password }) : ""
}

0 comments on commit f31641c

Please sign in to comment.