Skip to content

Commit 7b5f553

Browse files
yuhuyoyoclaude
andauthored
[ECI-1615] Add IAM for the Datadog group to manage the events forwarding pipeline (#125)
Grant the Datadog user group and the runtime dynamic groups the permissions needed to stand up the full event-forwarding pipeline out-of-band when the customer opts in via the Datadog UI: - oci_identity_tag_namespace.datadog_managed and oci_identity_tag.marker (DatadogManaged.marker) — applied to the events rule so the IAM grant below can scope to only Datadog-owned rules. - dd_auth (Datadog group manages the pipeline): * manage cloudevents-rules in tenancy with where-any on EVENTRULE_CREATE plus the DatadogManaged.marker target tag (CREATE unconditional, UPDATE/DELETE/READ scoped to tagged rules). * manage streams in compartment with the same where-any shape on STREAM_CREATE plus the DatadogManaged.marker target tag. - dynamic_group (runtime data path): * service_connector use stream-pull on streams with DatadogManaged.marker — the connector hub consumes from the events stream. * any-user use stream-push where principal.type = 'eventrule' AND target carries DatadogManaged.marker — OCI Events Service publishes only to Datadog-managed streams. The pipeline resources themselves (events function, events rule, stream) are not created by this stack — they are managed at runtime. This PR only adds the IAM so that flow works. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ba68aa3 commit 7b5f553

2 files changed

Lines changed: 42 additions & 6 deletions

File tree

  • datadog-integration/modules/auth
  • datadog-terraform-onboarding/modules/auth

datadog-integration/modules/auth/main.tf

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,22 @@ resource "oci_identity_domains_group" "dd_auth" {
180180
}
181181
}
182182

183+
resource "oci_identity_tag_namespace" "datadog_managed" {
184+
compartment_id = var.compartment_id
185+
name = "DatadogManaged"
186+
description = "[DO NOT REMOVE] Marker namespace for Datadog-managed resources. Removing this breaks the IAM grant scoping for the events rule."
187+
freeform_tags = var.tags
188+
defined_tags = var.defined_tags
189+
}
190+
191+
resource "oci_identity_tag" "marker" {
192+
tag_namespace_id = oci_identity_tag_namespace.datadog_managed.id
193+
name = "marker"
194+
description = "[DO NOT REMOVE] Applied to resources that the Datadog group is allowed to manage (e.g. the events rule). Removing this breaks the scoped IAM grant."
195+
}
196+
183197
resource "oci_identity_policy" "dd_auth" {
184-
depends_on = [null_resource.user_group_variable_validation, oci_identity_domains_group.dd_auth]
198+
depends_on = [null_resource.user_group_variable_validation, oci_identity_domains_group.dd_auth, oci_identity_tag_namespace.datadog_managed]
185199
compartment_id = var.tenancy_id
186200
description = "[DO NOT REMOVE] Policies required by Datadog User"
187201
name = var.user_policy_name
@@ -194,7 +208,9 @@ resource "oci_identity_policy" "dd_auth" {
194208
"Allow group id ${local.dd_group_ocid} to manage buckets in compartment id ${var.compartment_id} where target.bucket.name=/dd-*/",
195209
"Allow group id ${local.dd_group_ocid} to manage object-family in compartment id ${var.compartment_id} where target.bucket.name=/dd-*/",
196210
"Allow group id ${local.dd_group_ocid} to use fn-invocation in compartment id ${var.compartment_id}",
197-
"Endorse group id ${local.dd_group_ocid} to read objects in tenancy usage-report"
211+
"Endorse group id ${local.dd_group_ocid} to read objects in tenancy usage-report",
212+
"Allow group id ${local.dd_group_ocid} to manage cloudevents-rules in tenancy where any {request.permission = 'EVENTRULE_CREATE', target.resource.tag.DatadogManaged.marker = 'true'}",
213+
"Allow group id ${local.dd_group_ocid} to manage streams in compartment id ${var.compartment_id} where any {request.permission = 'STREAM_CREATE', target.resource.tag.DatadogManaged.marker = 'true'}",
198214
]
199215
freeform_tags = var.tags
200216
defined_tags = var.defined_tags
@@ -229,7 +245,9 @@ resource "oci_identity_policy" "dynamic_group" {
229245
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.service_connector.ocid} to use fn-function in compartment id ${var.compartment_id}",
230246
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.service_connector.ocid} to use fn-invocation in compartment id ${var.compartment_id}",
231247
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.forwarding_function.ocid} to read secret-bundles in compartment id ${var.compartment_id}",
232-
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.forwarding_function.ocid} to manage object-family in compartment id ${var.compartment_id} where target.bucket.name=/dd-*/"
248+
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.forwarding_function.ocid} to manage object-family in compartment id ${var.compartment_id} where target.bucket.name=/dd-*/",
249+
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.service_connector.ocid} to use stream-pull in compartment id ${var.compartment_id} where target.resource.tag.DatadogManaged.marker = 'true'",
250+
"Allow any-user to use stream-push in compartment id ${var.compartment_id} where all {request.principal.type = 'eventrule', target.resource.tag.DatadogManaged.marker = 'true'}"
233251
]
234252
freeform_tags = var.tags
235253
defined_tags = var.defined_tags

