{
  "description": "Create an NGINX Plus and two NGINX Open Source Images",
  "variables": {
    "home": "{{env `HOME`}}",
    "aws_access_key": "",
    "aws_secret_key": "",
    "region": "us-west-1"
  },
  "builders": [
    {
      "type": "amazon-ebs",
      "name": "ngx-plus",
      "ami_name": "ngx-plus {{isotime \"2006-01-02\"}}",
      "instance_type": "t2.micro",
      "region": "{{user `region`}}",
      "source_ami": "ami-0b2d8d1abb76a53d8",
      "ssh_username": "ec2-user",
      "access_key": "{{user `aws_access_key`}}",
      "secret_key": "{{user `aws_secret_key`}}",
      "tags": {
        "Name": "ngx-plus"
      }
    },
    {
      "type": "amazon-ebs",
      "name": "ngx-oss",
      "ami_name": "ngx-oss {{isotime \"2006-01-02\"}}",
      "instance_type": "t2.micro",
      "region": "{{user `region`}}",
      "source_ami": "ami-0dd655843c87b6930",
      "ssh_username": "ubuntu",
      "access_key": "{{user `aws_access_key`}}",
      "secret_key": "{{user `aws_secret_key`}}",
      "tags": {
        "Name": "ngx-oss"
      }
    }
  ],
  "provisioners": [
    {
      "type": "file",
      "source": "{{user `home`}}/.ssh/ngx-certs",
      "destination": "~/.ssh/ngx-certs",
      "only": [
        "ngx-plus"
      ]
    },
    {
      "type": "shell",
      "inline": [
        "sudo yum update -y",
        "sudo yum install python-pip -y",
        "sudo pip install ansible"
      ],
      "only": [
        "ngx-plus"
      ]
    },
    {
      "type": "ansible-local",
      "galaxy_file": "requirements.yml",
      "playbook_file": "playbook-lb.yml",
      "only": [
        "ngx-plus"
      ]
    },
    {
      "type": "shell",
      "script": "setup-instance.sh",
      "only": [
        "ngx-plus"
      ]
    },
    {
      "type": "shell",
      "inline": [
        "sleep 60",
        "sudo apt update",
        "sudo apt install python-pip -y",
        "sudo pip install ansible"
      ],
      "only": [
        "ngx-oss"
      ]
    },
    {
      "type": "ansible-local",
      "galaxy_file": "requirements.yml",
      "playbook_file": "playbook-app.yml",
      "only": [
        "ngx-oss"
      ]
    }
  ]
}
