https://github.com/somethingwithproof/github-to-terraform
[infrastructure] Github To Terraform - A Shell project
https://github.com/somethingwithproof/github-to-terraform
shell terraform
Last synced: about 1 month ago
JSON representation
[infrastructure] Github To Terraform - A Shell project
- Host: GitHub
- URL: https://github.com/somethingwithproof/github-to-terraform
- Owner: somethingwithproof
- License: mit
- Created: 2024-06-06T06:17:01.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2026-03-16T02:08:42.000Z (3 months ago)
- Last Synced: 2026-03-16T07:34:17.472Z (3 months ago)
- Topics: shell, terraform
- Language: Shell
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Terraform Import Automation Script
## Overview
`terraport.sh` is a shell script designed to automate the process of importing existing GitHub resources into Terraform. This script leverages the GitHub CLI (`gh`) to list repositories and generate the necessary `terraform import` statements for various GitHub resources. It also configures the directory for Terraform Cloud.
## Prerequisites
Before running the script, ensure you have the following:
1. **GitHub CLI**: Installed and authenticated. You can install it from [GitHub CLI](https://cli.github.com/).
2. **Terraform**: Installed. You can download it from [Terraform](https://www.terraform.io/downloads.html).
3. **Environment Variables**: Set the following environment variables:
- `GITHUB_USERNAME`: Your GitHub username.
- `GITHUB_TOKEN`: Your GitHub personal access token.
- `TFE_TOKEN`: Your Terraform Cloud API token.
- `TFE_ORG`: Your Terraform Cloud organization name.
## Installation
1. Clone this repository
2. Copy `.env.example` to `.env` and configure your credentials
3. Make the script executable: `chmod +x terraport.sh`
## Usage
Run the script:
```bash
./terraport.sh
```
The script will:
1. List all repositories in your GitHub account
2. Generate Terraform import statements for each repository
3. Configure Terraform Cloud backend
## Development
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
## Security
See [SECURITY.md](SECURITY.md) for security policies and reporting procedures.
## License
See [LICENSE.md](LICENSE.md) for details.