Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 54 additions & 6 deletions mmv1/templates/terraform/resource_iam.html.markdown.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,22 @@ See [Provider Versions](../guides/provider_versions.html.markdown) for more deta
## {{ $.IamTerraformName }}_policy

```hcl
resource "google_service_account" "sa" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
{{- end }}
account_id = "my-custom-sa"
display_name = "My Custom Service Account"
}

data "google_iam_policy" "admin" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
{{- end }}
binding {
role = "{{if $.IamPolicy.AdminIamRole}}{{$.IamPolicy.AdminIamRole }}{{else}}{{$.IamPolicy.AllowedIamRole}}{{end}}"
members = [
"user:jane@example.com",
"serviceAccount:${google_service_account.sa.email}",
]
}
}
Expand All @@ -100,14 +108,22 @@ resource "{{ $.IamTerraformName }}_policy" "policy" {
With IAM Conditions:

```hcl
resource "google_service_account" "sa" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
{{- end }}
account_id = "my-custom-sa"
display_name = "My Custom Service Account"
}

data "google_iam_policy" "admin" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
{{- end }}
binding {
role = "{{if $.IamPolicy.AdminIamRole}}{{$.IamPolicy.AdminIamRole }}{{else}}{{$.IamPolicy.AllowedIamRole}}{{end}}"
members = [
"user:jane@example.com",
"serviceAccount:${google_service_account.sa.email}",
]

condition {
Expand Down Expand Up @@ -136,6 +152,14 @@ resource "{{ $.IamTerraformName }}_policy" "policy" {
## {{ $.IamTerraformName }}_binding

```hcl
resource "google_service_account" "sa" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
{{- end }}
account_id = "my-custom-sa"
display_name = "My Custom Service Account"
}

resource "{{ $.IamTerraformName }}_binding" "binding" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
Expand All @@ -149,14 +173,22 @@ resource "{{ $.IamTerraformName }}_binding" "binding" {
{{- end }}
role = "{{if $.IamPolicy.AdminIamRole}}{{$.IamPolicy.AdminIamRole }}{{else}}{{$.IamPolicy.AllowedIamRole}}{{end}}"
members = [
"user:jane@example.com",
"serviceAccount:${google_service_account.sa.email}",
]
}
```
{{ if $.IamPolicy.IamConditionsRequestType }}
With IAM Conditions:

```hcl
resource "google_service_account" "sa" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
{{- end }}
account_id = "my-custom-sa"
display_name = "My Custom Service Account"
}

resource "{{ $.IamTerraformName }}_binding" "binding" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
Expand All @@ -170,7 +202,7 @@ resource "{{ $.IamTerraformName }}_binding" "binding" {
{{- end }}
role = "{{if $.IamPolicy.AdminIamRole}}{{$.IamPolicy.AdminIamRole }}{{else}}{{$.IamPolicy.AllowedIamRole}}{{end}}"
members = [
"user:jane@example.com",
"serviceAccount:${google_service_account.sa.email}",
]

condition {
Expand All @@ -184,6 +216,14 @@ resource "{{ $.IamTerraformName }}_binding" "binding" {
## {{ $.IamTerraformName }}_member

```hcl
resource "google_service_account" "sa" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
{{- end }}
account_id = "my-custom-sa"
display_name = "My Custom Service Account"
}

resource "{{ $.IamTerraformName }}_member" "member" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
Expand All @@ -196,13 +236,21 @@ resource "{{ $.IamTerraformName }}_member" "member" {
{{ customTemplate $ $.IamPolicy.SampleConfigBody false }}
{{- end }}
role = "{{if $.IamPolicy.AdminIamRole}}{{$.IamPolicy.AdminIamRole }}{{else}}{{$.IamPolicy.AllowedIamRole}}{{end}}"
member = "user:jane@example.com"
member = "serviceAccount:${google_service_account.sa.email}"
}
```
{{ if $.IamPolicy.IamConditionsRequestType }}
With IAM Conditions:

```hcl
resource "google_service_account" "sa" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
{{- end }}
account_id = "my-custom-sa"
display_name = "My Custom Service Account"
}

resource "{{ $.IamTerraformName }}_member" "member" {
{{- if eq $.MinVersionObj.Name "beta" }}
provider = google-beta
Expand All @@ -215,7 +263,7 @@ resource "{{ $.IamTerraformName }}_member" "member" {
{{ customTemplate $ $.IamPolicy.SampleConfigBody false }}
{{- end }}
role = "{{if $.IamPolicy.AdminIamRole}}{{$.IamPolicy.AdminIamRole}}{{else}}{{$.IamPolicy.AllowedIamRole}}{{end}}"
member = "user:jane@example.com"
member = "serviceAccount:${google_service_account.sa.email}"

condition {
title = "expires_after_2019_12_31"
Expand Down
Loading