Quantcast
Channel: Terraform - HashiCorp Discuss
Viewing all articles
Browse latest Browse all 11469

Terraform Mongo imported service account password challenge

$
0
0

We created service account in mongo by not using terraform.
We imported the user in terraform.
Challenge here is we want to keep the password in the terraform state file same as when it was created by hand.
If we run below resources, random_password resource will generate new password and assign it to password which will change in database and statefile.
We want to have the same password first time generated when the user was created to be in the state file.

resource “random_password” “mongoserviceaccount” {
length = 16
lower = true
upper = true
numeric = true
special = false
}

resource “mongodbatlas_database_user” “mongoserviceaccount” {
username = “mongoserviceaccount”
password = random_password.mongoserviceaccount.result
project_id = var.pid
auth_database_name = “admin”

roles {
database_name = “admin”
role_name = “read”
}
scopes {
name = var.cname
type = “CLUSTER”
}
}

output “key_mongoserviceaccount” {
value = mongodbatlas_database_user.mongoserviceaccount.username
}

output “secret_mongoserviceaccount” {
value = random_password.mongoserviceaccount.result
sensitive = true
}

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 11469

Latest Images

Trending Articles


Telangana Ration Card Online Status Ahara Bhadratha Card Online Status


CalCen


Waves Complete v2019.02.14 Incl Emulator-R2R


[RELEASE THREAD]--_A-Team_--Cricket_Dream_5G


MCGEE, SAMUEL O., DECEASED, OF...


WordPress: Reverse Shell


GPGT - chio bu back from market kym


Ondonga king dragged to court


Justin Guy Ballou, III


Krupt Biography, Death, Songs, Photo, Video



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>