Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Creation of google service account key with terraform then save into output

Hi there, I wanted to create the json token key using terraform via data and output: 

 

 

 

resource "google_service_account" "myaccount" {
	account_id = "myaccount"
	display_name = "My Service Account"
}
resource "google_service_account_key" "mykey" {
	service_account_id = google_service_account.myaccount.name
	public_key_type = "TYPE_GOOGLE_CREDENTIALS_FILE"
}
data "google_service_account_key" "google_service_account_key" {
	service_account_id = google_service_account.myaccount.name
}

output "google_credentials_json" {
	value = google_service_account_key.google_service_account_key.private_key
	sensitive = true
}

 

 

 

 

There is a sample of creating the key but we are not allowed to create an output for the key, I want to know :

1. how to create a physical token creation with terraform
2. what is the standard practice of creating the key using terraform if not do we just create them in the console
(ps: I know there are safer way than this which is using role federation for the application but this case I have to stick with json credentials)

1 1 4,826
1 REPLY 1