This project leverages Terraform to manage and deploy projects on Render. Follow the steps below to download Terraform, configure your project, deploy your services, and manage resources on Render.
- Operating System: I have used Windows (these instructions assume you are using PowerShell) for demonstration purposes.- Terraform: Download the Terraform cli tool from the Terraform downloads page.
- Render Account: Make sure you have an account with Render, and generate an API key.
- Git: Ensure Git is installed for version control.
-
Download Terraform
- Download the Terraform cli tool and save the
terraform.exefile in theinfrastructurefolder.
- Download the Terraform cli tool and save the
-
Initialize Git
- Create a
.gitignorefile in your project root. - Add files and folders to ignore.
- Create a
-
Configure the Provider
- Add the Render provider in your Terraform configuration files to manage resources on Render.
-
Configure the Project
- Define your project settings in your Terraform configuration files.
-
Generate API Key and Get Owner ID
- Log in to your Render account.
- Go to Workspace Settings and use the Website URL to locate the owner ID (it starts with
tea-). - Generate your API key from Render.
-
Initialize Terraform in the Render Directory
- Navigate to the
renderdirectory. - Run the Terraform initialization command:
../terraform init
- Navigate to the
-
Deploy the Project Using PowerShell
- Open a PowerShell terminal and navigate to the
renderdirectory. - Set the required environment variables:
$env:RENDER_OWNER_ID="tea-cxxxxxxxxxxxxxxxxxx0" $env:RENDER_API_KEY="rnd_etxxxxxxxxxxxxxxxxxxxxxxxxxxv"
- Apply the Terraform configuration:
../terraform apply
- Open a PowerShell terminal and navigate to the
-
Verify the Initial Deployment
- Check the Render dashboard to see the project created with a no service running tag.
-
Destroy the Deployment
- Run the following command to remove the deployed resources:
../terraform destroy
- Run the following command to remove the deployed resources:
-
Add a PostgreSQL Database
- Update your Terraform configuration to include a PostgreSQL database.
-
Reapply the Terraform Configuration
- Run the apply command again:
../terraform apply
- Run the apply command again:
-
Verify the Updated Deployment
- Check the Render dashboard again. The project should now appear with a service running tag.
-
Final Cleanup
- When you are finished, destroy the deployed resources by running:
../terraform destroy
- When you are finished, destroy the deployed resources by running:
- Environment Variables: Ensure that your environment variables (
RENDER_OWNER_IDandRENDER_API_KEY) are correctly set before runningterraform apply. - Terraform Commands: Always review the execution plan before applying or destroying resources.
- Documentation: Refer to the Terraform documentation and Render documentation for further details and troubleshooting.
