Oracle Cloud Infrastructure (OCI) Authentication¶
DRACO authenticates to Oracle Cloud Infrastructure (OCI) with an API key of an OCI user: the user OCID, the tenancy OCID, the key fingerprint, the private key and the region, entered in the provider form (see Getting started).
API Key Authentication¶
Setting Up API Keys¶
Option A: Generate API Key Using OCI Console (Simpler)¶
- Log in to OCI Console
- Navigate to Identity → Users → Select your user
- In the Resources section, click API Keys
- Click Add API Key
- Select Generate API Key Pair
- Click Download Private Key - save this file as
~/.oci/oci_api_key.pem - Click Add
- The console will display a configuration file preview with:
userOCIDfingerprinttenancyOCID-
region -
Copy the entire configuration snippet from the console and paste it into
~/.oci/config - Add the
key_fileparameter pointing to your downloaded private key:
[DEFAULT]
user=ocid1.user.oc1..aaaaaaaexample
fingerprint=11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:11
tenancy=ocid1.tenancy.oc1..aaaaaaaexample
region=us-ashburn-1
key_file=~/.oci/oci_api_key.pem # Add this line
- Set proper permissions:
chmod 600 ~/.oci/oci_api_key.pem chmod 600 ~/.oci/config
Option B: Generate API Key Manually¶
- Generate the key pair locally:
mkdir -p ~/.oci
openssl genrsa -out ~/.oci/oci_api_key.pem 2048
chmod 600 ~/.oci/oci_api_key.pem
openssl rsa -pubout -in ~/.oci/oci_api_key.pem -out ~/.oci/oci_api_key_public.pem
- Upload the public key to OCI Console:
- Navigate to Identity → Users → Select your user
- In the Resources section, click API Keys
- Click Add API Key
- Select Paste Public Key or Choose Public Key File
- Paste or upload the contents of
~/.oci/oci_api_key_public.pem -
Click Add
-
The console will display the configuration file preview with your user OCID, fingerprint, tenancy OCID, and region.
-
Copy the configuration snippet from the console and create
~/.oci/config:
[DEFAULT]
user=<user_ocid_from_console>
fingerprint=<fingerprint_from_console>
tenancy=<tenancy_ocid_from_console>
region=<region_from_console>
key_file=~/.oci/oci_api_key.pem
- Set proper permissions:
chmod 600 ~/.oci/config chmod 600 ~/.oci/oci_api_key.pem
Security Best Practices¶
API Key Security¶
- Rotate API Keys Regularly
- OCI recommends rotating API keys every 90 days
-
DRACO includes a check for this:
identity_user_api_keys_rotated_90_days -
Use Separate Keys Per Environment
- Development, staging, and production should use different API keys
-
Use profiles to manage multiple environments
-
Restrict Key Permissions
- Follow the principle of least privilege
-
Grant only read permissions for security auditing
-
Secure Key Storage
chmod 600 ~/.oci/oci_api_key.pem chmod 600 ~/.oci/config -
Never Commit Keys to Version Control
- Add
~/.oci/to.gitignore - Use secret management systems for automation
Troubleshooting¶
Permission Errors¶
Error: "Authorization failed or requested resource not found"
Cause: Insufficient IAM permissions
Solution: Add required policies (see the OCI IAM policies documentation)