Skip to main content

Prebuilt oci Provider for Terraform CDK (cdktf)

Project description

CDKTF Provider for Oracle Cloud Infrastructure (OCI)

npm version PyPI version

This repository contains prebuilt Terraform OCI Provider bindings for CDK for Terraform (CDKTF).

About

The cdktf-provider-oci package provides TypeScript/JavaScript and Python bindings for the Oracle Cloud Infrastructure Terraform Provider, enabling you to manage OCI resources using CDKTF with type safety and IDE support.

Features

  • Complete OCI Coverage: Access to all OCI resources and data sources available in the Terraform OCI Provider
  • Type Safety: Full TypeScript/Python type definitions for all resources
  • IDE Support: IntelliSense and autocomplete for resource properties
  • CDKTF Integration: Seamlessly works with CDK for Terraform constructs and workflows

Prerequisites

Before using this provider, ensure you have:

  1. OCI Account: An active Oracle Cloud Infrastructure account
  2. OCI CLI Configuration: Properly configured OCI CLI with credentials (~/.oci/config)
  3. Node.js/Python: Node.js 20.x+ for TypeScript/JavaScript or Python 3.8+ for Python
  4. Terraform: Terraform v1.0+ installed
  5. CDKTF CLI: Install with npm install -g cdktf-cli

Available Packages

npm

Published from this repository at https://www.npmjs.com/package/cdktf-provider-oci (owner: sureshveeragoni).

npm install cdktf-provider-oci

PyPI

Published at https://pypi.org/project/cdktf-provider-oci (owner: sureshveeragoni).

pip install cdktf-provider-oci

Configuration

Authentication

The OCI provider supports multiple authentication methods:

1. API Key Authentication (Default)

new OciProvider(this, 'oci', {
  region: 'us-ashburn-1',
  // Uses ~/.oci/config by default
});

2. Instance Principal Authentication

new OciProvider(this, 'oci', {
  region: 'us-ashburn-1',
  auth: 'InstancePrincipal',
});

3. Resource Principal Authentication

new OciProvider(this, 'oci', {
  region: 'us-ashburn-1',
  auth: 'ResourcePrincipal',
});

Usage

TypeScript

import { App, TerraformStack } from 'cdktf';
import { Construct } from 'constructs';
import { OciProvider } from 'cdktf-provider-oci/lib/provider';
import { CoreInstance } from 'cdktf-provider-oci/lib/core-instance';

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

    new OciProvider(this, 'oci', {
      region: 'us-ashburn-1',
    });

    new CoreInstance(this, 'example', {
      compartmentId: 'ocid1.compartment.oc1..exampleuniqueID',
      availabilityDomain: 'kIdk:US-ASHBURN-AD-1',
      shape: 'VM.Standard.E4.Flex',
      sourceDetails: {
        sourceType: 'image',
        imageId: 'ocid1.image.oc1..exampleuniqueID',
      },
      createVnicDetails: {
        subnetId: 'ocid1.subnet.oc1..exampleuniqueID',
      },
    });
  }
}

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

Install dependencies with npm install cdktf cdktf-provider-oci constructs before synthesizing.

Python

from constructs import Construct
from cdktf import App, TerraformStack
from cdktf_provider_oci.provider import OciProvider
from cdktf_provider_oci.core_instance import CoreInstance


class MyStack(TerraformStack):
    def __init__(self, scope: Construct, construct_id: str) -> None:
        super().__init__(scope, construct_id)

        OciProvider(self, "oci", region="us-ashburn-1")

        CoreInstance(self, "example",
            compartment_id="ocid1.compartment.oc1..exampleuniqueID",
            availability_domain="kIdk:US-ASHBURN-AD-1",
            shape="VM.Standard.E4.Flex",
            source_details={
                "source_type": "image",
                "image_id": "ocid1.image.oc1..exampleuniqueID",
            },
            create_vnic_details={
                "subnet_id": "ocid1.subnet.oc1..exampleuniqueID",
            },
        )


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

Install dependencies with pip install cdktf cdktf-provider-oci constructs before synthesizing.

Complete Example Project

For a complete working example of using this provider, check out the cdktf-oci-example repository, which demonstrates:

  • Setting up a VCN (Virtual Cloud Network)
  • Creating compute instances
  • Configuring security lists and route tables
  • Managing storage resources
  • And more OCI resource configurations

Quick Start with Example Project

# Clone the example repository
git clone https://github.com/veeragoni/cdktf-oci-example.git
cd cdktf-oci-example

# Install dependencies
npm install

# Deploy to OCI
cdktf deploy

Documentation

Provider Documentation

CDKTF Documentation

API Reference

Auto-generated API documentation for this provider is available in the docs folder of this repository:

Contributing

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

License

This project is licensed under the Apache-2.0 License.

Support

Versioning

This project is explicitly not tracking the Terraform oci provider version 1:1. In fact, it always tracks latest of ~> 7.19.0 with every release. If there are scenarios where you explicitly have to pin your provider version, you can do so by generating the provider constructs manually.

These are the upstream dependencies:

If there are breaking changes (backward incompatible) in any of the above, the major version of this project will be bumped.

Provider Version

The provider version can be adjusted in ./.projenrc.js.

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-1.1.2.tar.gz (79.7 MB 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-1.1.2-py3-none-any.whl (80.0 MB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cdktf_provider_oci-1.1.2.tar.gz
Algorithm Hash digest
SHA256 4ab8ad61d03ac4e9fa684c4c3564e870ec194ed78f1d5f2e529432f433f213f1
MD5 aa39625fc3daa7bbd33a4c316c01590a
BLAKE2b-256 6e17bd8fb951d7761c0c3574514f53162828a08ae4d8335644bec0206ea2b19b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cdktf_provider_oci-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a477f5f8811756b270f20f3aca0cad1b00a911c49329342bfeba5766755b0a38
MD5 1527a1613bf9ccb10c581ac59becb104
BLAKE2b-256 d6896622c7839678f97dad77181a110ed4dd7a72d7e2f38b46d0fba5ddfee012

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