This is an example Terraform project hosting a web app in Netlify and a web api in Heroku. Terraform is used to manage and deploy the infrastructure.
The actual projects being deployed are two other repos of mine:
- dummy-web-app
- A simple dummy web app which reaches out to a server for some information
- dummy-web-api
- A simple dummy web API that serves some information
The inclusion of these sub-projects is done through meta. The idea is that these projects are not meant to be developed as a part of this repo, just included and deployed.
You will need to have the following in order to begin
- Node.js installed (for running and installing
meta
) npm i -g meta
to installmeta
- Terraform installed and available in your path
- Clone this repo using
git clone ...
- Clone the subprojects using
meta git update
- Set up Terraform variables using
cp example.tfvars terraform.tfvars
and filling out the values in theterraform.tfvars
file - Initialize Terraform using
terraform init
(this will install providers) - Run
terraform plan
to see what changes will be made - Run
terraform apply
and then typeyes
to deploy the configuration!
The npm project is set up to run the client and the server locally.
- Ensure the projects are installed using
npm install
(this will also install dependencies forclient
andserver
projects) - Run
npm start
to run both the client and the server
- You can run just the server or the client by running
npm run start:server
ornpm run start:client
You can simply tear down all your infrastructure with terraform destroy
. It will preview the changes and ask for your permission before doing any destructive actions.