Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignores password_reset_required change to support changes in AWS provider 4.x #24

Merged
merged 4 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ version-resolver:
- 'bugfix'
- 'bug'
- 'hotfix'
- 'no-release'
default: 'minor'

categories:
Expand Down
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
":preserveSemverRanges"
],
"labels": ["auto-update"],
"dependencyDashboardAutoclose": true,
"enabledManagers": ["terraform"],
"terraform": {
"ignorePaths": ["**/context.tf", "examples/**"]
}
}

18 changes: 18 additions & 0 deletions examples/complete/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
terraform {
required_version = ">= 0.13.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 2.0"
}
template = {
source = "hashicorp/template"
version = ">= 2.0"
}
null = {
source = "hashicorp/null"
version = ">= 2.0"
}
}
}
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ resource "aws_iam_user_login_profile" "default" {
password_length = var.password_length
password_reset_required = var.password_reset_required
depends_on = [aws_iam_user.default]

lifecycle {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... Does adding the lifecycle block force a recreate of this resource? What does that do for existing IAM users that you're managing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After upgrade of AWS provider to 4.x (in our case - to 4.21, without any change to root module configuration or terraform vars) the resource was forced to recreate:

  # module.users["veronika_gnilitska"].aws_iam_user_login_profile.default[0] must be replaced
-/+ resource "aws_iam_user_login_profile" "default" {
      ~ encrypted_password      = "wcBMAwEF3O2PIAyrAQgAvoQ6klRbbQ705f0Pj6l9uf4C/9GOdVfiEqmBkendM3dKPRkbbcJVXRP80xaTkElae17OiS69QJVji3/sS3ru2TLnFyZcNtSMayu9sodi2VDbNOhN6FRywuv9OBkBcgDu7686pOZLG27H2zT7V18sBwYR6bDaUepnLtDLq" -> (known after apply)
      ~ id                      = "veronika.gnilitska" -> (known after apply)
      ~ key_fingerprint         = "92f19546ec0f7d7ca8f9d" -> (known after apply)
      + password                = (known after apply)
      ~ password_reset_required = false -> true # forces replacement
        # (3 unchanged attributes hidden)
    }

If you apply this plan you won't be able to login with the credentials used before the apply. To avoid this behaviour for existing users - lifecycle was used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gowiem thank you! 💯

ignore_changes = [password_reset_required]
}
}

resource "aws_iam_user_group_membership" "default" {
Expand Down