You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/best-practices/deletion-behaviors.md
+4-6Lines changed: 4 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,8 @@ weight: 20
5
5
6
6
# Deletion behaviors
7
7
8
-
{{< hint info >}}
9
-
**Note:** This page covers best practices guidance for the Terraform provider for Google Cloud, which is used to ensure a consistent UX for Terraform users across providers or GCP users across the Google provider. Generally, this guidance should be followed and exceptions should be clearly demarcated / discussed.
10
-
{{< /hint >}}
8
+
> [!NOTE]
9
+
> **Note:** This page covers best practices guidance for the Terraform provider for Google Cloud, which is used to ensure a consistent UX for Terraform users across providers or GCP users across the Google provider. Generally, this guidance should be followed and exceptions should be clearly demarcated / discussed.
11
10
12
11
## Mitigating data loss risk via deletion_protection {#deletion_protection}
13
12
@@ -26,9 +25,8 @@ Resources that do not have a significant risk of unrecoverable data loss or simi
26
25
27
26
See [Client-side fields]({{< ref "/develop/client-side-fields" >}}) for information about adding `deletion_protection` fields.
28
27
29
-
{{< hint info >}}
30
-
**Note:** The previous best practice was a field called `force_delete` that defaulted to `false`. This is still present on some resources for backwards-compatibility reasons, but `deletion_protection` is preferred going forward.
31
-
{{< /hint >}}
28
+
> [!NOTE]
29
+
> **Note:** The previous best practice was a field called `force_delete` that defaulted to `false`. This is still present on some resources for backwards-compatibility reasons, but `deletion_protection` is preferred going forward.
Copy file name to clipboardExpand all lines: docs/content/best-practices/immutable-fields.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,8 @@ aliases:
8
8
9
9
# Immutable fields
10
10
11
-
{{< hint info >}}
12
-
**Note:** This page covers best practices guidance for the Terraform provider for Google Cloud, which is used to ensure a consistent UX for Terraform users across providers or GCP users across the Google provider. Generally, this guidance should be followed and exceptions should be clearly demarcated / discussed.
13
-
{{< /hint >}}
11
+
> [!NOTE]
12
+
> **Note:** This page covers best practices guidance for the Terraform provider for Google Cloud, which is used to ensure a consistent UX for Terraform users across providers or GCP users across the Google provider. Generally, this guidance should be followed and exceptions should be clearly demarcated / discussed.
14
13
15
14
[`ForceNew`](https://developer.hashicorp.com/terraform/intro#how-does-terraform-work) in a Terraform resource schema attribute that indicates that a field is immutable – that is, that a change to the field requires the resource to be destroyed and recreated.
Copy file name to clipboardExpand all lines: docs/content/best-practices/labels-and-annotations.md
+85-86Lines changed: 85 additions & 86 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,8 @@ weight: 30
5
5
6
6
# Add labels and annotations support
7
7
8
-
{{< hint info >}}
9
-
**Note:** This page covers best practices guidance for the Terraform provider for Google Cloud, which is used to ensure a consistent UX for Terraform users across providers or GCP users across the Google provider. Generally, this guidance should be followed and exceptions should be clearly demarcated / discussed.
10
-
{{< /hint >}}
8
+
> [!NOTE]
9
+
> **Note:** This page covers best practices guidance for the Terraform provider for Google Cloud, which is used to ensure a consistent UX for Terraform users across providers or GCP users across the Google provider. Generally, this guidance should be followed and exceptions should be clearly demarcated / discussed.
11
10
12
11
The new labels model and the new annotations model are introduced in [Terraform provider for Google Cloud 5.0.0](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/version_5_upgrade#provider).
13
12
@@ -29,83 +28,83 @@ When adding a new `labels` field, please make the changes below to support the n
29
28
30
29
1. Use the type `KeyValueLabels` for the standard resource `labels` field. The standard resource `labels` field could be the top level `labels` field or the nested `labels` field inside the top level `metadata` field. Don't add `default_from_api: true` to this field or don't use this type for other `labels` fields in the resource. `KeyValueLabels` will add all of changes required for the new model automatically.
31
30
32
-
```yaml
33
-
- name: 'labels'
34
-
type: KeyValueLabels
35
-
description: |
36
-
The labels associated with this dataset. You can use these to
37
-
organize and group your datasets.
38
-
```
31
+
```yaml
32
+
- name: 'labels'
33
+
type: KeyValueLabels
34
+
description: |
35
+
The labels associated with this dataset. You can use these to
36
+
organize and group your datasets.
37
+
```
39
38
2. In the handwritten acceptance tests, add `labels` and `terraform_labels` to `ImportStateVerifyIgnore` if `labels` field is in the configuration.
3. In the corresponding data source, after the resource read method, call the function `tpgresource.SetDataSourceLabels(d)` to make `labels` and `terraform_labels` have all of the labels on the resource.
1. Add `tpgresource.SetLabelsDiff` to `CustomizeDiff` of the resource.
60
-
```go
61
-
CustomizeDiff: customdiff.All(
62
-
tpgresource.SetLabelsDiff,
63
-
),
64
-
```
59
+
```go
60
+
CustomizeDiff: customdiff.All(
61
+
tpgresource.SetLabelsDiff,
62
+
),
63
+
```
65
64
2. Add `labels` field and add more attributes (such as `ForceNew: true,`, `Set: schema.HashString,`) to this field if necessary.
66
-
```go
67
-
"labels": {
68
-
Type: schema.TypeMap,
69
-
Optional: true,
70
-
Elem: &schema.Schema{Type: schema.TypeString},
71
-
Description: `A set of key/value label pairs to assign to the project.
72
-
73
-
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
74
-
Please refer to the field 'effective_labels' for all of the labels present on the resource.`,
75
-
},
76
-
```
65
+
```go
66
+
"labels": {
67
+
Type: schema.TypeMap,
68
+
Optional: true,
69
+
Elem: &schema.Schema{Type: schema.TypeString},
70
+
Description: `A set of key/value label pairs to assign to the project.
71
+
72
+
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
73
+
Please refer to the field 'effective_labels' for all of the labels present on the resource.`,
74
+
},
75
+
```
77
76
3. Add output only field `terraform_labels` and add more attributes (such as `Set: schema.HashString,`) to this field if necessary. Don't add `ForceNew:true,` to this field.
78
-
```go
79
-
"terraform_labels": {
80
-
Type: schema.TypeMap,
81
-
Computed: true,
82
-
Description: `The combination of labels configured directly on the resource and default labels configured on the provider.`,
83
-
Elem: &schema.Schema{Type: schema.TypeString},
84
-
},
85
-
```
77
+
```go
78
+
"terraform_labels": {
79
+
Type: schema.TypeMap,
80
+
Computed: true,
81
+
Description: `The combination of labels configured directly on the resource and default labels configured on the provider.`,
82
+
Elem: &schema.Schema{Type: schema.TypeString},
83
+
},
84
+
```
86
85
4. Add output only field `effective_labels` and add more attributes (such as `ForceNew: true,`, `Set: schema.HashString,`) to this field if necessary.
87
-
```go
88
-
"effective_labels": {
89
-
Type: schema.TypeMap,
90
-
Computed: true,
91
-
Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`,
92
-
Elem: &schema.Schema{Type: schema.TypeString},
93
-
},
94
-
```
86
+
```go
87
+
"effective_labels": {
88
+
Type: schema.TypeMap,
89
+
Computed: true,
90
+
Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`,
91
+
Elem: &schema.Schema{Type: schema.TypeString},
92
+
},
93
+
```
95
94
5. In the create method, use the value of `effective_labels` in API request.
96
95
6. In the update method, use the value of `effective_labels` in API request.
97
96
7. In the read mehtod, set `labels`, `terraform_labels` and `effective_labels` to state.
8. In the handwritten acceptance tests, add `labels` and `terraform_labels` to `ImportStateVerifyIgnore`.
110
109
9. In the corresponding data source, after the resource read method, call the function `tpgresource.SetDataSourceLabels(d)` to make `labels` and `terraform_labels` have all of the labels on the resource.
111
110
10. Add the documentation for these label-related fields.
@@ -117,33 +116,33 @@ When adding a new `annotations` field, please make the changes below below to su
117
116
118
117
1. Use the type `KeyValueAnnotations` for the standard resource `annotations` field. The standard resource `annotations` field could be the top level `annotations` field or the nested `annotations` field inside the top level `metadata` field. Don't add `default_from_api: true` to this field or don't use this type for other `annotations` fields in the resource. `KeyValueAnnotations` will add all of changes required for the new model automatically.
119
118
120
-
```yaml
121
-
- name: 'annotations'
122
-
type: KeyValueAnnotations
123
-
description: |
124
-
Client-specified annotations. This is distinct from labels.
125
-
```
119
+
```yaml
120
+
- name: 'annotations'
121
+
type: KeyValueAnnotations
122
+
description: |
123
+
Client-specified annotations. This is distinct from labels.
124
+
```
126
125
2. In the handwritten acceptance tests, add `annotations` to `ImportStateVerifyIgnore` if `annotations` field is in the configuration.
127
126
128
-
```go
129
-
ImportStateVerifyIgnore: []string{"annotations"},
130
-
```
127
+
```go
128
+
ImportStateVerifyIgnore: []string{"annotations"},
129
+
```
131
130
3. In the corresponding data source, after the resource read method, call the function `tpgresource.SetDataSourceAnnotations(d)` to make `annotations` have all of the annotations on the resource.
132
131
133
-
```go
134
-
err = resourceSecretManagerSecretRead(d, meta)
135
-
if err != nil {
136
-
return err
137
-
}
132
+
```go
133
+
err = resourceSecretManagerSecretRead(d, meta)
134
+
if err != nil {
135
+
return err
136
+
}
138
137
139
-
if err := tpgresource.SetDataSourceLabels(d); err != nil {
140
-
return err
141
-
}
138
+
if err := tpgresource.SetDataSourceLabels(d); err != nil {
139
+
return err
140
+
}
142
141
143
-
if err := tpgresource.SetDataSourceAnnotations(d); err != nil {
144
-
return err
145
-
}
146
-
```
142
+
if err := tpgresource.SetDataSourceAnnotations(d); err != nil {
Copy file name to clipboardExpand all lines: docs/content/breaking-changes/make-a-breaking-change.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,7 @@ provider at runtime as well as in documentation.
89
89
90
90
#### Field deprecation (due to removal or rename)
91
91
92
-
{{< tabs "Field deprecations" >}}
92
+
{{% tabs "Field deprecations" %}}
93
93
{{< tab "MMv1" >}}
94
94
Set `deprecation_message` on the field. For example:
95
95
@@ -124,11 +124,11 @@ The deprecation message will automatically show up in the resource documentation
124
124
* `api_field_name` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html), Deprecated) FIELD_DESCRIPTION. `api_field_name` is deprecated and will be removed in a future major release. Use `other_field_name` instead.
125
125
```
126
126
{{< /tab >}}
127
-
{{< /tabs >}}
127
+
{{% /tabs %}}
128
128
129
129
#### Resource deprecation (due to removal or rename)
130
130
131
-
{{< tabs "Resource deprecations" >}}
131
+
{{% tabs "Resource deprecations" %}}
132
132
{{< tab "MMv1" >}}
133
133
Set `deprecation_message` on the resource. For example:
134
134
@@ -165,7 +165,7 @@ The deprecation message will automatically show up in the resource documentation
165
165
major release. Use `google_OTHER_RESOURCE_NAME` instead.
0 commit comments