Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for the list of private_ips #103

Merged
merged 1 commit into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module "ec2" {
ami = data.aws_ami.amazon_linux.id
instance_type = "c5.large"
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]
associate_public_ip_address = true
placement_group = aws_placement_group.web.id
Expand Down
18 changes: 12 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ resource "aws_instance" "this" {
iam_instance_profile = var.iam_instance_profile

associate_public_ip_address = var.associate_public_ip_address
private_ip = var.private_ip
ipv6_address_count = var.ipv6_address_count
ipv6_addresses = var.ipv6_addresses
private_ip = element(
distinct(compact(concat([var.private_ip], var.private_ips))),
count.index,
)
ipv6_address_count = var.ipv6_address_count
ipv6_addresses = var.ipv6_addresses

ebs_optimized = var.ebs_optimized

Expand Down Expand Up @@ -110,9 +113,12 @@ resource "aws_instance" "this_t2" {
iam_instance_profile = var.iam_instance_profile

associate_public_ip_address = var.associate_public_ip_address
private_ip = var.private_ip
ipv6_address_count = var.ipv6_address_count
ipv6_addresses = var.ipv6_addresses
private_ip = element(
distinct(compact(concat([var.private_ip], var.private_ips))),
count.index,
)
ipv6_address_count = var.ipv6_address_count
ipv6_addresses = var.ipv6_addresses

ebs_optimized = var.ebs_optimized

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ variable "private_ip" {
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" {
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
Expand Down