Skip to content

Commit f3d2390

Browse files
authored
Terraform integration for adding output only RoleBinding ID to entitlement resource (#14218)
1 parent 003d947 commit f3d2390

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

mmv1/products/privilegedaccessmanager/Entitlement.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ properties:
225225
description: |
226226
The expression field of the IAM condition to be associated with the role. If specified, a user with an active grant for this entitlement would be able to access the resource only if this condition evaluates to true for their request.
227227
https://cloud.google.com/iam/docs/conditions-overview#attributes.
228+
- name: 'id'
229+
type: String
230+
description: |
231+
Output Only. The ID corresponding to this role binding in the policy binding. This will be unique within an entitlement across time. Gets re-generated each time the entitlement is updated.
232+
min_version: beta
233+
output: true
228234
- name: 'maxRequestDuration'
229235
type: String
230236
description: |

mmv1/third_party/terraform/services/privilegedaccessmanager/resource_privileged_access_manager_entitlement_test.go renamed to mmv1/third_party/terraform/services/privilegedaccessmanager/resource_privileged_access_manager_entitlement_test.go.tmpl

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,79 @@ func TestAccPrivilegedAccessManagerEntitlement_privilegedAccessManagerEntitlemen
4444
})
4545
}
4646

47+
{{ if ne $.TargetVersionName `ga` -}}
48+
func TestAccPrivilegedAccessManagerEntitlement_roleBindingId_beta(t *testing.T) {
49+
t.Parallel()
50+
51+
context := map[string]interface{}{
52+
"random_suffix": acctest.RandString(t, 10),
53+
"project_name": envvar.GetTestProjectFromEnv(),
54+
}
55+
56+
acctest.VcrTest(t, resource.TestCase{
57+
PreCheck: func() { acctest.AccTestPreCheck(t) },
58+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
59+
CheckDestroy: testAccCheckPrivilegedAccessManagerEntitlementDestroyProducer(t),
60+
Steps: []resource.TestStep{
61+
{
62+
Config: testAccPrivilegedAccessManagerEntitlement_privilegedAccessManagerEntitlementBasicExample_basic_beta(context),
63+
Check: resource.ComposeTestCheckFunc(
64+
// Checks the output-only role binding id field
65+
resource.TestCheckResourceAttrSet(
66+
"google_privileged_access_manager_entitlement.tfentitlement",
67+
"privileged_access.0.gcp_iam_access.0.role_bindings.0.id",
68+
),
69+
),
70+
},
71+
},
72+
})
73+
}
74+
75+
func testAccPrivilegedAccessManagerEntitlement_privilegedAccessManagerEntitlementBasicExample_basic_beta(context map[string]interface{}) string {
76+
return acctest.Nprintf(`
77+
resource "google_privileged_access_manager_entitlement" "tfentitlement" {
78+
provider = google-beta
79+
entitlement_id = "tf-test-example-entitlement%{random_suffix}"
80+
location = "global"
81+
max_request_duration = "43200s"
82+
parent = "projects/%{project_name}"
83+
requester_justification_config {
84+
unstructured{}
85+
}
86+
eligible_users {
87+
principals = ["group:[email protected]"]
88+
}
89+
privileged_access{
90+
gcp_iam_access{
91+
role_bindings{
92+
role = "roles/storage.admin"
93+
condition_expression = "request.time < timestamp(\"2024-04-23T18:30:00.000Z\")"
94+
}
95+
resource = "//cloudresourcemanager.googleapis.com/projects/%{project_name}"
96+
resource_type = "cloudresourcemanager.googleapis.com/Project"
97+
}
98+
}
99+
additional_notification_targets {
100+
admin_email_recipients = ["[email protected]"]
101+
requester_email_recipients = ["[email protected]"]
102+
}
103+
approval_workflow {
104+
manual_approvals {
105+
require_approver_justification = true
106+
steps {
107+
approvals_needed = 1
108+
approver_email_recipients = ["[email protected]"]
109+
approvers {
110+
principals = ["group:[email protected]"]
111+
}
112+
}
113+
}
114+
}
115+
}
116+
`, context)
117+
}
118+
{{- end }}
119+
47120
func testAccPrivilegedAccessManagerEntitlement_privilegedAccessManagerEntitlementBasicExample_basic(context map[string]interface{}) string {
48121
return acctest.Nprintf(`
49122
resource "google_privileged_access_manager_entitlement" "tfentitlement" {

0 commit comments

Comments
 (0)