add prefix/suffix and disk size
This commit is contained in:
parent
20c7496038
commit
f8e8768944
14
main.tf
14
main.tf
|
@ -60,7 +60,7 @@ resource "local_file" "public_key" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_key_pair" "deployer" {
|
resource "aws_key_pair" "deployer" {
|
||||||
key_name = "ubuntu_ssh_key"
|
key_name = "${var.name_prefix}-key-${var.name_suffix}"
|
||||||
public_key = tls_private_key.ssh_key.public_key_openssh
|
public_key = tls_private_key.ssh_key.public_key_openssh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,18 +130,28 @@ data "aws_ami" "ubuntu" {
|
||||||
|
|
||||||
resource "aws_instance" "ubuntu_instance" {
|
resource "aws_instance" "ubuntu_instance" {
|
||||||
ami = data.aws_ami.ubuntu.id
|
ami = data.aws_ami.ubuntu.id
|
||||||
# Ubuntu "ami-0a0e5d9c7acc336f1"
|
|
||||||
# ami = data.aws_ami.latest_ecs.ami # Amazon Linux
|
# ami = data.aws_ami.latest_ecs.ami # Amazon Linux
|
||||||
instance_type = var.instance_size
|
instance_type = var.instance_size
|
||||||
subnet_id = aws_subnet.public_subnet.id
|
subnet_id = aws_subnet.public_subnet.id
|
||||||
vpc_security_group_ids = [aws_security_group.allow_ssh_http_https.id]
|
vpc_security_group_ids = [aws_security_group.allow_ssh_http_https.id]
|
||||||
key_name = aws_key_pair.deployer.key_name
|
key_name = aws_key_pair.deployer.key_name
|
||||||
associate_public_ip_address = true
|
associate_public_ip_address = true
|
||||||
|
name_prefix = var.name_prefix
|
||||||
|
resource_tag = var.name_suffix
|
||||||
|
|
||||||
depends_on = [
|
depends_on = [
|
||||||
aws_security_group.allow_ssh_http_https,
|
aws_security_group.allow_ssh_http_https,
|
||||||
aws_internet_gateway.igw
|
aws_internet_gateway.igw
|
||||||
]
|
]
|
||||||
|
|
||||||
|
lifecycle {
|
||||||
|
ignore_changes = [ami]
|
||||||
|
}
|
||||||
|
|
||||||
|
root_block_device {
|
||||||
|
volume_size = var.disk_size
|
||||||
|
delete_on_termination = true
|
||||||
|
}
|
||||||
|
|
||||||
user_data = var.user_data
|
user_data = var.user_data
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,3 +62,8 @@ variable "name_suffix" {
|
||||||
description = "The suffix for all your resources, suggest generating a unique value for each deployment"
|
description = "The suffix for all your resources, suggest generating a unique value for each deployment"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "disk_size" {
|
||||||
|
description = "Size of instance disk in Gigabytes"
|
||||||
|
default = 10
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue