add creation of AWS instance and record for it

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-05-28 17:23:18 -04:00
parent 2a7cdb640c
commit 0952abdc59
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 50 additions and 5 deletions

35
main.tf
View File

@ -124,3 +124,38 @@ resource "gandi_zonerecord" "dap_ps_site" {
"185.199.111.153",
]
}
/* RESOURCES ------------------------------------*/
resource "aws_key_pair" "admin" {
key_name = "admin-key"
public_key = "${file("admin.pub")}"
}
data "aws_ami" "ubuntu" {
filter {
name = "name"
values = ["${var.image_name}"]
}
owners = ["099720109477"]
}
resource "aws_instance" "dap_ps_dev" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "${var.instance_type}"
availability_zone = "${var.zone}"
key_name = "${aws_key_pair.admin.key_name}"
tags = {
Name = "node-01.${var.zone}.${var.env}.test"
}
}
resource "gandi_zonerecord" "main" {
zone = "${gandi_zone.dap_ps_zone.id}"
name = "dev"
type = "A"
ttl = 3600
values = ["${aws_instance.dap_ps_dev.public_ip}"]
}

View File

@ -31,7 +31,17 @@ variable env {
default = "dapps"
}
variable region {
description = "Name of region to deploy to"
default = "us-east-1"
variable zone {
description = "Name of availability zone to deploy to."
default = "us-east-1a"
}
variable image_name {
description = "Name of AMI image to use."
default = "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20190212.1"
}
variable instance_type {
description = "Name of instance type to use"
default = "t3.medium"
}