You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
3.1 KiB

  1. variable "deploymentName" {
  2. type = "string"
  3. description = "The desired name of your deployment."
  4. }
  5. variable "numControllers"{
  6. type = "string"
  7. description = "Desired # of controllers."
  8. }
  9. variable "numEtcd" {
  10. type = "string"
  11. description = "Desired # of etcd nodes. Should be an odd number."
  12. }
  13. variable "numNodes" {
  14. type = "string"
  15. description = "Desired # of nodes."
  16. }
  17. variable "volSizeController" {
  18. type = "string"
  19. description = "Volume size for the controllers (GB)."
  20. }
  21. variable "volSizeEtcd" {
  22. type = "string"
  23. description = "Volume size for etcd (GB)."
  24. }
  25. variable "volSizeNodes" {
  26. type = "string"
  27. description = "Volume size for nodes (GB)."
  28. }
  29. variable "subnet" {
  30. type = "string"
  31. description = "The subnet in which to put your cluster."
  32. }
  33. variable "securityGroups" {
  34. type = "string"
  35. description = "The sec. groups in which to put your cluster."
  36. }
  37. variable "ami"{
  38. type = "string"
  39. description = "AMI to use for all VMs in cluster."
  40. }
  41. variable "SSHKey" {
  42. type = "string"
  43. description = "SSH key to use for VMs."
  44. }
  45. variable "master_instance_type" {
  46. type = "string"
  47. description = "Size of VM to use for masters."
  48. }
  49. variable "etcd_instance_type" {
  50. type = "string"
  51. description = "Size of VM to use for etcd."
  52. }
  53. variable "node_instance_type" {
  54. type = "string"
  55. description = "Size of VM to use for nodes."
  56. }
  57. variable "terminate_protect" {
  58. type = "string"
  59. default = "false"
  60. }
  61. variable "awsRegion" {
  62. type = "string"
  63. }
  64. provider "aws" {
  65. region = "${var.awsRegion}"
  66. }
  67. resource "aws_instance" "master" {
  68. count = "${var.numControllers}"
  69. ami = "${var.ami}"
  70. instance_type = "${var.master_instance_type}"
  71. subnet_id = "${var.subnet}"
  72. vpc_security_group_ids = ["${var.securityGroups}"]
  73. key_name = "${var.SSHKey}"
  74. disable_api_termination = "${var.terminate_protect}"
  75. root_block_device {
  76. volume_size = "${var.volSizeController}"
  77. }
  78. tags {
  79. Name = "${var.deploymentName}-master-${count.index + 1}"
  80. }
  81. }
  82. resource "aws_instance" "etcd" {
  83. count = "${var.numEtcd}"
  84. ami = "${var.ami}"
  85. instance_type = "${var.etcd_instance_type}"
  86. subnet_id = "${var.subnet}"
  87. vpc_security_group_ids = ["${var.securityGroups}"]
  88. key_name = "${var.SSHKey}"
  89. disable_api_termination = "${var.terminate_protect}"
  90. root_block_device {
  91. volume_size = "${var.volSizeEtcd}"
  92. }
  93. tags {
  94. Name = "${var.deploymentName}-etcd-${count.index + 1}"
  95. }
  96. }
  97. resource "aws_instance" "minion" {
  98. count = "${var.numNodes}"
  99. ami = "${var.ami}"
  100. instance_type = "${var.node_instance_type}"
  101. subnet_id = "${var.subnet}"
  102. vpc_security_group_ids = ["${var.securityGroups}"]
  103. key_name = "${var.SSHKey}"
  104. disable_api_termination = "${var.terminate_protect}"
  105. root_block_device {
  106. volume_size = "${var.volSizeNodes}"
  107. }
  108. tags {
  109. Name = "${var.deploymentName}-minion-${count.index + 1}"
  110. }
  111. }
  112. output "master-ip" {
  113. value = "${join(", ", aws_instance.master.*.private_ip)}"
  114. }
  115. output "etcd-ip" {
  116. value = "${join(", ", aws_instance.etcd.*.private_ip)}"
  117. }
  118. output "minion-ip" {
  119. value = "${join(", ", aws_instance.minion.*.private_ip)}"
  120. }