Skip to content

Commit b3536a2

Browse files
committed
Add Policy Parameters support for Managed constraints
1 parent 075e151 commit b3536a2

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

mmv1/products/orgpolicy/Policy.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ examples:
5454
- name: 'org_policy_policy_dry_run_spec'
5555
primary_resource_id: 'primary'
5656
exclude_test: true
57+
- name: 'org_policy_policy_parameters_enforce'
58+
primary_resource_id: 'primary'
59+
exclude_test: true
60+
min_version: 'beta'
5761
parameters:
5862
- name: 'parent'
5963
type: String
@@ -121,6 +125,14 @@ properties:
121125
send_empty_value: true
122126
custom_flatten: 'templates/terraform/custom_flatten/enum_bool.go.tmpl'
123127
custom_expand: 'templates/terraform/custom_expand/enum_bool.go.tmpl'
128+
- name: 'parameters'
129+
description: 'Optional. Required for Managed Constraints if parameters defined in constraints. Pass parameter values when policy enforcement is enabled. Ensure that parameter value types match those defined in the constraint definition. For example: { \"allowedLocations\" : [\"us-east1\", \"us-west1\"], \"allowAll\" : true }'
130+
min_version: beta
131+
custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
132+
custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
133+
state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
134+
validation:
135+
function: 'validation.StringIsJSON'
124136
- name: 'condition'
125137
type: NestedObject
126138
description: 'A condition which determines whether this rule is used in the evaluation of the policy. When set, the `expression` field in the `Expr'' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag(''/tag_key_short_name, ''tag_value_short_name'')". or "resource.matchTagId(''tagKeys/key_id'', ''tagValues/value_id'')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag(''123456789/environment, ''prod'')". or "resource.matchTagId(''tagKeys/123'', ''tagValues/456'')".'
@@ -197,6 +209,14 @@ properties:
197209
send_empty_value: true
198210
custom_flatten: 'templates/terraform/custom_flatten/enum_bool.go.tmpl'
199211
custom_expand: 'templates/terraform/custom_expand/enum_bool.go.tmpl'
212+
- name: 'parameters'
213+
description: 'Optional. Required for Managed Constraints if parameters defined in constraints. Pass parameter values when policy enforcement is enabled. Ensure that parameter value types match those defined in the constraint definition. For example: { \"allowedLocations\" : [\"us-east1\", \"us-west1\"], \"allowAll\" : true }'
214+
min_version: beta
215+
custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
216+
custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
217+
state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
218+
validation:
219+
function: 'validation.StringIsJSON'
200220
- name: 'condition'
201221
type: NestedObject
202222
description: 'A condition which determines whether this rule is used in the evaluation of the policy. When set, the `expression` field in the `Expr'' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag(''/tag_key_short_name, ''tag_value_short_name'')". or "resource.matchTagId(''tagKeys/key_id'', ''tagValues/value_id'')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag(''123456789/environment, ''prod'')". or "resource.matchTagId(''tagKeys/123'', ''tagValues/456'')".'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
resource "google_org_policy_policy" "primary" {
2+
provider = google-beta
3+
name = "projects/${google_project.basic.name}/policies/iam.managed.disableServiceAccountKeyUpload"
4+
parent = "projects/${google_project.basic.name}"
5+
6+
spec {
7+
rules {
8+
enforce = "FALSE"
9+
parameters {
10+
"allowAll" : true
11+
"allowedLocations" : ["us-east1", "us-west1"]
12+
}
13+
}
14+
}
15+
}
16+
17+
resource "google_project" "basic" {
18+
project_id = "id"
19+
name = "id"
20+
org_id = "123456789"
21+
deletion_policy = "DELETE"
22+
}

mmv1/third_party/terraform/services/orgpolicy/resource_org_policy_policy_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,4 @@ func testAccCheckOrgPolicyPolicyDestroyProducer(t *testing.T) func(s *terraform.
458458
return nil
459459
}
460460
}
461+

0 commit comments

Comments
 (0)