Write your Terraform configurations using React components, leveraging React's composition patterns and TypeScript's type safety.
npm install -g @dkkoval/react-tf
The react-tf
CLI tool can process individual files or directories:
# Process current directory
react-tf
# Process specific directory
react-tf ./terraform
# Process specific file
react-tf ./terraform/main.tsx
# Process multiple files
react-tf ./terraform/main.tsx ./terraform/network.tsx
# Mix files and directories
react-tf ./terraform/main.tsx ./other-terraform
Here's a basic example:
import { Terraform, Provider, Resource } from '@dkkoval/react-tf';
const Infrastructure = () => (
<Terraform>
<Provider
name="aws"
configuration={{
region: "us-west-2"
}}
/>
<Resource
type="aws_instance"
name="example"
attributes={{
ami: "ami-0c55b159cbfafe1f0",
instance_type: "t2.micro"
}}
/>
</Terraform>
);
export default Infrastructure;
The examples directory contains several examples showcasing different features:
- Basic Usage - Simple provider and resource setup
- Advanced Configuration - Variables, multiple instances, and outputs
- React Patterns - Reusable components and composition patterns
# Install dependencies
bun install
# Run tests
bun test
# Build package
bun run build
Apache License 2.0 - see LICENSE for details.