Skip to content

Commit c389029

Browse files
authored
Finish converting ACM resources to use policy mutex lock (#12735)
1 parent 9449992 commit c389029

25 files changed

+141
-8
lines changed

mmv1/products/accesscontextmanager/AccessLevel.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ self_link: '{{name}}'
3939
create_url: '{{parent}}/accessLevels'
4040
update_verb: 'PATCH'
4141
update_mask: true
42+
mutex: '{{parent}}'
4243
import_format:
4344
- '{{name}}'
4445
timeouts:

mmv1/products/accesscontextmanager/AccessLevelCondition.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ create_verb: 'PATCH'
4747
update_mask: true
4848
delete_verb: 'PATCH'
4949
immutable: true
50-
mutex: '{{access_level}}'
50+
mutex: '{{access_policy_id}}'
5151
import_format:
5252
- '{{access_level}}'
5353
# no unique way to specify
@@ -78,6 +78,7 @@ nested_query:
7878
is_list_of_ids: false
7979
modify_by_patch: true
8080
custom_code:
81+
encoder: 'templates/terraform/encoders/access_context_manager_access_level_condition.go.tmpl'
8182
exclude_tgc: true
8283
# Skipping the sweeper due to the non-standard base_url and because this is fine-grained under AccessLevel
8384
exclude_sweeper: true
@@ -248,3 +249,9 @@ properties:
248249
description: 'CIDR block IP subnetwork specification. Must be IPv4.'
249250
item_type:
250251
type: String
252+
- name: 'accessPolicyId'
253+
type: String
254+
description: |
255+
The name of the Access Policy this resource belongs to.
256+
ignore_read: true
257+
output: true

mmv1/products/accesscontextmanager/AccessLevels.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ update_url: '{{parent}}/accessLevels:replaceAll'
3737
update_verb: 'POST'
3838
import_format:
3939
- '{{parent}}/accessLevels'
40+
mutex: '{{parent}}'
4041
timeouts:
4142
insert_minutes: 20
4243
update_minutes: 20

mmv1/products/accesscontextmanager/AccessPolicy.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ update_verb: 'PATCH'
3737
update_mask: true
3838
import_format:
3939
- '{{name}}'
40+
mutex: 'accessPolicies/{{name}}'
4041
timeouts:
4142
insert_minutes: 20
4243
update_minutes: 20

mmv1/products/accesscontextmanager/AuthorizedOrgsDesc.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ create_url: '{{parent}}/authorizedOrgsDescs'
3737
update_verb: 'PATCH'
3838
import_format:
3939
- '{{name}}'
40+
mutex: '{{parent}}'
4041
timeouts:
4142
insert_minutes: 20
4243
update_minutes: 20

mmv1/products/accesscontextmanager/EgressPolicy.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ create_verb: 'PATCH'
2828
update_mask: true
2929
delete_verb: 'PATCH'
3030
immutable: true
31+
mutex: '{{access_policy_id}}'
3132
import_format:
3233
- '{{egress_policy_name}}/{{resource}}'
3334
timeouts:
@@ -51,6 +52,7 @@ nested_query:
5152
is_list_of_ids: true
5253
modify_by_patch: true
5354
custom_code:
55+
encoder: 'templates/terraform/encoders/access_context_manager_egress_policy.go.tmpl'
5456
custom_import: 'templates/terraform/custom_import/access_context_manager_service_perimeter_egress_policy.go.tmpl'
5557
exclude_tgc: true
5658
# Skipping the sweeper due to the non-standard base_url and because this is fine-grained under ServicePerimeter/IngressPolicy
@@ -72,3 +74,9 @@ properties:
7274
A GCP resource that is inside of the service perimeter.
7375
required: true
7476
immutable: true
77+
- name: 'accessPolicyId'
78+
type: String
79+
description: |
80+
The name of the Access Policy this resource belongs to.
81+
ignore_read: true
82+
output: true

mmv1/products/accesscontextmanager/IngressPolicy.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ create_verb: 'PATCH'
2828
update_mask: true
2929
delete_verb: 'PATCH'
3030
immutable: true
31+
mutex: '{{access_policy_id}}'
3132
import_format:
3233
- '{{ingress_policy_name}}/{{resource}}'
3334
timeouts:
@@ -51,6 +52,7 @@ nested_query:
5152
is_list_of_ids: true
5253
modify_by_patch: true
5354
custom_code:
55+
encoder: 'templates/terraform/encoders/access_context_manager_ingress_policy.go.tmpl'
5456
custom_import: 'templates/terraform/custom_import/access_context_manager_service_perimeter_ingress_policy.go.tmpl'
5557
exclude_tgc: true
5658
# Skipping the sweeper due to the non-standard base_url and because this is fine-grained under ServicePerimeter/IngressPolicy
@@ -72,3 +74,9 @@ properties:
7274
A GCP resource that is inside of the service perimeter.
7375
required: true
7476
immutable: true
77+
- name: 'accessPolicyId'
78+
type: String
79+
description: |
80+
The name of the Access Policy this resource belongs to.
81+
ignore_read: true
82+
output: true

mmv1/products/accesscontextmanager/ServicePerimeter.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ self_link: '{{name}}'
4747
create_url: '{{parent}}/servicePerimeters'
4848
update_verb: 'PATCH'
4949
update_mask: true
50-
mutex: '{{name}}'
50+
mutex: '{{parent}}'
5151
import_format:
5252
- '{{name}}'
5353
timeouts:

mmv1/products/accesscontextmanager/ServicePerimeterDryRunEgressPolicy.yaml

+9-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ create_verb: 'PATCH'
4343
update_mask: true
4444
delete_verb: 'PATCH'
4545
immutable: true
46-
mutex: '{{perimeter}}'
46+
mutex: '{{access_policy_id}}'
4747
import_format:
4848
- '{{perimeter}}'
4949
exclude_import: true
@@ -70,6 +70,7 @@ nested_query:
7070
modify_by_patch: true
7171
custom_code:
7272
constants: 'templates/terraform/constants/access_context_manager.go.tmpl'
73+
encoder: 'templates/terraform/encoders/access_context_manager_service_perimeter_dry_run_egress_policy.go.tmpl'
7374
pre_create: 'templates/terraform/pre_create/access_context_manager_dry_run_resource.go.tmpl'
7475
pre_update: 'templates/terraform/pre_create/access_context_manager_dry_run_resource.go.tmpl'
7576
pre_delete: 'templates/terraform/pre_create/access_context_manager_dry_run_resource.go.tmpl'
@@ -194,3 +195,10 @@ properties:
194195
description: |
195196
Value for permission should be a valid Cloud IAM permission for the
196197
corresponding `serviceName` in `ApiOperation`.
198+
immutable: true
199+
- name: 'accessPolicyId'
200+
type: String
201+
description: |
202+
The name of the Access Policy this resource belongs to.
203+
ignore_read: true
204+
output: true

mmv1/products/accesscontextmanager/ServicePerimeterDryRunIngressPolicy.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ create_verb: 'PATCH'
4444
update_mask: true
4545
delete_verb: 'PATCH'
4646
immutable: true
47-
mutex: '{{perimeter}}'
47+
mutex: '{{access_policy_id}}'
4848
import_format:
4949
- '{{perimeter}}'
5050
exclude_import: true
@@ -71,6 +71,7 @@ nested_query:
7171
modify_by_patch: true
7272
custom_code:
7373
constants: 'templates/terraform/constants/access_context_manager.go.tmpl'
74+
encoder: 'templates/terraform/encoders/access_context_manager_service_perimeter_dry_run_egress_policy.go.tmpl'
7475
pre_create: 'templates/terraform/pre_create/access_context_manager_dry_run_resource.go.tmpl'
7576
pre_update: 'templates/terraform/pre_create/access_context_manager_dry_run_resource.go.tmpl'
7677
pre_delete: 'templates/terraform/pre_create/access_context_manager_dry_run_resource.go.tmpl'
@@ -203,3 +204,9 @@ properties:
203204
description: |
204205
Value for permission should be a valid Cloud IAM permission for the
205206
corresponding `serviceName` in `ApiOperation`.
207+
- name: 'accessPolicyId'
208+
type: String
209+
description: |
210+
The name of the Access Policy this resource belongs to.
211+
ignore_read: true
212+
output: true

mmv1/products/accesscontextmanager/ServicePerimeterDryRunResource.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ create_verb: 'PATCH'
4343
update_mask: true
4444
delete_verb: 'PATCH'
4545
immutable: true
46-
mutex: '{{perimeter_name}}'
46+
mutex: '{{access_policy_id}}'
4747
import_format:
4848
- '{{perimeter_name}}/{{resource}}'
4949
timeouts:
@@ -67,6 +67,7 @@ nested_query:
6767
is_list_of_ids: true
6868
modify_by_patch: true
6969
custom_code:
70+
encoder: 'templates/terraform/encoders/access_context_manager_service_perimeter_dry_run_resource.go.tmpl'
7071
pre_create: 'templates/terraform/pre_create/access_context_manager_dry_run_resource.go.tmpl'
7172
pre_update: 'templates/terraform/pre_create/access_context_manager_dry_run_resource.go.tmpl'
7273
pre_delete: 'templates/terraform/pre_create/access_context_manager_dry_run_resource.go.tmpl'
@@ -99,3 +100,9 @@ properties:
99100
Format: projects/{project_number}
100101
required: true
101102
immutable: true
103+
- name: 'accessPolicyId'
104+
type: String
105+
description: |
106+
The name of the Access Policy this resource belongs to.
107+
ignore_read: true
108+
output: true

mmv1/products/accesscontextmanager/ServicePerimeterEgressPolicy.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ create_verb: 'PATCH'
4343
update_mask: true
4444
delete_verb: 'PATCH'
4545
immutable: true
46-
mutex: '{{perimeter}}'
46+
mutex: '{{access_policy_id}}'
4747
import_format:
4848
- '{{perimeter}}'
4949
exclude_import: true
@@ -71,6 +71,7 @@ nested_query:
7171
custom_code:
7272
constants: 'templates/terraform/constants/access_context_manager.go.tmpl'
7373
custom_import: 'templates/terraform/custom_import/access_context_manager_service_perimeter_egress_policy.go.tmpl'
74+
encoder: 'templates/terraform/encoders/access_context_manager_service_perimeter_egress_policy.go.tmpl'
7475
exclude_tgc: true
7576
# Skipping the sweeper due to the non-standard base_url and because this is fine-grained under ServicePerimeter
7677
exclude_sweeper: true
@@ -192,3 +193,9 @@ properties:
192193
description: |
193194
Value for permission should be a valid Cloud IAM permission for the
194195
corresponding `serviceName` in `ApiOperation`.
196+
- name: 'accessPolicyId'
197+
type: String
198+
description: |
199+
The name of the Access Policy this resource belongs to.
200+
ignore_read: true
201+
output: true

mmv1/products/accesscontextmanager/ServicePerimeterIngressPolicy.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ create_verb: 'PATCH'
4444
update_mask: true
4545
delete_verb: 'PATCH'
4646
immutable: true
47-
mutex: '{{perimeter}}'
47+
mutex: '{{access_policy_id}}'
4848
import_format:
4949
- '{{perimeter}}'
5050
exclude_import: true
@@ -72,6 +72,7 @@ nested_query:
7272
custom_code:
7373
constants: 'templates/terraform/constants/access_context_manager.go.tmpl'
7474
custom_import: 'templates/terraform/custom_import/access_context_manager_service_perimeter_ingress_policy.go.tmpl'
75+
encoder: 'templates/terraform/encoders/access_context_manager_service_perimeter_ingress_policy.go.tmpl'
7576
exclude_tgc: true
7677
# Skipping the sweeper due to the non-standard base_url and because this is fine-grained under ServicePerimeter
7778
exclude_sweeper: true
@@ -203,3 +204,9 @@ properties:
203204
description: |
204205
Value for permission should be a valid Cloud IAM permission for the
205206
corresponding `serviceName` in `ApiOperation`.
207+
- name: 'accessPolicyId'
208+
type: String
209+
description: |
210+
The name of the Access Policy this resource belongs to.
211+
ignore_read: true
212+
output: true

mmv1/products/accesscontextmanager/ServicePerimeterResource.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,4 @@ properties:
103103
description: |
104104
The name of the Access Policy this resource belongs to.
105105
ignore_read: true
106-
immutable: true
107106
output: true

mmv1/products/accesscontextmanager/ServicePerimeters.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ base_url: '{{parent}}/servicePerimeters:replaceAll'
3030
self_link: '{{parent}}/servicePerimeters'
3131
update_url: '{{parent}}/servicePerimeters:replaceAll'
3232
update_verb: 'POST'
33+
mutex: '{{parent}}'
3334
import_format:
3435
- '{{parent}}/servicePerimeters'
3536
timeouts:

mmv1/templates/terraform/custom_import/access_context_manager_service_perimeter_egress_policy.go.tmpl

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
return nil, err
1919
}
2020

