Commit 9d31a735 authored by Anton Babenko's avatar Anton Babenko Committed by GitHub

Added support for the list of private_ips (fixes #102) (#103)

parent f43568fa
...@@ -67,6 +67,7 @@ module "ec2" { ...@@ -67,6 +67,7 @@ module "ec2" {
ami = data.aws_ami.amazon_linux.id ami = data.aws_ami.amazon_linux.id
instance_type = "c5.large" instance_type = "c5.large"
subnet_id = tolist(data.aws_subnet_ids.all.ids)[0] subnet_id = tolist(data.aws_subnet_ids.all.ids)[0]
private_ip = ["123.0.0.1", "123.0.0.2"]
vpc_security_group_ids = [module.security_group.this_security_group_id] vpc_security_group_ids = [module.security_group.this_security_group_id]
associate_public_ip_address = true associate_public_ip_address = true
placement_group = aws_placement_group.web.id placement_group = aws_placement_group.web.id
......
...@@ -24,7 +24,10 @@ resource "aws_instance" "this" { ...@@ -24,7 +24,10 @@ resource "aws_instance" "this" {
iam_instance_profile = var.iam_instance_profile iam_instance_profile = var.iam_instance_profile
associate_public_ip_address = var.associate_public_ip_address associate_public_ip_address = var.associate_public_ip_address
private_ip = var.private_ip private_ip = element(
distinct(compact(concat([var.private_ip], var.private_ips))),
count.index,
)
ipv6_address_count = var.ipv6_address_count ipv6_address_count = var.ipv6_address_count
ipv6_addresses = var.ipv6_addresses ipv6_addresses = var.ipv6_addresses
...@@ -110,7 +113,10 @@ resource "aws_instance" "this_t2" { ...@@ -110,7 +113,10 @@ resource "aws_instance" "this_t2" {
iam_instance_profile = var.iam_instance_profile iam_instance_profile = var.iam_instance_profile
associate_public_ip_address = var.associate_public_ip_address associate_public_ip_address = var.associate_public_ip_address
private_ip = var.private_ip private_ip = element(
distinct(compact(concat([var.private_ip], var.private_ips))),
count.index,
)
ipv6_address_count = var.ipv6_address_count ipv6_address_count = var.ipv6_address_count
ipv6_addresses = var.ipv6_addresses ipv6_addresses = var.ipv6_addresses
......
...@@ -90,6 +90,12 @@ variable "private_ip" { ...@@ -90,6 +90,12 @@ variable "private_ip" {
default = "" default = ""
} }
variable "private_ips" {
description = "A list of private IP address to associate with the instance in a VPC. Should match the number of instances."
type = list(string)
default = []
}
variable "source_dest_check" { variable "source_dest_check" {
description = "Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs." description = "Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs."
type = bool type = bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment