parent
097a150b57
commit
4791bf9b6d
@ -0,0 +1,14 @@
|
|||||||
|
resource "aws_instance" "nodes" {
|
||||||
|
ami = var.ami
|
||||||
|
instance_type = var.ec2-instance-type
|
||||||
|
# key_name = aws_key_pair.debug1.key_name
|
||||||
|
associate_public_ip_address = true
|
||||||
|
subnet_id = var.subnet-id
|
||||||
|
vpc_security_group_ids = var.security-group-ids
|
||||||
|
user_data = element(var.user-datas.*.rendered, count.index)
|
||||||
|
count = var.num-nodes
|
||||||
|
|
||||||
|
tags = {
|
||||||
|
Name = "${var.name-prefix}-${count.index}"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
output "ips" {
|
||||||
|
value = aws_instance.nodes.*.public_ip
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
variable "ami" {
|
||||||
|
description = "The AWS AMI to be used for all the nodes"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ec2-instance-type" {
|
||||||
|
default = "t2.micro"
|
||||||
|
description = "The AWS instance type to use for all nodes."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "name-prefix" {
|
||||||
|
default = "tf-node"
|
||||||
|
description = "This prefix will be applied to all names created by this module."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "num-nodes" {
|
||||||
|
default = 1
|
||||||
|
description = "The number of nodes to create from the given input parameters."
|
||||||
|
type = number
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "user-datas" {
|
||||||
|
description = "A list of cloud-init configs that get applied to their corresponding node."
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "subnet-id" {
|
||||||
|
description = "The ID of the subnet that all the nodes will be added to."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "security-group-ids" {
|
||||||
|
description = "A list of security group IDs to be applied to all the nodes."
|
||||||
|
type = list(string)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue