CodexBloom - Programming Q&A Platform

OCI Identity and Access Management: Permissions guide with Service Gateway in Terraform

👀 Views: 0 💬 Answers: 1 📅 Created: 2025-06-20
oci terraform iam HCL

I'm maintaining legacy code that I'm maintaining legacy code that I'm working with a frustrating question with configuring a service gateway in Oracle Cloud Infrastructure (OCI) using Terraform. Despite having the necessary permissions set up in my IAM policies, I'm working with a `403 Forbidden` behavior when trying to deploy my Terraform configuration. The code I’m using is as follows: ```hcl provider "oci" { tenancy_ocid = var.tenancy_ocid user_ocid = var.user_ocid fingerprint = var.fingerprint private_key_path = var.private_key_path region = var.region } resource "oci_core_virtual_cloud_network" "vcn" { compartment_id = var.compartment_id display_name = "my-vcn" cidr_block = "10.0.0.0/16" } resource "oci_core_service_gateway" "service_gateway" { compartment_id = var.compartment_id display_name = "my-service-gateway" vcn_id = oci_core_virtual_cloud_network.vcn.id service_id = "<service-id>" } ``` I’ve double-checked that the IAM policy includes the following: ```plaintext Allow group <your-group> to manage service-gateways in compartment <compartment-name> ``` However, when I run `terraform apply`, I receive the behavior: ``` behavior: behavior creating ServiceGateway: unable to create service gateway: (403: Forbidden) The request is not authorized. ``` I confirmed that my user is part of the `<your-group>`, and I also set the correct compartment ID. I’ve also tried re-authenticating and refreshing my Terraform state, but the scenario continues. Is there something I'm missing regarding the permissions, or could it be a misconfiguration in the Terraform setup? Any insights or tips to troubleshoot this would be greatly appreciated! I've been using Hcl for about a year now.