반응형
how can we add project number from variable in terraform gcp resource iam binding
Below is my terraform resource. how can we add project number from variable in terraform gcp resource iam binding because if i will run same terraform for other account, i have to change it manually.
resource "google_project_iam_binding" "project" {
project = var.projectid
role = "roles/container.admin"
members = [
"serviceAccount:service-1016545346555@gcp-sa-cloudbuild.iam.gserviceaccount.com",
]
}
You can use google_client_config
data-source to access the configuration of the provider.
First, add the following data-source block to main.tf:
data "google_client_config" "current" {}
Then, you would be able to access the project_id as below:
output "project_id" {
value = data.google_client_config.current.project
}
For more information, please refer to: https://www.terraform.io/docs/providers/google/d/client_config.html
The project number is found in the google_project data-source.
So when this one is added:
data "google_project" "project" {}
it should be accessible using:
data.google_project.project.number
반응형
'개발하자' 카테고리의 다른 글
동적 쿼리 매개 변수 빠른 속도API (0) | 2022.11.16 |
---|---|
빠른 속도로 파일을 업로드하는 방법API를 Panda Dataframe으로 변환하시겠습니까? (0) | 2022.11.15 |
Kubernetes 시크릿 볼륨 대 변수 (0) | 2022.11.14 |
Svelte: How to handle the custom writtable store's async init's promise in the component? (0) | 2022.11.14 |
Docker-Compose를 사용하여 Jupyter 노트북을 시작할 때 Docker 컨테이너 내부의 콘다 환경 활성화 (1) | 2022.11.14 |