datadog-terraform-onboarding/modules/auth/main.tf

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,22 @@ resource "oci_identity_domains_group" "dd_auth" {
184184
}
185185
}
186186

187+
resource "oci_identity_tag_namespace" "datadog_managed" {
188+
compartment_id = var.compartment_id
189+
name = "DatadogManaged"
190+
description = "[DO NOT REMOVE] Marker namespace for Datadog-managed resources. Removing this breaks the IAM grant scoping for the events rule."
191+
freeform_tags = var.tags
192+
defined_tags = var.defined_tags
193+
}
194+
195+
resource "oci_identity_tag" "marker" {
196+
tag_namespace_id = oci_identity_tag_namespace.datadog_managed.id
197+
name = "marker"
198+
description = "[DO NOT REMOVE] Applied to resources that the Datadog group is allowed to manage (e.g. the events rule). Removing this breaks the scoped IAM grant."
199+
}
200+
187201
resource "oci_identity_policy" "dd_auth" {
188-
depends_on = [null_resource.user_group_variable_validation, oci_identity_domains_group.dd_auth]
202+
depends_on = [null_resource.user_group_variable_validation, oci_identity_domains_group.dd_auth, oci_identity_tag_namespace.datadog_managed]
189203
compartment_id = var.tenancy_id
190204
description = "[DO NOT REMOVE] Policies required by Datadog User"
191205
name = var.user_policy_name
@@ -198,7 +212,9 @@ resource "oci_identity_policy" "dd_auth" {
198212
"Allow group id ${var.existing_group_id != null && var.existing_group_id != "" ? var.existing_group_id : oci_identity_domains_group.dd_auth[0].ocid} to manage buckets in compartment id ${var.compartment_id} where target.bucket.name=/dd-*/",
199213
"Allow group id ${var.existing_group_id != null && var.existing_group_id != "" ? var.existing_group_id : oci_identity_domains_group.dd_auth[0].ocid} to manage object-family in compartment id ${var.compartment_id} where target.bucket.name=/dd-*/",
200214
"Allow group id ${var.existing_group_id != null && var.existing_group_id != "" ? var.existing_group_id : oci_identity_domains_group.dd_auth[0].ocid} to use fn-invocation in compartment id ${var.compartment_id}",
201-
"Endorse group id ${var.existing_group_id != null && var.existing_group_id != "" ? var.existing_group_id : oci_identity_domains_group.dd_auth[0].ocid} to read objects in tenancy usage-report"
215+
"Endorse group id ${var.existing_group_id != null && var.existing_group_id != "" ? var.existing_group_id : oci_identity_domains_group.dd_auth[0].ocid} to read objects in tenancy usage-report",
216+
"Allow group id ${var.existing_group_id != null && var.existing_group_id != "" ? var.existing_group_id : oci_identity_domains_group.dd_auth[0].ocid} to manage cloudevents-rules in tenancy where any {request.permission = 'EVENTRULE_CREATE', target.resource.tag.DatadogManaged.marker = 'true'}",
217+
"Allow group id ${var.existing_group_id != null && var.existing_group_id != "" ? var.existing_group_id : oci_identity_domains_group.dd_auth[0].ocid} to manage streams in compartment id ${var.compartment_id} where any {request.permission = 'STREAM_CREATE', target.resource.tag.DatadogManaged.marker = 'true'}",
202218
]
203219
freeform_tags = var.tags
204220
defined_tags = var.defined_tags
@@ -233,7 +249,9 @@ resource "oci_identity_policy" "dynamic_group" {
233249
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.service_connector.ocid} to use fn-function in compartment id ${var.compartment_id}",
234250
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.service_connector.ocid} to use fn-invocation in compartment id ${var.compartment_id}",
235251
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.forwarding_function.ocid} to read secret-bundles in compartment id ${var.compartment_id}",
236-
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.forwarding_function.ocid} to manage object-family in compartment id ${var.compartment_id} where target.bucket.name=/dd-*/"
252+
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.forwarding_function.ocid} to manage object-family in compartment id ${var.compartment_id} where target.bucket.name=/dd-*/",
253+
"Allow dynamic-group id ${oci_identity_domains_dynamic_resource_group.service_connector.ocid} to use stream-pull in compartment id ${var.compartment_id} where target.resource.tag.DatadogManaged.marker = 'true'",
254+
"Allow any-user to use stream-push in compartment id ${var.compartment_id} where all {request.principal.type = 'eventrule', target.resource.tag.DatadogManaged.marker = 'true'}"
237255
]
238256
freeform_tags = var.tags
239257
defined_tags = var.defined_tags

0 commit comments

Comments
 (0)