From b97edfa9c4ae8f3250b0eccefa191fd8061e5274 Mon Sep 17 00:00:00 2001 From: zachfeld Date: Thu, 24 Feb 2022 12:41:28 -0500 Subject: [PATCH] feat: add ipv4 & ipv6 prefix options to aws_launch_template resource --- internal/service/ec2/launch_template.go | 28 +++++++++++++++++++ .../ec2/launch_template_data_source.go | 18 ++++++++++++ 2 files changed, 46 insertions(+) diff --git a/internal/service/ec2/launch_template.go b/internal/service/ec2/launch_template.go index 2be71acf9bc..d864e34d7b5 100644 --- a/internal/service/ec2/launch_template.go +++ b/internal/service/ec2/launch_template.go @@ -526,6 +526,30 @@ func ResourceLaunchTemplate() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "ipv4_prefixes": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.IsIPv4Address, + }, + }, + "ipv4_prefix_count": { + Type: schema.TypeInt, + Optional: true, + }, + "ipv6_prefixes": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.IsIPv6Address, + }, + }, + "ipv6_prefix_count": { + Type: schema.TypeInt, + Optional: true, + }, "interface_type": { Type: schema.TypeString, Optional: true, @@ -1208,6 +1232,10 @@ func getNetworkInterfaces(n []*ec2.LaunchTemplateInstanceNetworkInterfaceSpecifi "network_card_index": aws.Int64Value(v.NetworkCardIndex), "network_interface_id": aws.StringValue(v.NetworkInterfaceId), "private_ip_address": aws.StringValue(v.PrivateIpAddress), + "ipv4_prefixes": []*ec2.Ipv4PrefixSpecificationResponse(v.Ipv4Prefixes), + "ipv4_prefix_count": aws.Int64Value(v.Ipv4PrefixCount), + "ipv6_prefixes": []*ec2.Ipv6PrefixSpecificationResponse(v.Ipv6Prefixes), + "ipv6_prefix_count": aws.Int64Value(v.Ipv6PrefixCount), "subnet_id": aws.StringValue(v.SubnetId), } diff --git a/internal/service/ec2/launch_template_data_source.go b/internal/service/ec2/launch_template_data_source.go index eabc5ab0265..490be3835de 100644 --- a/internal/service/ec2/launch_template_data_source.go +++ b/internal/service/ec2/launch_template_data_source.go @@ -329,6 +329,24 @@ func DataSourceLaunchTemplate() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "ipv4_prefixes": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "ipv4_prefix_count": { + Type: schema.TypeInt, + Computed: true, + }, + "ipv6_prefixes": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "ipv6_prefix_count": { + Type: schema.TypeInt, + Computed: true, + }, "interface_type": { Type: schema.TypeString, Computed: true,