@@ -31,6 +31,8 @@ func TestAccVPCNATGatewayDataSource_basic(t *testing.T) {
3131 Check : resource .ComposeAggregateTestCheckFunc (
3232 resource .TestCheckResourceAttrPair (dataSourceNameByID , "allocation_id" , resourceName , "allocation_id" ),
3333 resource .TestCheckResourceAttrPair (dataSourceNameByID , names .AttrAssociationID , resourceName , names .AttrAssociationID ),
34+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "availability_mode" , resourceName , "availability_mode" ),
35+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "availability_zone_address.#" , resourceName , "availability_zone_address.#" ),
3436 resource .TestCheckResourceAttrPair (dataSourceNameByID , "connectivity_type" , resourceName , "connectivity_type" ),
3537 resource .TestCheckResourceAttrPair (dataSourceNameByID , names .AttrNetworkInterfaceID , resourceName , names .AttrNetworkInterfaceID ),
3638 resource .TestCheckResourceAttrPair (dataSourceNameByID , "private_ip" , resourceName , "private_ip" ),
@@ -42,6 +44,8 @@ func TestAccVPCNATGatewayDataSource_basic(t *testing.T) {
4244
4345 resource .TestCheckResourceAttrPair (dataSourceNameBySubnetID , "allocation_id" , resourceName , "allocation_id" ),
4446 resource .TestCheckResourceAttrPair (dataSourceNameBySubnetID , names .AttrAssociationID , resourceName , names .AttrAssociationID ),
47+ resource .TestCheckResourceAttrPair (dataSourceNameBySubnetID , "availability_mode" , resourceName , "availability_mode" ),
48+ resource .TestCheckResourceAttrPair (dataSourceNameBySubnetID , "availability_zone_address.#" , resourceName , "availability_zone_address.#" ),
4549 resource .TestCheckResourceAttrPair (dataSourceNameBySubnetID , "connectivity_type" , resourceName , "connectivity_type" ),
4650 resource .TestCheckResourceAttrPair (dataSourceNameBySubnetID , names .AttrNetworkInterfaceID , resourceName , names .AttrNetworkInterfaceID ),
4751 resource .TestCheckResourceAttrPair (dataSourceNameBySubnetID , "private_ip" , resourceName , "private_ip" ),
@@ -53,6 +57,8 @@ func TestAccVPCNATGatewayDataSource_basic(t *testing.T) {
5357
5458 resource .TestCheckResourceAttrPair (dataSourceNameByTags , "allocation_id" , resourceName , "allocation_id" ),
5559 resource .TestCheckResourceAttrPair (dataSourceNameByTags , names .AttrAssociationID , resourceName , names .AttrAssociationID ),
60+ resource .TestCheckResourceAttrPair (dataSourceNameByTags , "availability_mode" , resourceName , "availability_mode" ),
61+ resource .TestCheckResourceAttrPair (dataSourceNameByTags , "availability_zone_address.#" , resourceName , "availability_zone_address.#" ),
5662 resource .TestCheckResourceAttrPair (dataSourceNameByTags , "connectivity_type" , resourceName , "connectivity_type" ),
5763 resource .TestCheckResourceAttrPair (dataSourceNameByTags , names .AttrNetworkInterfaceID , resourceName , names .AttrNetworkInterfaceID ),
5864 resource .TestCheckResourceAttrPair (dataSourceNameByTags , "private_ip" , resourceName , "private_ip" ),
@@ -67,6 +73,45 @@ func TestAccVPCNATGatewayDataSource_basic(t *testing.T) {
6773 })
6874}
6975
76+ func TestAccVPCNATGatewayDataSource_availabilityModeRegional (t * testing.T ) {
77+ ctx := acctest .Context (t )
78+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
79+ dataSourceNameByID := "data.aws_nat_gateway.test_by_id"
80+ resourceName := "aws_nat_gateway.test"
81+
82+ resource .ParallelTest (t , resource.TestCase {
83+ PreCheck : func () { acctest .PreCheck (ctx , t ) },
84+ ErrorCheck : acctest .ErrorCheck (t , names .EC2ServiceID ),
85+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
86+ Steps : []resource.TestStep {
87+ {
88+ Config : testAccVPCNATGatewayDataSourceConfig_availabilityModeRegional (rName ),
89+ Check : resource .ComposeAggregateTestCheckFunc (
90+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "auto_provision_zones" , resourceName , "auto_provision_zones" ),
91+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "auto_scaling_ips" , resourceName , "auto_scaling_ips" ),
92+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "availability_mode" , resourceName , "availability_mode" ),
93+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "availability_zone_address.#" , resourceName , "availability_zone_address.#" ),
94+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "availability_zone_address.0.allocation_ids.#" , resourceName , "availability_zone_address.0.allocation_ids.#" ),
95+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "availability_zone_address.0.allocation_ids.0" , resourceName , "availability_zone_address.0.allocation_ids.0" ),
96+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "availability_zone_address.0.availability_zone" , resourceName , "availability_zone_address.0.availability_zone" ),
97+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "availability_zone_address.0.availability_zone_id" , resourceName , "availability_zone_address.0.availability_zone_id" ),
98+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "connectivity_type" , resourceName , "connectivity_type" ),
99+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "regional_nat_gateway_address.#" , resourceName , "regional_nat_gateway_address.#" ),
100+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "regional_nat_gateway_address.0.allocation_id" , resourceName , "regional_nat_gateway_address.0.allocation_id" ),
101+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "regional_nat_gateway_address.0.association_id" , resourceName , "regional_nat_gateway_address.0.association_id" ),
102+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "regional_nat_gateway_address.0.available_zone" , resourceName , "regional_nat_gateway_address.0.available_zone" ),
103+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "regional_nat_gateway_address.0.available_zone_id" , resourceName , "regional_nat_gateway_address.0.available_zone_id" ),
104+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "regional_nat_gateway_address.0.public_ip" , resourceName , "regional_nat_gateway_address.0.public_ip" ),
105+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "regional_nat_gateway_address.0.status" , resourceName , "regional_nat_gateway_address.0.status" ),
106+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "route_table_id" , resourceName , "route_table_id" ),
107+ resource .TestCheckResourceAttrPair (dataSourceNameByID , "tags.#" , resourceName , "tags.#" ),
108+ resource .TestCheckResourceAttrPair (dataSourceNameByID , names .AttrVPCID , resourceName , names .AttrVPCID ),
109+ ),
110+ },
111+ },
112+ })
113+ }
114+
70115func testAccVPCNATGatewayDataSourceConfig_basic (rName string ) string {
71116 return acctest .ConfigCompose (testAccNATGatewayConfig_base (rName ), fmt .Sprintf (`
72117resource "aws_nat_gateway" "test" {
@@ -95,3 +140,24 @@ data "aws_nat_gateway" "test_by_tags" {
95140}
96141` , rName ))
97142}
143+
144+ func testAccVPCNATGatewayDataSourceConfig_availabilityModeRegional (rName string ) string {
145+ return acctest .ConfigCompose (
146+ testAccVPCNATGatewayConfig_availabilityModeRegionalBase (rName , 1 ), `
147+ resource "aws_nat_gateway" "test" {
148+ vpc_id = aws_vpc.test.id
149+ availability_mode = "regional"
150+
151+ availability_zone_address {
152+ allocation_ids = [aws_eip.test[0].id]
153+ availability_zone = data.aws_availability_zones.available.names[0]
154+ }
155+
156+ depends_on = [aws_internet_gateway.test]
157+ }
158+
159+ data "aws_nat_gateway" "test_by_id" {
160+ id = aws_nat_gateway.test.id
161+ }
162+ ` )
163+ }
0 commit comments