webserver.tf 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ###############################################
  2. # DO NOT EDIT THIS FILE
  3. #
  4. # This file is generated through 'make all'.
  5. # If you need to make changes, make your changes
  6. # to the corresponding .j file and then rerun
  7. # make all
  8. ###############################################
  9. ###################
  10. # Web Server Instance
  11. resource "aws_instance" "webserver" {
  12. # ami = "${data.aws_ami.ubuntu.id}"
  13. ami = "${data.aws_ami.centos7.id}"
  14. instance_type = "${var.Instance-Type}"
  15. availability_zone = "${data.aws_availability_zones.available.names[0]}"
  16. subnet_id = "${aws_subnet.subnet_public_a.id}"
  17. ebs_optimized = "${var.EBS-Optimized}"
  18. disable_api_termination = false
  19. associate_public_ip_address = true
  20. instance_initiated_shutdown_behavior = "terminate"
  21. key_name = "${var.AWS-Key-Pair-Name}"
  22. vpc_security_group_ids = ["${aws_security_group.sg_instance_access.id}"]
  23. depends_on = ["aws_internet_gateway.gw_primary"]
  24. tags {
  25. Name = "webserver"
  26. }
  27. root_block_device {
  28. volume_type = "standard"
  29. volume_size = "10" # Gigabytes
  30. delete_on_termination = true
  31. }
  32. ebs_block_device {
  33. device_name = "/dev/sdd"
  34. volume_size = "${var.Swap-Volume-Size}"
  35. volume_type = "${var.Swap-Volume-Type}"
  36. delete_on_termination = true
  37. }
  38. user_data = <<EOF
  39. #cloud-config
  40. runcmd:
  41. - [ mkswap, /dev/xvdd ]
  42. - [ swapon, -a ]
  43. mounts:
  44. - [ xvdd, none, swap, sw, 0, 0 ]
  45. EOF
  46. # Fix issues with cached keys. Arguably less secure, but also way less annoying
  47. provisioner "local-exec" {
  48. command = "ssh-keygen -f ~/.ssh/known_hosts -R webserver.lab.${var.Domain-Name}"
  49. }
  50. }
  51. # Give me the IP Addresses
  52. output "webserver_ip" {
  53. value = "${aws_instance.webserver.public_ip}"
  54. }
  55. # Give me DNS entries
  56. resource "aws_route53_record" "webserver" {
  57. zone_id = "${var.Domain-Zone-ID}"
  58. name = "webserver.lab.${var.Domain-Name}"
  59. type = "A"
  60. ttl = "300"
  61. records = ["${aws_instance.webserver.public_ip}"]
  62. }
  63. resource "aws_route53_record" "webserver_pvt" {
  64. zone_id = "${var.Domain-Zone-ID}"
  65. name = "webserver_pvt.lab.${var.Domain-Name}"
  66. type = "A"
  67. ttl = "300"
  68. records = ["${aws_instance.webserver.private_ip}"]
  69. }
  70. output "webserver_dns" {
  71. value = "${aws_route53_record.webserver.name}"
  72. }