/*
* Create templates
*/
data "template_file" "cloud_config" {
template = "${file("${path.module}/cloud-config/perforce.yaml.tpl")}"
vars {
public_keys = "${join(",", var.additional_public_keys)}"
}
}
/*
* KEYPAIR
*/
resource "aws_key_pair" "key_pair" {
public_key = "${file("${path.root}/files/${var.key_name}")}"
}
/*
* SECURITY GROUP
*/
resource "aws_security_group" "instance_sg" {
description = "Allow HTTP and SSH traffic"
vpc_id = "${module.networking.vpc-id}"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 1666
to_port = 1666
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 22
to_port = 22
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"]
}
tags {
Name = "${var.stack_name}-${var.env}-instance"
}
lifecycle {
create_before_destroy = true
}
}