This repository contains prebuilt Terraform OCI Provider bindings for CDK for Terraform (CDKTF).
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.
- 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
Before using this provider, ensure you have:
- OCI Account: An active Oracle Cloud Infrastructure account
- OCI CLI Configuration: Properly configured OCI CLI with credentials (
~/.oci/config) - Node.js/Python: Node.js 20.x+ for TypeScript/JavaScript or Python 3.8+ for Python
- Terraform: Terraform v1.0+ installed
- CDKTF CLI: Install with
npm install -g cdktf-cli
Published from this repository at https://www.npmjs.com/package/cdktf-provider-oci.
npm install cdktf-provider-oci
Published at https://pypi.org/project/cdktf-provider-oci.
pip install cdktf-provider-oci
The OCI provider supports multiple authentication methods:
new OciProvider(this, 'oci', {
region: 'us-ashburn-1',
// Uses ~/.oci/config by default
});new OciProvider(this, 'oci', {
region: 'us-ashburn-1',
auth: 'InstancePrincipal',
});new OciProvider(this, 'oci', {
region: 'us-ashburn-1',
auth: 'ResourcePrincipal',
});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.
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.
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
# 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 deployAuto-generated API documentation for this provider is available in the docs folder of this repository:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the Apache-2.0 License.
- For issues with this provider package, please open an issue in this repository
- For OCI-specific issues, refer to Oracle Cloud Infrastructure Support
- For CDKTF issues, see CDKTF GitHub
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.
The provider version can be adjusted in ./.projenrc.js.