Skip to content

Commit bb408f8

Browse files
authored
fix: issue-1776 - adjustment to accommodate new users with the password reset issue (#554)
* managing user endpoint lifecycle differently for password * fix: accommodate brand new user circumstance with 1776 fix * chore: dedupe from merge
1 parent 72ed66f commit bb408f8

File tree

22 files changed

+74
-42
lines changed

22 files changed

+74
-42
lines changed

aws-github/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ projects:
1515
terraform_version: 1.3.8
1616
autoplan:
1717
enabled: true
18-
when_modified: ['**/*.tf', '*.tf*']
18+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1919
- dir: terraform/vault
2020
terraform_version: 1.3.8
2121
autoplan:

aws-github/terraform/users/modules/user/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ resource "random_password" "password" {
2525
}
2626

2727
resource "vault_generic_endpoint" "user" {
28+
depends_on = [ vault_generic_endpoint.user_password ] # avoids race condition
2829
path = "auth/userpass/users/${var.username}"
2930
ignore_absent_fields = true
3031

@@ -43,11 +44,13 @@ resource "vault_generic_endpoint" "user_password" {
4344
ignore_changes=[data_json]
4445
}
4546

46-
# note: this resource only manages the user's initial password and has a lifecycle policy to
47-
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
47+
# note: this resource includes the initial password and only gets applied once
48+
# changes to the user should be managed by the vault_generic_endpoint named "user" above
4849
data_json = jsonencode(
4950
{
50-
password = var.initial_password != "" ? var.initial_password : random_password.password.result
51+
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
52+
policies = var.acl_policies,
53+
token_ttl = "1h"
5154
}
5255
)
5356
}

aws-gitlab/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ projects:
1515
terraform_version: 1.3.8
1616
autoplan:
1717
enabled: true
18-
when_modified: ['**/*.tf', '*.tf*']
18+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1919
- dir: terraform/vault
2020
terraform_version: 1.3.8
2121
autoplan:

aws-gitlab/terraform/users/modules/user/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ resource "random_password" "password" {
3434
}
3535

3636
resource "vault_generic_endpoint" "user" {
37+
depends_on = [ vault_generic_endpoint.user_password ] # avoids race condition
3738
path = "auth/userpass/users/${var.username}"
3839
ignore_absent_fields = true
3940

@@ -52,11 +53,13 @@ resource "vault_generic_endpoint" "user_password" {
5253
ignore_changes=[data_json]
5354
}
5455

55-
# note: this resource only manages the user's initial password and has a lifecycle policy to
56-
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
56+
# note: this resource includes the initial password and only gets applied once
57+
# changes to the user should be managed by the vault_generic_endpoint named "user" above
5758
data_json = jsonencode(
5859
{
59-
password = var.initial_password != "" ? var.initial_password : random_password.password.result
60+
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
61+
policies = var.acl_policies,
62+
token_ttl = "1h"
6063
}
6164
)
6265
}

civo-github/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ projects:
1515
terraform_version: 1.3.8
1616
autoplan:
1717
enabled: true
18-
when_modified: ['**/*.tf', '*.tf*']
18+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1919
- dir: terraform/vault
2020
terraform_version: 1.3.8
2121
autoplan:

civo-github/terraform/users/modules/user/github/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ resource "random_password" "password" {
2525
}
2626

2727
resource "vault_generic_endpoint" "user" {
28+
depends_on = [ vault_generic_endpoint.user_password ] # avoids race condition
2829
path = "auth/userpass/users/${var.username}"
2930
ignore_absent_fields = true
3031

@@ -43,11 +44,13 @@ resource "vault_generic_endpoint" "user_password" {
4344
ignore_changes=[data_json]
4445
}
4546

46-
# note: this resource only manages the user's initial password and has a lifecycle policy to
47-
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
47+
# note: this resource includes the initial password and only gets applied once
48+
# changes to the user should be managed by the vault_generic_endpoint named "user" above
4849
data_json = jsonencode(
4950
{
50-
password = var.initial_password != "" ? var.initial_password : random_password.password.result
51+
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
52+
policies = var.acl_policies,
53+
token_ttl = "1h"
5154
}
5255
)
5356
}

civo-gitlab/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ projects:
1515
terraform_version: 1.3.8
1616
autoplan:
1717
enabled: true
18-
when_modified: ['**/*.tf', '*.tf*']
18+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1919
- dir: terraform/vault
2020
terraform_version: 1.3.8
2121
autoplan:

civo-gitlab/terraform/users/modules/user/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ resource "random_password" "password" {
3434
}
3535

3636
resource "vault_generic_endpoint" "user" {
37+
depends_on = [ vault_generic_endpoint.user_password ] # avoids race condition
3738
path = "auth/userpass/users/${var.username}"
3839
ignore_absent_fields = true
3940

@@ -52,11 +53,13 @@ resource "vault_generic_endpoint" "user_password" {
5253
ignore_changes=[data_json]
5354
}
5455

55-
# note: this resource only manages the user's initial password and has a lifecycle policy to
56-
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
56+
# note: this resource includes the initial password and only gets applied once
57+
# changes to the user should be managed by the vault_generic_endpoint named "user" above
5758
data_json = jsonencode(
5859
{
59-
password = var.initial_password != "" ? var.initial_password : random_password.password.result
60+
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
61+
policies = var.acl_policies,
62+
token_ttl = "1h"
6063
}
6164
)
6265
}

digitalocean-github/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ projects:
1515
terraform_version: 1.3.8
1616
autoplan:
1717
enabled: true
18-
when_modified: ['**/*.tf', '*.tf*']
18+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1919
- dir: terraform/vault
2020
terraform_version: 1.3.8
2121
autoplan:

digitalocean-github/terraform/users/modules/user/github/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ resource "random_password" "password" {
2525
}
2626

2727
resource "vault_generic_endpoint" "user" {
28+
depends_on = [ vault_generic_endpoint.user_password ] # avoids race condition
2829
path = "auth/userpass/users/${var.username}"
2930
ignore_absent_fields = true
3031

@@ -43,11 +44,13 @@ resource "vault_generic_endpoint" "user_password" {
4344
ignore_changes=[data_json]
4445
}
4546

46-
# note: this resource only manages the user's initial password and has a lifecycle policy to
47-
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
47+
# note: this resource includes the initial password and only gets applied once
48+
# changes to the user should be managed by the vault_generic_endpoint named "user" above
4849
data_json = jsonencode(
4950
{
50-
password = var.initial_password != "" ? var.initial_password : random_password.password.result
51+
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
52+
policies = var.acl_policies,
53+
token_ttl = "1h"
5154
}
5255
)
5356
}

digitalocean-gitlab/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ projects:
1515
terraform_version: 1.3.8
1616
autoplan:
1717
enabled: true
18-
when_modified: ['**/*.tf', '*.tf*']
18+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1919
- dir: terraform/vault
2020
terraform_version: 1.3.8
2121
autoplan:

digitalocean-gitlab/terraform/users/modules/user/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ resource "random_password" "password" {
3434
}
3535

3636
resource "vault_generic_endpoint" "user" {
37+
depends_on = [ vault_generic_endpoint.user_password ] # avoids race condition
3738
path = "auth/userpass/users/${var.username}"
3839
ignore_absent_fields = true
3940

@@ -52,11 +53,13 @@ resource "vault_generic_endpoint" "user_password" {
5253
ignore_changes=[data_json]
5354
}
5455

55-
# note: this resource only manages the user's initial password and has a lifecycle policy to
56-
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
56+
# note: this resource includes the initial password and only gets applied once
57+
# changes to the user should be managed by the vault_generic_endpoint named "user" above
5758
data_json = jsonencode(
5859
{
59-
password = var.initial_password != "" ? var.initial_password : random_password.password.result
60+
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
61+
policies = var.acl_policies,
62+
token_ttl = "1h"
6063
}
6164
)
6265
}

gcp-github/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ projects:
1515
terraform_version: 1.3.8
1616
autoplan:
1717
enabled: true
18-
when_modified: ['**/*.tf', '*.tf*']
18+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1919
- dir: terraform/vault
2020
terraform_version: 1.3.8
2121
autoplan:

gcp-github/terraform/users/modules/user/github/main.tf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ resource "random_password" "password" {
2525
}
2626

2727
resource "vault_generic_endpoint" "user" {
28+
depends_on = [ vault_generic_endpoint.user_password ] # avoids race condition
2829
path = "auth/userpass/users/${var.username}"
2930
ignore_absent_fields = true
3031

@@ -43,15 +44,19 @@ resource "vault_generic_endpoint" "user_password" {
4344
ignore_changes=[data_json]
4445
}
4546

46-
# note: this resource only manages the user's initial password and has a lifecycle policy to
47-
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
47+
# note: this resource includes the initial password and only gets applied once
48+
# changes to the user should be managed by the vault_generic_endpoint named "user" above
4849
data_json = jsonencode(
4950
{
50-
password = var.initial_password != "" ? var.initial_password : random_password.password.result
51+
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
52+
policies = var.acl_policies,
53+
token_ttl = "1h"
5154
}
5255
)
5356
}
5457

58+
59+
5560
resource "vault_generic_secret" "user" {
5661
path = "users/${var.username}"
5762

gcp-gitlab/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ projects:
1515
terraform_version: 1.3.8
1616
autoplan:
1717
enabled: true
18-
when_modified: ['**/*.tf', '*.tf*']
18+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1919
- dir: terraform/vault
2020
terraform_version: 1.3.8
2121
autoplan:

gcp-gitlab/terraform/users/modules/user/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ resource "random_password" "password" {
3434
}
3535

3636
resource "vault_generic_endpoint" "user" {
37+
depends_on = [ vault_generic_endpoint.user_password ] # avoids race condition
3738
path = "auth/userpass/users/${var.username}"
3839
ignore_absent_fields = true
3940

@@ -52,11 +53,13 @@ resource "vault_generic_endpoint" "user_password" {
5253
ignore_changes=[data_json]
5354
}
5455

55-
# note: this resource only manages the user's initial password and has a lifecycle policy to
56-
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
56+
# note: this resource includes the initial password and only gets applied once
57+
# changes to the user should be managed by the vault_generic_endpoint named "user" above
5758
data_json = jsonencode(
5859
{
59-
password = var.initial_password != "" ? var.initial_password : random_password.password.result
60+
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
61+
policies = var.acl_policies,
62+
token_ttl = "1h"
6063
}
6164
)
6265
}

k3d-github/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ projects:
1010
terraform_version: 1.3.8
1111
autoplan:
1212
enabled: true
13-
when_modified: ['**/*.tf', '*.tf*']
13+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1414
- dir: terraform/vault
1515
terraform_version: 1.3.8
1616
autoplan:

k3d-gitlab/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ projects:
1010
terraform_version: 1.3.8
1111
autoplan:
1212
enabled: true
13-
when_modified: ['**/*.tf', '*.tf*']
13+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1414
- dir: terraform/vault
1515
terraform_version: 1.3.8
1616
autoplan:

vultr-github/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ projects:
1515
terraform_version: 1.3.8
1616
autoplan:
1717
enabled: true
18-
when_modified: ['**/*.tf', '*.tf*']
18+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1919
- dir: terraform/vault
2020
terraform_version: 1.3.8
2121
autoplan:

vultr-github/terraform/users/modules/user/github/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ resource "random_password" "password" {
2525
}
2626

2727
resource "vault_generic_endpoint" "user" {
28+
depends_on = [ vault_generic_endpoint.user_password ] # avoids race condition
2829
path = "auth/userpass/users/${var.username}"
2930
ignore_absent_fields = true
3031

@@ -43,11 +44,13 @@ resource "vault_generic_endpoint" "user_password" {
4344
ignore_changes=[data_json]
4445
}
4546

46-
# note: this resource only manages the user's initial password and has a lifecycle policy to
47-
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
47+
# note: this resource includes the initial password and only gets applied once
48+
# changes to the user should be managed by the vault_generic_endpoint named "user" above
4849
data_json = jsonencode(
4950
{
50-
password = var.initial_password != "" ? var.initial_password : random_password.password.result
51+
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
52+
policies = var.acl_policies,
53+
token_ttl = "1h"
5154
}
5255
)
5356
}

vultr-gitlab/atlantis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ projects:
1515
terraform_version: 1.3.8
1616
autoplan:
1717
enabled: true
18-
when_modified: ['**/*.tf', '*.tf*']
18+
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
1919
- dir: terraform/vault
2020
terraform_version: 1.3.8
2121
autoplan:

vultr-gitlab/terraform/users/modules/user/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ resource "random_password" "password" {
3434
}
3535

3636
resource "vault_generic_endpoint" "user" {
37+
depends_on = [ vault_generic_endpoint.user_password ] # avoids race condition
3738
path = "auth/userpass/users/${var.username}"
3839
ignore_absent_fields = true
3940

@@ -52,11 +53,13 @@ resource "vault_generic_endpoint" "user_password" {
5253
ignore_changes=[data_json]
5354
}
5455

55-
# note: this resource only manages the user's initial password and has a lifecycle policy to
56-
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
56+
# note: this resource includes the initial password and only gets applied once
57+
# changes to the user should be managed by the vault_generic_endpoint named "user" above
5758
data_json = jsonencode(
5859
{
59-
password = var.initial_password != "" ? var.initial_password : random_password.password.result
60+
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
61+
policies = var.acl_policies,
62+
token_ttl = "1h"
6063
}
6164
)
6265
}

0 commit comments

Comments
 (0)