feat(oci): add admin policy

This commit is contained in:
Kat Inskip 2024-06-09 10:44:54 -07:00
parent 3711cf0255
commit 0505f506d2
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
10 changed files with 244 additions and 12 deletions

View file

@ -0,0 +1,6 @@
resource "oci_identity_group" "this" {
compartment_id = var.tenancy_ocid
name = "terraform"
description = "terraform"
}

View file

@ -0,0 +1,4 @@
resource "oci_identity_user_group_membership" "this" {
user_id = oci_identity_user.this.id
group_id = oci_identity_group.this.id
}

View file

@ -0,0 +1,21 @@
locals {
policy_multi_line_statement = <<EOF
Allow group ${oci_identity_group.this.name} to manage vcns in compartment id ${var.tenancy_ocid} where ALL {
ANY { request.operation = 'CreateNetworkSecurityGroup', request.operation = 'DeleteNetworkSecurityGroup' }
}
EOF
}
resource "oci_identity_policy" "terraform-admin" {
compartment_id = var.tenancy_ocid
name = "terraform-admin"
description = "terraform-admin"
statements = [
"Allow group ${oci_identity_group.this.name} to manage all-resources in compartment id ${local.child_compartment_id}",
"Allow group ${oci_identity_group.this.name} to read virtual-network-family in compartment id ${var.tenancy_ocid}",
local.policy_multi_line_statement,
]
}