ryaninvents / terraform-node-pm2

Terraform configuration that keeps a Node.js app running.
3 stars 1 forks source link

Enable adding other applications #5

Open ryaninvents opened 6 years ago

ryaninvents commented 6 years ago

Add a second Terraform module that would allow for a second application to be started via a reference to the remote state.

Usage might look something like this:

data "terraform_remote_state" "dev" {
  backend = "s3"
  config {
    bucket = "myterraformstate.example.com"
    region = "us-east-1"
    key = "applications/app-name/deployments/dev/terraform.tfstate"
  }
}

module "second_app" {
  source = "github.com/r24y/terraform-node-pm2/config/application"
  ssh_key = "${data.terraform_remote_state.dev.ssh_key}"
  host = "${data.terraform_remote_state.dev.instance_ip}"
  app {
    name = "my-second-app"
    source_tarball = "${file("${path.cwd}/dist/app.tgz")}"
    config = {
      env = {
        NODE_ENV = "development"
        PORT = 3001
      }
    }
  }
}

Todo: