Skip to content

Commit

Permalink
Merge branch 'master' of github.e.it.census.gov:terraform-modules/aws…
Browse files Browse the repository at this point in the history
…-iam-user
  • Loading branch information
badra001 committed Nov 23, 2023
2 parents d076391 + 045eb41 commit 606e7dc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,10 @@

* 2.8.3 -- 2022-09-14
- fix access key variables and usage
<<<<<<< HEAD
- add secret
=======

* 2.8.4 -- 2023-11-22
- if pgp_key_file is not provided (empty), it will use the secret vs encrypted secret, so that the secret can be used as input into other resources
>>>>>>> 045eb41f1a92a7a1d4485246e132fe15d4e2e95d
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ git push

The `variables.auto.tfvars` is there to enable this directory to be used for key rotation with the `rotate-keys.py` script.

## Changes when running plan or apply
You may see a `tf-plan` and a `tf-apply` inform you of changes to two different resources in a directory where you have used
this access key enablement:

* module.NAME.local\_sensitive\_file.access\_key\_file[0]
* module.NAME.null\_resource.access\_key\_file\_decrypt\_key[0]

This is because these resources are populated from `data` sources with a `templatefile()`. As such, it does not know
the output of the template until run time, so it re-generates that data. If there are no changes to the key, it will simple
create these files with the same content as before. This is not harmful, but it is important to understand when you see changes
in a plan you know you didn't make.

## Requirements

No requirements.
Expand Down Expand Up @@ -141,7 +153,7 @@ No requirements.
| Name | Description |
|------|-------------|
| <a name="output_aws_access_key_id"></a> [aws\_access\_key\_id](#output\_aws\_access\_key\_id) | AWS Access Key (current) |
| <a name="output_aws_secret_access_key"></a> [aws\_secret\_access\_key](#output\_aws\_secret\_access\_key) | AWS Secret Access Key [encrypted] (current) |
| <a name="output_aws_secret_access_key"></a> [aws\_secret\_access\_key](#output\_aws\_secret\_access\_key) | AWS Secret Access Key, either encrypted (if using PGP key) or clear |
| <a name="output_user_arn"></a> [user\_arn](#output\_user\_arn) | User ARN |
| <a name="output_user_name"></a> [user\_name](#output\_user\_name) | User name |
| <a name="output_user_password"></a> [user\_password](#output\_user\_password) | User Password |
2 changes: 1 addition & 1 deletion access_keys.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ resource "local_sensitive_file" "access_key_file" {
}

resource "null_resource" "access_key_file_decrypt_key" {
count = var.create_access_keys ? 1 : 0
count = var.create_access_keys && var.pgp_key_file != "" ? 1 : 0
triggers = {
access_keys_directory = var.create_access_keys ? format("%v/%v", path.root, join("", null_resource.rotate_keys_tfvars.*.triggers.access_keys_directory)) : "."
access_key_file = var.create_access_keys ? join("", local_sensitive_file.access_key_file.*.filename) : "empty.txt"
Expand Down
12 changes: 12 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@
* ```
*
* The `variables.auto.tfvars` is there to enable this directory to be used for key rotation with the `rotate-keys.py` script.
*
* ## Changes when running plan or apply
* You may see a `tf-plan` and a `tf-apply` inform you of changes to two different resources in a directory where you have used
* this access key enablement:
*
* * module.NAME.local_sensitive_file.access_key_file[0]
* * module.NAME.null_resource.access_key_file_decrypt_key[0]
*
* This is because these resources are populated from `data` sources with a `templatefile()`. As such, it does not know
* the output of the template until run time, so it re-generates that data. If there are no changes to the key, it will simple
* create these files with the same content as before. This is not harmful, but it is important to understand when you see changes
* in a plan you know you didn't make.
*/

locals {
Expand Down
4 changes: 2 additions & 2 deletions outputs.access_keys.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ output "aws_access_key_id" {
}

output "aws_secret_access_key" {
description = "AWS Secret Access Key [encrypted] (current)"
description = "AWS Secret Access Key, either encrypted (if using PGP key) or clear"
# value = join("", aws_iam_access_key.iam_access_key_v1.*.encrypted_secret)
value = var.create_access_keys ? lookup(aws_iam_access_key.iam_access_key_v1[0], "encrypted_secret", "") : ""
value = var.create_access_keys ? lookup(aws_iam_access_key.iam_access_key_v1[0], "encrypted_secret", "") : lookup(aws_iam_access_key.iam_access_key_v1[0], "secret", "")
}
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.3"
_module_version = "2.8.4"
}

0 comments on commit 606e7dc

Please sign in to comment.