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.1.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.1-py3-none-any.whl (80.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cdktf_provider_oci-1.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 8393fa2a9b3fcc13cc8a85dfe0978718040744c4a928732ddacc21eadebbe901
MD5 79c16440225906eb01f6c8ec3348d510
BLAKE2b-256 5e021927454824092ddafba9c208621c2c7c5236443b71e26972d684f79d71d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cdktf_provider_oci-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0908d4c93a945117cfc03bb8af2d12129030f4589ae717c2edfb7fd4c8831db5
MD5 91901b32c1521379d7dd3181f43a00db
BLAKE2b-256 dad61accb0f97f4eed97a0c35d5dda67a03026e0b27ebed365265fe474ed2fe9

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