remove the ec2 instance

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-05-31 17:49:01 -04:00
parent 2258bc273c
commit 1e6269427b
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 0 additions and 106 deletions

106
dev.tf
View File

@ -1,109 +1,3 @@
/* RESOURCES ------------------------------------*/
resource "aws_key_pair" "admin" {
key_name = "admin-key"
public_key = "${file("files/admin.pub")}"
}
data "aws_ami" "ubuntu" {
filter {
name = "name"
values = ["${var.image_name}"]
}
owners = ["099720109477"]
}
resource "aws_security_group" "dap_ps_dev" {
name = "default-webserver"
description = "Allow SSH, HTTP and HTTPS"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_instance" "dap_ps_dev" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "${var.instance_type}"
key_name = "${aws_key_pair.admin.key_name}"
availability_zone = "${var.zone}"
security_groups = ["${aws_security_group.dap_ps_dev.name}"]
associate_public_ip_address = true
tags = {
Name = "node-01.${var.zone}.${var.env}.test"
}
/* bootstraping access for later Ansible use */
provisioner "ansible" {
plays {
playbook = {
file_path = "${path.cwd}/ansible/bootstrap.yml"
}
groups = ["${var.group}"]
extra_vars = {
hostname = "node-01.${var.zone}.${var.env}.test"
ansible_ssh_user = "${var.ssh_user}"
data_center = "${var.zone}"
stage = "${terraform.workspace}"
env = "${var.env}"
}
}
}
}
resource "gandi_zonerecord" "dap_ps_dev" {
zone = "${gandi_zone.dap_ps_zone.id}"
name = "${aws_instance.dap_ps_dev.tags.Name}.${var.hosts_subdomain}"
type = "A"
ttl = 3600
values = ["${aws_instance.dap_ps_dev.public_ip}"]
}
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}"]
}
resource "ansible_host" "main" {
inventory_hostname = "${aws_instance.dap_ps_dev.tags.Name}"
groups = ["${var.group}", "${var.zone}"]
vars {
ansible_host = "${aws_instance.dap_ps_dev.public_ip}"
hostname = "${aws_instance.dap_ps_dev.tags.Name}"
region = "${aws_instance.dap_ps_dev.availability_zone}"
dns_entry = "${aws_instance.dap_ps_dev.tags.Name}.${var.hosts_subdomain}.${var.public_domain}"
dns_domain = "${var.hosts_subdomain}"
data_center = "${var.zone}"
stage = "${terraform.workspace}"
env = "${var.env}"
}
}