Changed to separate network interface
This commit is contained in:
parent
949b668654
commit
fccd5807b3
27
main.tf
27
main.tf
@ -62,6 +62,24 @@ data "template_file" "user_data" {
|
|||||||
template = file("${path.module}/template/user_data.sh")
|
template = file("${path.module}/template/user_data.sh")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_network_interface" "interface" {
|
||||||
|
subnet_id = var.subnet_id
|
||||||
|
security_groups = [aws_security_group.ami[0].id]
|
||||||
|
|
||||||
|
tags = merge(
|
||||||
|
{
|
||||||
|
"Name" = format("%s-bastion", var.environment)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Environment" = format("%s", var.environment)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Project" = format("%s", var.project)
|
||||||
|
},
|
||||||
|
var.tags,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
resource "aws_instance" "instance" {
|
resource "aws_instance" "instance" {
|
||||||
count = var.enable_bastion ? 1 : 0
|
count = var.enable_bastion ? 1 : 0
|
||||||
|
|
||||||
@ -69,11 +87,16 @@ resource "aws_instance" "instance" {
|
|||||||
instance_type = var.instance_type
|
instance_type = var.instance_type
|
||||||
associate_public_ip_address = true
|
associate_public_ip_address = true
|
||||||
ebs_optimized = var.ebs_optimized
|
ebs_optimized = var.ebs_optimized
|
||||||
subnet_id = var.subnet_id
|
#subnet_id = var.subnet_id
|
||||||
vpc_security_group_ids = [aws_security_group.ami[0].id]
|
#vpc_security_group_ids = [aws_security_group.ami[0].id]
|
||||||
key_name = var.key_name
|
key_name = var.key_name
|
||||||
user_data = var.user_data == "" ? data.template_file.user_data.rendered : var.user_data
|
user_data = var.user_data == "" ? data.template_file.user_data.rendered : var.user_data
|
||||||
|
|
||||||
|
network_interface {
|
||||||
|
network_interface_id = aws_network_interface.interface.id
|
||||||
|
device_index = 0
|
||||||
|
}
|
||||||
|
|
||||||
metadata_options {
|
metadata_options {
|
||||||
http_endpoint = "enabled"
|
http_endpoint = "enabled"
|
||||||
http_tokens = "required"
|
http_tokens = "required"
|
||||||
|
|||||||
@ -49,7 +49,7 @@ variable "instance_type" {
|
|||||||
variable "ebs_optimized" {
|
variable "ebs_optimized" {
|
||||||
description = "If true, the launched EC2 instance will be EBS-optimized."
|
description = "If true, the launched EC2 instance will be EBS-optimized."
|
||||||
type = bool
|
type = bool
|
||||||
default = false
|
default = true
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "admin_cidr" {
|
variable "admin_cidr" {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user