Skip to main content

CDKTF bindings for Oracle Cloud Infrastructure

Project description

CDKTF OCI Provider Bindings

Generate and use Oracle Cloud Infrastructure (OCI) resources with the Cloud Development Kit for Terraform (CDKTF).

Note: Due to the size of the OCI provider (thousands of resources), bindings are generated locally in your project rather than distributed as a package.

Installation

Step 1: Set up your CDKTF project

If you haven't already, create a new CDKTF project:

npm install -g cdktf-cli
cdktf init --template typescript --local

Step 2: Configure the OCI provider

Add the OCI provider to your cdktf.json:

{
  "language": "typescript",
  "app": "npx ts-node main.ts",
  "terraformProviders": [
    "oracle/oci@~> 7.19"
  ]
}

Step 3: Generate the provider bindings

cdktf get

This creates a .gen/providers/oci/ directory with TypeScript bindings for all OCI resources.

Usage

TypeScript

import { Construct } from 'constructs';
import { App, TerraformStack } from 'cdktf';
import { OciProvider } from './.gen/providers/oci/provider';
import { CoreVcn } from './.gen/providers/oci/core-vcn';
import { CoreSubnet } from './.gen/providers/oci/core-subnet';

class MyStack extends TerraformStack {
  constructor(scope: Construct, name: string) {
    super(scope, name);

    // Configure OCI Provider
    new OciProvider(this, 'oci', {
      region: 'us-ashburn-1',
      tenancyOcid: process.env.OCI_TENANCY_OCID!,
      userOcid: process.env.OCI_USER_OCID!,
      fingerprint: process.env.OCI_FINGERPRINT!,
      privateKey: process.env.OCI_PRIVATE_KEY!,
    });

    // Create a VCN
    const vcn = new CoreVcn(this, 'my-vcn', {
      compartmentId: process.env.OCI_COMPARTMENT_ID!,
      cidrBlock: '10.0.0.0/16',
      displayName: 'My VCN',
    });

    // Create a Subnet
    new CoreSubnet(this, 'my-subnet', {
      compartmentId: process.env.OCI_COMPARTMENT_ID!,
      vcnId: vcn.id,
      cidrBlock: '10.0.1.0/24',
      displayName: 'My Subnet',
    });
  }
}

const app = new App();
new MyStack(app, 'oci-stack');
app.synth();

Python

import os
from constructs import Construct
from cdktf import App, TerraformStack
from imports.oci.provider import OciProvider
from imports.oci.core_vcn import CoreVcn
from imports.oci.core_subnet import CoreSubnet

class MyStack(TerraformStack):
    def __init__(self, scope: Construct, name: str):
        super().__init__(scope, name)

        # Configure OCI Provider
        OciProvider(self, "oci",
            region="us-ashburn-1",
            tenancy_ocid=os.environ["OCI_TENANCY_OCID"],
            user_ocid=os.environ["OCI_USER_OCID"],
            fingerprint=os.environ["OCI_FINGERPRINT"],
            private_key=os.environ["OCI_PRIVATE_KEY"]
        )

        # Create a VCN
        vcn = CoreVcn(self, "my-vcn",
            compartment_id=os.environ["OCI_COMPARTMENT_ID"],
            cidr_block="10.0.0.0/16",
            display_name="My VCN"
        )

        # Create a Subnet
        CoreSubnet(self, "my-subnet",
            compartment_id=os.environ["OCI_COMPARTMENT_ID"],
            vcn_id=vcn.id,
            cidr_block="10.0.1.0/24",
            display_name="My Subnet"
        )

app = App()
MyStack(app, "oci-stack")
app.synth()

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

How It Works

When you run cdktf get, the CDKTF CLI:

  1. Downloads the OCI Terraform provider
  2. Generates TypeScript/Python bindings for all resources
  3. Places them in your project directory (.gen/ or imports/)
  4. Makes them available for import in your code

This gives you:

  • ✅ Type-safe access to all OCI resources
  • ✅ IntelliSense/autocomplete in your IDE
  • ✅ The exact provider version you specify
  • ✅ No large dependencies in node_modules

Troubleshooting

Common Import Patterns

// TypeScript - Import from locally generated bindings
import { OciProvider } from './.gen/providers/oci/provider';
import { CoreInstance } from './.gen/providers/oci/core-instance';
# Python - Import from locally generated bindings
from imports.oci.provider import OciProvider
from imports.oci.core_instance import CoreInstance

Finding Resource Names

After running cdktf get, you can find all available resources in:

  • TypeScript: .gen/providers/oci/ directory
  • Python: imports/oci/ directory

Resource naming convention:

  • Terraform resource oci_core_instance becomes CoreInstance
  • Terraform resource oci_identity_compartment becomes IdentityCompartment
  • Data sources follow the same pattern with Data prefix: DataOciCoreInstances

Resources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdktf_provider_oci-0.0.2.tar.gz (33.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdktf_provider_oci-0.0.2-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file cdktf_provider_oci-0.0.2.tar.gz.

File metadata

  • Download URL: cdktf_provider_oci-0.0.2.tar.gz
  • Upload date:
  • Size: 33.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cdktf_provider_oci-0.0.2.tar.gz
Algorithm Hash digest
SHA256 706869fd1162e012e4fbeb79e5c2430a6649a4a50379d59c47e90420a92a5d23
MD5 48a12bb94cc9e3fcf7c875032cc95f52
BLAKE2b-256 e3bc0d1cf154ffb755d64ee97fdd393cf1ccc206d96138acf7d4c2f50a29d99d

See more details on using hashes here.

File details

Details for the file cdktf_provider_oci-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for cdktf_provider_oci-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4d94b60e05219f71ccd9078ef60c04cf9378ecfe43d7751013c5ccde593b6955
MD5 c9fa210a537b5c44e1e698b5dc35b5d5
BLAKE2b-256 6b92807fa8a3bec5b9b34f6942b97074c1d4a82e5a6c29522286483d334f6416

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page