-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
35 lines (31 loc) · 833 Bytes
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.32.0"
}
}
}
data "google_iam_policy" "secret_accessor" {
binding {
role = "roles/secretmanager.secretAccessor"
members = [
"serviceAccount:${var.service_account}",
]
}
}
resource "google_secret_manager_secret" "secret" {
secret_id = var.secret_key
replication {
automatic = true
}
}
resource "google_secret_manager_secret_version" "value" {
secret = google_secret_manager_secret.secret.id
secret_data = var.secret_value
}
resource "google_secret_manager_secret_iam_policy" "policy" {
project = google_secret_manager_secret.secret.project
secret_id = google_secret_manager_secret.secret.secret_id
policy_data = data.google_iam_policy.secret_accessor.policy_data
}