LAB 38 ‐ Service Gateway: Private Access to Supported OCI Public Services - gautam-amitesh/OCI GitHub Wiki
OCI has native public services whose native endpoints (network destinations) reside outside customer VCNs and have publicly routable IP addresses by default. Some examples of OCI public services are Object Storage and Archive Storage. Therefore, to access Object Storage, you need either public internet access (Internet/NAT Gateway) or a Service Gateway.
A Service Gateway in OCI is a regional component attached to a single VCN that enables resources in private subnets to privately access supported OCI public services without exposing traffic to the public internet. It does not require public IP addresses, NAT Gateways, or Internet Gateways to reach Oracle services because it allows traffic to travel over the Oracle Cloud network fabric. Additionally, only resources within the VCN can initiate communication with the service endpoints, while the external services cannot initiate connections back to the VCN.
Create Service Gateway
-
Navigation
Navigation menu > Networking > Virtual cloud networks > Spoke VCN > Gateways > Service Gateways -
Click
Create Service Gateway -
Enter
Name, selectnetwork-compartment, selectOCI IAD Object StorageService for accessing only Object Storage, and final clickCreate Service Gateway
Create Route Rules
-
Navigation
Navigation menu > Networking > Virtual cloud networks > Spoke VCN > Routing > RT-spoke_vcn-manual > Route Rules -
Click
Add Route Rules -
Select
Service GatewayinTarget Type -
Select
OCI IAD Object StorageinDestination Service, selectTarget Service Gateway Compartment&Target Service Gateway, and finally clickAdd Route Rules
Allow Egress Rule
-
Navigation
Navigation menu > Networking > Virtual cloud networks > Spoke VCN > Security > Security Lists > SL-private_subnet-01-spoke_vcn-manual > Security Rules > Egress Rules -
I have already allowed outbound traffic to
0.0.0.0/0usingAll Protocols
OCI-CLI Installation & Configuration
-
Install
python3&python3-pipif not already installed# Verification python --version python3 -m pip --version # Installation sudo dnf install python3 python3-pip -y -
Install
oci-clifrompip# Installation python3 -m pip install oci-cli --upgrade # Verification oci --version -
OCI-CLI Configuration file setup`
oci setup config
Setup API Key in OCI Console
-
Navigation
Profile > Identity domain: Default > User management > select user (eg. [email protected]) > API keys -
Choose
Paste a public key, navigate to the terminal, copy paste the content of/home/opc/.oci/oci_api_key_public.pemfile, and clickAdd -
Match your fingerprint shown here and click
Closeand now we are ready to upload objects in the bucket
Upload Objects to Bucket using OCI-CLI via Service Gateway
-
Delete the NAT Gateway to validate that objects can be uploaded to the bucket using only the Service Gateway, since the reverse scenario is possible.
-
Create compressed and archived file to test upload
# Create Directory mkdir scripts # Create Script Files touch scripts/script01.sh scripts/script02.sh # Verify Creation ls -lrth scripts/ # Create Compressed Archive tar -cjvf scripts_20261009.tar.bz2 scripts # Verify Creation ls -lrth -
Run OCI-CLI command to upload this archive file to OCI bucket
oci os object put -bn <bucket-name> --file <archive-name> -
Verify object upload in bucket via OCI Console