21+
if err := d.Set("access_policy_id", fmt.Sprintf("accessPolicies/%s", parts["accessPolicy"])); err != nil {
22+
return nil, fmt.Errorf("Error setting access_policy_id: %s", err)
23+
}
2124
if err := d.Set("perimeter", fmt.Sprintf("accessPolicies/%s/servicePerimeters/%s", parts["accessPolicy"], parts["perimeter"])); err != nil {
2225
return nil, fmt.Errorf("Error setting perimeter: %s", err)
2326
}

mmv1/templates/terraform/custom_import/access_context_manager_service_perimeter_ingress_policy.go.tmpl

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
return nil, err
1919
}
2020

21+
if err := d.Set("access_policy_id", fmt.Sprintf("accessPolicies/%s", parts["accessPolicy"])); err != nil {
22+
return nil, fmt.Errorf("Error setting access_policy_id: %s", err)
23+
}
2124
if err := d.Set("perimeter", fmt.Sprintf("accessPolicies/%s/servicePerimeters/%s", parts["accessPolicy"], parts["perimeter"])); err != nil {
2225
return nil, fmt.Errorf("Error setting perimeter: %s", err)
2326
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Set the access_policy_id field from part of the access_level parameter.
2+
3+
// The is logic is inside the encoder since the access_policy_id field is part of
4+
// the mutex lock and encoders run before the lock is set.
5+
parts := strings.Split(d.Get("access_level").(string), "/")
6+
d.Set("access_policy_id", fmt.Sprintf("accessPolicies/%s", parts[1]))
7+
8+
return obj, nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Set the access_policy_id field from part of the egress_policy_name parameter.
2+
3+
// The is logic is inside the encoder since the access_policy_id field is part of
4+
// the mutex lock and encoders run before the lock is set.
5+
parts := strings.Split(d.Get("egress_policy_name").(string), "/")
6+
d.Set("access_policy_id", fmt.Sprintf("accessPolicies/%s", parts[1]))
7+
8+
return obj, nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Set the access_policy_id field from part of the ingress_policy_name parameter.
2+
3+
// The is logic is inside the encoder since the access_policy_id field is part of
4+
// the mutex lock and encoders run before the lock is set.
5+
parts := strings.Split(d.Get("ingress_policy_name").(string), "/")
6+
d.Set("access_policy_id", fmt.Sprintf("accessPolicies/%s", parts[1]))
7+
8+
return obj, nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Set the access_policy_id field from part of the perimeter parameter.
2+
3+
// The is logic is inside the encoder since the access_policy_id field is part of
4+
// the mutex lock and encoders run before the lock is set.
5+
parts := strings.Split(d.Get("perimeter").(string), "/")
6+
d.Set("access_policy_id", fmt.Sprintf("accessPolicies/%s", parts[1]))
7+
8+
return obj, nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Set the access_policy_id field from part of the perimeter parameter.
2+
3+
// The is logic is inside the encoder since the access_policy_id field is part of
4+
// the mutex lock and encoders run before the lock is set.
5+
parts := strings.Split(d.Get("perimeter").(string), "/")
6+
d.Set("access_policy_id", fmt.Sprintf("accessPolicies/%s", parts[1]))
7+
8+
return obj, nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Set the access_policy_id field from part of the perimeter_name parameter.
2+
3+
// The is logic is inside the encoder since the access_policy_id field is part of
4+
// the mutex lock and encoders run before the lock is set.
5+
parts := strings.Split(d.Get("perimeter_name").(string), "/")
6+
d.Set("access_policy_id", fmt.Sprintf("accessPolicies/%s", parts[1]))
7+
8+
return obj, nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Set the access_policy_id field from part of the perimeter parameter.
2+
3+
// The is logic is inside the encoder since the access_policy_id field is part of
4+
// the mutex lock and encoders run before the lock is set.
5+
parts := strings.Split(d.Get("perimeter").(string), "/")
6+
d.Set("access_policy_id", fmt.Sprintf("accessPolicies/%s", parts[1]))
7+
8+
return obj, nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Set the access_policy_id field from part of the perimeter parameter.
2+
3+
// The is logic is inside the encoder since the access_policy_id field is part of
4+
// the mutex lock and encoders run before the lock is set.
5+
parts := strings.Split(d.Get("perimeter").(string), "/")
6+
d.Set("access_policy_id", fmt.Sprintf("accessPolicies/%s", parts[1]))
7+
8+
return obj, nil

0 commit comments

Comments
 (0)