|
| 1 | +resource "tls_private_key" "flexvolume_driver_user_key" { |
| 2 | + algorithm = "RSA" rsa_bits = 2048 |
| 3 | +} |
| 4 | + |
| 5 | +resource "oci_identity_group" "flexvolume_driver_group" { |
| 6 | + name = "${var.label_prefix}flexvolume_driver_group" |
| 7 | + description = "Terraform created group for OCI Cloud Controller Manager" |
| 8 | +} |
| 9 | + |
| 10 | +resource "oci_identity_user" "flexvolume_driver_user" { |
| 11 | + name = "${var.label_prefix}flexvolume_driver_user" |
| 12 | + description = "Terraform created user for OCI Cloud Controller Manager" |
| 13 | +} |
| 14 | + |
| 15 | +resource "oci_identity_api_key" "flexvolume_driver_key_assoc" { |
| 16 | + user_id = "${oci_identity_user.flexvolume_driver_user.id}" |
| 17 | + key_value = "${tls_private_key.flexvolume_driver_user_key.public_key_pem}" |
| 18 | +} |
| 19 | + |
| 20 | +resource "oci_identity_user_group_membership" "flexvolume_driver_user_group_assoc" { |
| 21 | + compartment_id = "${var.tenancy_ocid}" |
| 22 | + user_id = "${oci_identity_user.flexvolume_driver_user.id}" |
| 23 | + group_id = "${oci_identity_group.flexvolume_driver_group.id}" |
| 24 | +} |
| 25 | + |
| 26 | +resource "oci_identity_policy" "flexvolume_driver_policy" { |
| 27 | + depends_on = ["oci_identity_group.flexvolume_driver_group"] |
| 28 | + compartment_id = "${var.compartment_ocid}" |
| 29 | + name = "${var.label_prefix}flexvolume_driver_policy" |
| 30 | + description = "${var.label_prefix}flexvolume_driver_group policy" |
| 31 | + statements = [ |
| 32 | + "Allow group id ${oci_identity_group.flexvolume_driver_group.id} to read vnic-attachments in compartment id ${var.compartment_ocid}", |
| 33 | + "Allow group id ${oci_identity_group.flexvolume_driver_group.id} to read vnics in compartment id ${var.compartment_ocid}", |
| 34 | + "Allow group id ${oci_identity_group.flexvolume_driver_group.id} to read instances in compartment id ${var.compartment_ocid}", |
| 35 | + "Allow group id ${oci_identity_group.flexvolume_driver_group.id} to read subnets in compartment id ${var.compartment_ocid}", |
| 36 | + "Allow group id ${oci_identity_group.flexvolume_driver_group.id} to use volumes in compartment id ${var.compartment_ocid}", |
| 37 | + "Allow group id ${oci_identity_group.flexvolume_driver_group.id} to use instances in compartment id ${var.compartment_ocid}", |
| 38 | + "Allow group id ${oci_identity_group.flexvolume_driver_group.id} to manage volume-attachments in compartment id ${var.compartment_ocid}", |
| 39 | + ] |
| 40 | +} |
0 commit comments