Proof of Concept: This project was built as a proof-of-concept for generating Terraform configurations from existing AWS infrastructure. It will not be actively maintained and may not receive updates.
iacgen scans your AWS account and generates Terraform (HCL) configuration files for your existing resources. This can be useful for importing existing infrastructure into Infrastructure as Code or understanding your current AWS setup.
Currently supports:
- S3 Buckets: Generates the following resources:
aws_s3_bucketaws_s3_bucket_policyaws_s3_bucket_public_access_blockaws_s3_bucket_server_side_encryption_configurationaws_s3_bucket_versioningaws_s3_bucket_logging
cargo build --releaseThe binary will be available at target/release/iacgen.
- AWS credentials configured (via
~/.aws/credentials, environment variables, or IAM role) - Appropriate IAM permissions to describe resources
- OpenSSL: The AWS SDK requires SSL/TLS support
On macOS, the AWS SDK requires SSL certificate paths to be explicitly set. Before running iacgen, export these environment variables:
export SSL_CERT_FILE=/etc/ssl/cert.pem
export SSL_CERT_DIR=/etc/ssl/certsAlternatively, if you have OpenSSL installed via Homebrew:
export SSL_CERT_FILE=/opt/homebrew/etc/openssl@3/cert.pem
export SSL_CERT_DIR=/opt/homebrew/etc/openssl@3/certsYou can add these to your shell profile (~/.zshrc, ~/.bashrc, etc.) to make them permanent.
Generate Terraform configuration for S3 buckets:
# Output to stdout
iacgen s3
# Write to file
iacgen s3 --output s3.tf
# Use specific AWS profile
iacgen s3 --profile production
# Enable debug logging
iacgen s3 --debug-o, --output <PATH>- Write output to file instead of stdout-p, --profile <NAME>- AWS profile to use-d, --debug- Enable debug logging
The project follows a layered architecture:
core/ - Core traits and orchestration logic
aws/ - AWS resource fetching (implements ResourceFetcher)
terraform/ - Terraform HCL generation (implements TerraformGenerator)
output/ - Output handling (stdout, file)
This separation allows easy extension to support additional AWS services or IaC formats.
- Limited Resource Coverage: Only S3 is currently supported
- No State Management: Does not generate or manage Terraform state
- Basic Error Handling: May not gracefully handle all AWS API errors
- No Import Blocks: Generates configuration only, not
terraform importcommands - Read-Only: Does not modify any AWS resources
MIT - See LICENSE file for details
As this is a proof-of-concept project, contributions are not actively being accepted. Feel free to fork the repository for your own use.