12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- ###############################################
- # DO NOT EDIT THIS FILE
- #
- # This file is generated through 'make all'.
- # If you need to make changes, make your changes
- # to the corresponding .j file and then rerun
- # make all
- ###############################################
- ###################
- # Web Server Instance
- resource "aws_instance" "webserver" {
- # ami = "${data.aws_ami.ubuntu.id}"
- ami = "${data.aws_ami.centos7.id}"
- instance_type = "${var.Instance-Type}"
- availability_zone = "${data.aws_availability_zones.available.names[0]}"
- subnet_id = "${aws_subnet.subnet_public_a.id}"
- ebs_optimized = "${var.EBS-Optimized}"
- disable_api_termination = false
- associate_public_ip_address = true
- instance_initiated_shutdown_behavior = "terminate"
- key_name = "${var.AWS-Key-Pair-Name}"
- vpc_security_group_ids = ["${aws_security_group.sg_instance_access.id}"]
- depends_on = ["aws_internet_gateway.gw_primary"]
- tags {
- Name = "webserver"
- }
- root_block_device {
- volume_type = "standard"
- volume_size = "10" # Gigabytes
- delete_on_termination = true
- }
- ebs_block_device {
- device_name = "/dev/sdd"
- volume_size = "${var.Swap-Volume-Size}"
- volume_type = "${var.Swap-Volume-Type}"
- delete_on_termination = true
- }
- user_data = <<EOF
- #cloud-config
- runcmd:
- - [ mkswap, /dev/xvdd ]
- - [ swapon, -a ]
- mounts:
- - [ xvdd, none, swap, sw, 0, 0 ]
- EOF
- # Fix issues with cached keys. Arguably less secure, but also way less annoying
- provisioner "local-exec" {
- command = "ssh-keygen -f ~/.ssh/known_hosts -R webserver.lab.${var.Domain-Name}"
- }
- }
- # Give me the IP Addresses
- output "webserver_ip" {
- value = "${aws_instance.webserver.public_ip}"
- }
- # Give me DNS entries
- resource "aws_route53_record" "webserver" {
- zone_id = "${var.Domain-Zone-ID}"
- name = "webserver.lab.${var.Domain-Name}"
- type = "A"
- ttl = "300"
- records = ["${aws_instance.webserver.public_ip}"]
- }
- resource "aws_route53_record" "webserver_pvt" {
- zone_id = "${var.Domain-Zone-ID}"
- name = "webserver_pvt.lab.${var.Domain-Name}"
- type = "A"
- ttl = "300"
- records = ["${aws_instance.webserver.private_ip}"]
- }
- output "webserver_dns" {
- value = "${aws_route53_record.webserver.name}"
- }
|