Skip to content

OAMPC/DreamRenewablesInfrastructure

Repository files navigation

Dream Renewables Infrastructure

Contents

About This Project

This is the Repo/Code for the infrastructure required to run the Dream Renewables Web Application. This application primarily utilises the following technologies:

Terraform requires state locking which for larger projects requires a DB to manage to ensure there is not overwriting. As this is run by only a few devs this unnecessary and can be managed with good communication i.e not making changes to the terraform at the same time.

Setup

Requirements

This project requires the following pre-requisites:

  1. Terraform
  2. NodeJs
  3. AWS-Vault

Cloud Providers

Heroku
  • In order to locally make changes to Heroku you'll need to authorize with Heroku. When logged in as the Heroku admin the following command will show you a already made authorization token
    • heroku authorizations - will show authorizations, there should be one called terraform-dream-renewables-website
    • heroku authorizations:info <ID> - will show data on a specified authorization
    • export HEROKU_API_KEY=<TOKEN> HEROKU_EMAIL=<EMAIL> - This will set the keys in order for you to make usual terraform commands
AWS
  • In order to locally make changes to AWS you'll need to assume the credentials of the terraform-client.
    1. If not already installed setup aws vault via their installing documentation for installation on windows I'd recommend using chocolatey and for mac i'd recommend using HomebrewCask
    2. Add the terraform-client to your aws-vault: aws-vault add terraform-client

Installing project dependencies

This project uses Husky and lint-staged to enforce consistent formatting of Terraform files using terraform fmt before committing changes.

  1. In the root directory Install dependencies: npm i
  2. The pre-commit file .husky/pre-commit should contain the following line only: npx lint-staged
    • The subfolder .husky/_ is required and should not be committed by default
  3. Ensure the pre-commit file is executable: chmod +x .husky/pre-commit

Usage

Running the IaC

To run the application you must ensure you've followed the setup steps

  • Cloned the repo
  • Navigated to the terraform directory you want to work on as this project uses several terraform states to manage each system in the overall web application
  • If necessary initialise the provider: terraform init
  • If you are working in a directory which has aws as a provider you will need to run the commands with aws-vault terraform-client. This can be done by starting a subshell with temporary credentials: aws-vault exec terraform-client or by prefixing the below commands with aws-vault exec terraform-client -- for example aws-vault exec terraform-client -- terraform plan
  • Review the terraform plan and ensure nothing is irregular. If terraform is looking to create pre-existing resources you made need to import pre-existing infrastructure. This can be done with the following command: terraform import <resource_type>.<resource_name_in_tf_file> <existing_infrastructure_identifier>

Further documentation

Related Repositories

Name Description
Dream Renewables Cms The Content Management System for this web application
Dream Renewables Frontend React code for this web application

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages