Skip to content

Commit

Permalink
r/aws_launch_template: Fix address count interface attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonbondon committed Apr 26, 2018
1 parent 8fe9444 commit 7862f92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions aws/resource_aws_launch_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,9 +982,12 @@ func readNetworkInterfacesFromConfig(ni map[string]interface{}) *ec2.LaunchTempl
Ipv6Address: aws.String(address.(string)),
})
}
networkInterface.Ipv6AddressCount = aws.Int64(int64(len(ipv6AddressList)))
networkInterface.Ipv6Addresses = ipv6Addresses

if v := ni["ipv6_address_count"].(int); v > 0 {
networkInterface.Ipv6AddressCount = aws.Int64(int64(v))
}

ipv4AddressList := ni["ipv4_addresses"].(*schema.Set).List()
for _, address := range ipv4AddressList {
privateIp := &ec2.PrivateIpAddressSpecification{
Expand All @@ -993,9 +996,12 @@ func readNetworkInterfacesFromConfig(ni map[string]interface{}) *ec2.LaunchTempl
}
ipv4Addresses = append(ipv4Addresses, privateIp)
}
networkInterface.SecondaryPrivateIpAddressCount = aws.Int64(int64(len(ipv4AddressList)))
networkInterface.PrivateIpAddresses = ipv4Addresses

if v := ni["ipv4_address_count"].(int); v > 0 {
networkInterface.SecondaryPrivateIpAddressCount = aws.Int64(int64(v))
}

return networkInterface
}

Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/launch_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,19 @@ The `monitoring` block supports the following:

Attaches one or more [Network Interfaces](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html) to the instance.

Check limitations for autoscaling group in [Creating an Auto Scaling Group Using a Launch Template Guide](https://docs.aws.amazon.com/autoscaling/ec2/userguide/create-asg-launch-template.html#limitations)

Each `network_interfaces` block supports the following:

* `associate_public_ip_address` - Associate a public ip address with the network interface. Boolean value.
* `delete_on_termination` - Whether the network interface should be destroyed on instance termination.
* `description` - Description of the network interface.
* `device_index` - The integer index of the network interface attachment.
* `ipv6_addresses` - One or more specific IPv6 addresses from the IPv6 CIDR block range of your subnet.
* `ipv6_address_count` - The number of IPv6 addresses to assign to a network interface. Conflicts with `ipv6_addresses`
* `network_interface_id` - The ID of the network interface to attach.
* `private_ip_address` - The primary private IPv4 address.
* `ipv4_address_count` - The number of secondary private IPv4 addresses to assign to a network interface.
* `ipv4_addresses` - One or more private IPv4 addresses to associate.
* `security_groups` - A list of security group IDs to associate.
* `subnet_id` - The VPC Subnet ID to associate.
Expand Down

0 comments on commit 7862f92

Please sign in to comment.