31 lines
949 B
HCL
31 lines
949 B
HCL
resource "aws_instance" "ec2-instance" {
|
|
ami = var.ami-id
|
|
instance_type = var.instance-type
|
|
associate_public_ip_address = var.asso-public-ip
|
|
// availability_zone = var.az
|
|
iam_instance_profile = var.instance-profile
|
|
key_name = var.key-name
|
|
root_block_device {
|
|
encrypted = var.ebs-encrypted
|
|
volume_size = var.root-volume-size
|
|
volume_type = var.root-volume-type
|
|
}
|
|
ebs_optimized = true
|
|
subnet_id = var.subnet-id
|
|
vpc_security_group_ids = var.security-groups
|
|
tags = merge(var.additional_tags, var.default-tags,
|
|
{ Name = var.instance-name }
|
|
)
|
|
volume_tags = merge(var.additional_tags, var.default-tags,
|
|
{ Name = var.instance-name }
|
|
)
|
|
}
|
|
|
|
resource "aws_eip" "ec2-eip" {
|
|
count = var.asso-eip ? 1 : 0
|
|
instance = aws_instance.ec2-instance.id
|
|
vpc = true
|
|
tags = merge(var.default-tags,
|
|
{ Name = var.instance-name }
|
|
)
|
|
} |