Skip to content

Commit

Permalink
fix: issue-1776 - adjustment to accommodate new users with the passwo…
Browse files Browse the repository at this point in the history
…rd reset issue (#554)

* managing user endpoint lifecycle differently for password

* fix: accommodate brand new user circumstance with 1776 fix

* chore: dedupe from merge
  • Loading branch information
johndietz authored Aug 29, 2023
1 parent 72ed66f commit bb408f8
Show file tree
Hide file tree
Showing 22 changed files with 74 additions and 42 deletions.
2 changes: 1 addition & 1 deletion aws-github/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
9 changes: 6 additions & 3 deletions aws-github/terraform/users/modules/user/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ resource "random_password" "password" {
}

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

Expand All @@ -43,11 +44,13 @@ resource "vault_generic_endpoint" "user_password" {
ignore_changes=[data_json]
}

# note: this resource only manages the user's initial password and has a lifecycle policy to
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
# note: this resource includes the initial password and only gets applied once
# changes to the user should be managed by the vault_generic_endpoint named "user" above
data_json = jsonencode(
{
password = var.initial_password != "" ? var.initial_password : random_password.password.result
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
policies = var.acl_policies,
token_ttl = "1h"
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion aws-gitlab/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
9 changes: 6 additions & 3 deletions aws-gitlab/terraform/users/modules/user/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ resource "random_password" "password" {
}

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

Expand All @@ -52,11 +53,13 @@ resource "vault_generic_endpoint" "user_password" {
ignore_changes=[data_json]
}

# note: this resource only manages the user's initial password and has a lifecycle policy to
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
# note: this resource includes the initial password and only gets applied once
# changes to the user should be managed by the vault_generic_endpoint named "user" above
data_json = jsonencode(
{
password = var.initial_password != "" ? var.initial_password : random_password.password.result
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
policies = var.acl_policies,
token_ttl = "1h"
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion civo-github/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
9 changes: 6 additions & 3 deletions civo-github/terraform/users/modules/user/github/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ resource "random_password" "password" {
}

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

Expand All @@ -43,11 +44,13 @@ resource "vault_generic_endpoint" "user_password" {
ignore_changes=[data_json]
}

# note: this resource only manages the user's initial password and has a lifecycle policy to
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
# note: this resource includes the initial password and only gets applied once
# changes to the user should be managed by the vault_generic_endpoint named "user" above
data_json = jsonencode(
{
password = var.initial_password != "" ? var.initial_password : random_password.password.result
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
policies = var.acl_policies,
token_ttl = "1h"
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion civo-gitlab/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
9 changes: 6 additions & 3 deletions civo-gitlab/terraform/users/modules/user/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ resource "random_password" "password" {
}

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

Expand All @@ -52,11 +53,13 @@ resource "vault_generic_endpoint" "user_password" {
ignore_changes=[data_json]
}

# note: this resource only manages the user's initial password and has a lifecycle policy to
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
# note: this resource includes the initial password and only gets applied once
# changes to the user should be managed by the vault_generic_endpoint named "user" above
data_json = jsonencode(
{
password = var.initial_password != "" ? var.initial_password : random_password.password.result
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
policies = var.acl_policies,
token_ttl = "1h"
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion digitalocean-github/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ resource "random_password" "password" {
}

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

Expand All @@ -43,11 +44,13 @@ resource "vault_generic_endpoint" "user_password" {
ignore_changes=[data_json]
}

# note: this resource only manages the user's initial password and has a lifecycle policy to
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
# note: this resource includes the initial password and only gets applied once
# changes to the user should be managed by the vault_generic_endpoint named "user" above
data_json = jsonencode(
{
password = var.initial_password != "" ? var.initial_password : random_password.password.result
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
policies = var.acl_policies,
token_ttl = "1h"
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion digitalocean-gitlab/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
9 changes: 6 additions & 3 deletions digitalocean-gitlab/terraform/users/modules/user/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ resource "random_password" "password" {
}

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

Expand All @@ -52,11 +53,13 @@ resource "vault_generic_endpoint" "user_password" {
ignore_changes=[data_json]
}

# note: this resource only manages the user's initial password and has a lifecycle policy to
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
# note: this resource includes the initial password and only gets applied once
# changes to the user should be managed by the vault_generic_endpoint named "user" above
data_json = jsonencode(
{
password = var.initial_password != "" ? var.initial_password : random_password.password.result
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
policies = var.acl_policies,
token_ttl = "1h"
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion gcp-github/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
11 changes: 8 additions & 3 deletions gcp-github/terraform/users/modules/user/github/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ resource "random_password" "password" {
}

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

Expand All @@ -43,15 +44,19 @@ resource "vault_generic_endpoint" "user_password" {
ignore_changes=[data_json]
}

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



resource "vault_generic_secret" "user" {
path = "users/${var.username}"

Expand Down
2 changes: 1 addition & 1 deletion gcp-gitlab/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
9 changes: 6 additions & 3 deletions gcp-gitlab/terraform/users/modules/user/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ resource "random_password" "password" {
}

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

Expand All @@ -52,11 +53,13 @@ resource "vault_generic_endpoint" "user_password" {
ignore_changes=[data_json]
}

# note: this resource only manages the user's initial password and has a lifecycle policy to
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
# note: this resource includes the initial password and only gets applied once
# changes to the user should be managed by the vault_generic_endpoint named "user" above
data_json = jsonencode(
{
password = var.initial_password != "" ? var.initial_password : random_password.password.result
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
policies = var.acl_policies,
token_ttl = "1h"
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion k3d-github/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
2 changes: 1 addition & 1 deletion k3d-gitlab/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
2 changes: 1 addition & 1 deletion vultr-github/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
9 changes: 6 additions & 3 deletions vultr-github/terraform/users/modules/user/github/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ resource "random_password" "password" {
}

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

Expand All @@ -43,11 +44,13 @@ resource "vault_generic_endpoint" "user_password" {
ignore_changes=[data_json]
}

# note: this resource only manages the user's initial password and has a lifecycle policy to
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
# note: this resource includes the initial password and only gets applied once
# changes to the user should be managed by the vault_generic_endpoint named "user" above
data_json = jsonencode(
{
password = var.initial_password != "" ? var.initial_password : random_password.password.result
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
policies = var.acl_policies,
token_ttl = "1h"
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion vultr-gitlab/atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ projects:
terraform_version: 1.3.8
autoplan:
enabled: true
when_modified: ['**/*.tf', '*.tf*']
when_modified: ['**/*.tf', '**/modules/*.tf', '**/admins/*.tf', '**/developers/*.tf', '*.tf*']
- dir: terraform/vault
terraform_version: 1.3.8
autoplan:
Expand Down
9 changes: 6 additions & 3 deletions vultr-gitlab/terraform/users/modules/user/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ resource "random_password" "password" {
}

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

Expand All @@ -52,11 +53,13 @@ resource "vault_generic_endpoint" "user_password" {
ignore_changes=[data_json]
}

# note: this resource only manages the user's initial password and has a lifecycle policy to
# ignore changes. to change other vault_generic_endpoint properties see the "user" resource above
# note: this resource includes the initial password and only gets applied once
# changes to the user should be managed by the vault_generic_endpoint named "user" above
data_json = jsonencode(
{
password = var.initial_password != "" ? var.initial_password : random_password.password.result
password = var.initial_password != "" ? var.initial_password : random_password.password.result,
policies = var.acl_policies,
token_ttl = "1h"
}
)
}
Expand Down

0 comments on commit bb408f8

Please sign in to comment.