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.
This project requires the following pre-requisites:
- 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 calledterraform-dream-renewables-website
heroku authorizations:info <ID>
- will show data on a specified authorizationexport HEROKU_API_KEY=<TOKEN> HEROKU_EMAIL=<EMAIL>
- This will set the keys in order for you to make usual terraform commands
- In order to locally make changes to AWS you'll need to assume the credentials of the terraform-client.
- 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
- Add the terraform-client to your aws-vault:
aws-vault add terraform-client
This project uses Husky and lint-staged to enforce consistent formatting of Terraform files using terraform fmt
before committing changes.
- In the root directory Install dependencies:
npm i
- 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
- Ensure the pre-commit file is executable:
chmod +x .husky/pre-commit
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 withaws-vault exec terraform-client --
for exampleaws-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>
Name | Description |
---|---|
Dream Renewables Cms | The Content Management System for this web application |
Dream Renewables Frontend | React code for this web application |