Skip to content

This repository contains Terraform configurations for deploying and managing projects on Render. It automates the creation and management of services, including setting up a PostgreSQL database.

Notifications You must be signed in to change notification settings

P566-Practicums/Infrastructure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Render Deployment

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.

Prerequisites

  • 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.

Steps

  1. Download Terraform

    • Download the Terraform cli tool and save the terraform.exe file in the infrastructure folder.
  2. Initialize Git

    • Create a .gitignore file in your project root.
    • Add files and folders to ignore.
  3. Configure the Provider

    • Add the Render provider in your Terraform configuration files to manage resources on Render.
  4. Configure the Project

    • Define your project settings in your Terraform configuration files.
  5. 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.
  6. Initialize Terraform in the Render Directory

    • Navigate to the render directory.
    • Run the Terraform initialization command:
      ../terraform init
  7. Deploy the Project Using PowerShell

    • Open a PowerShell terminal and navigate to the render directory.
    • Set the required environment variables:
      $env:RENDER_OWNER_ID="tea-cxxxxxxxxxxxxxxxxxx0"
      $env:RENDER_API_KEY="rnd_etxxxxxxxxxxxxxxxxxxxxxxxxxxv"
    • Apply the Terraform configuration:
      ../terraform apply
  8. Verify the Initial Deployment

    • Check the Render dashboard to see the project created with a no service running tag.
  9. Destroy the Deployment

    • Run the following command to remove the deployed resources:
      ../terraform destroy
  10. Add a PostgreSQL Database

    • Update your Terraform configuration to include a PostgreSQL database.
  11. Reapply the Terraform Configuration

    • Run the apply command again:
      ../terraform apply
  12. Verify the Updated Deployment

    • Check the Render dashboard again. The project should now appear with a service running tag.

    img.png

  13. Final Cleanup

    • When you are finished, destroy the deployed resources by running:
      ../terraform destroy

Additional Information

  • Environment Variables: Ensure that your environment variables (RENDER_OWNER_ID and RENDER_API_KEY) are correctly set before running terraform 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.

About

This repository contains Terraform configurations for deploying and managing projects on Render. It automates the creation and management of services, including setting up a PostgreSQL database.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages