# terraform-dev-box

## Overview

Terraform module for creating "dev boxes". A dev box is a virtual machine used for developing and testing applications that are otherwise difficult to develop locally. Each dev box comes pre-configured with a Dockerised PHP application stack, which includes OA, Workstation and VAPI.

> [!WARNING]
> Breaking changes! Beginning with version 2.0.0, the module has been updated to use a second provider for DNS record creation. This provider must be defined in the same directory as the module. Use the `networking` profile if you need a domain in `theorchard.io` zone, or the `shared` profile if you need a record in the `shared.theorchard.io` zone. For more details, refer to [Providers](#providers).

> [!WARNING]
> Dev boxes will be automatically destroyed after 30 days. Any data will be lost. Please ensure any data or configuration you need is backed up locally.

## Usage

```
module "repository" {
  source = "git@github.com:theorchard/terraform-dev-box.git?ref=X.X.X"
  
  dev_box_id          = "<SOME_ID>" # A unique identifier for the dev box, e.g. your name, a team, a project or a feature.
  owner_email_address = "<YOUR_EMAIL_ADDRESS>"
  owner_name          = "<YOUR_FULL_NAME>"
}
```

## Access

The PHP application frontend URLs are available as outputs of the module.

For SSH access, grab the EC2 instance IP address from the AWS console. SSH users are defined in https://github.com/theorchard/irrigate-orchard_base/blob/master/recipes/dev_user_ssh.rb.

### Providers

The module requires an explicitly defined second AWS provider to create DNS records in the shared networking account.
This provider must be defined in the same directory as the module and should use the `networking` profile if you need a domain in `theorchard.io` zone, or the `shared` profile if you need a record in the `shared.theorchard.io` zone.
The provider should be defined as follows:

```hcl
provider "aws" {
  region  = var.aws_region
}

provider "aws" {
  region  = var.aws_region
  alias   = "shared"
  profile = "shared"
}

module "devbox" {
  source = "../../"

  providers = {
    aws.dns = aws
  }

  application_family  = "devops"
  dev_box_id          = "jdoe"
  owner_email_address = "john.doe@example.com"
  owner_name          = "John Doe"
}
```

```hcl
provider "aws" {
  region  = var.aws_region
}
provider "aws" {
  region  = var.aws_region
  alias   = "networking"
  profile = "networking"
}

module "devbox" {
  source = "../../"

  providers = {
    aws.dns = aws
  }

  application_family  = "devops"
  dev_box_id          = "jdoe"
  owner_email_address = "john.doe@example.com"
  owner_name          = "John Doe"
  subdomain           = "box.theorchard.io"
}
```
