1
1
import { testDeprecated } from '@aws-cdk/cdk-build-tools' ;
2
2
import { Annotations , Match , Template } from '../../assertions' ;
3
3
import { App , CfnOutput , CfnResource , Fn , Lazy , Stack , Tags } from '../../core' ;
4
- import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from '../../cx-api' ;
4
+ import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP , ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC } from '../../cx-api' ;
5
5
import {
6
6
AclCidr ,
7
7
AclTraffic ,
@@ -2747,8 +2747,7 @@ describe('vpc', () => {
2747
2747
} ,
2748
2748
} ) ;
2749
2749
} ) ;
2750
-
2751
- test ( 'EgressOnlyInternetGateWay is not created when no private subnet configured in dual stack' , ( ) => {
2750
+ test ( '(default)EgressOnlyInternetGateWay is created when no private subnet configured in dual stack' , ( ) => {
2752
2751
// GIVEN
2753
2752
const app = new App ( ) ;
2754
2753
const stack = new Stack ( app , 'DualStackStack' ) ;
@@ -2765,9 +2764,9 @@ describe('vpc', () => {
2765
2764
} ) ;
2766
2765
2767
2766
// THEN
2768
- Template . fromStack ( stack ) . resourceCountIs ( 'AWS::EC2::EgressOnlyInternetGateway' , 0 ) ;
2767
+ Template . fromStack ( stack ) . resourceCountIs ( 'AWS::EC2::EgressOnlyInternetGateway' , 1 ) ;
2769
2768
} ) ;
2770
- test ( 'EgressOnlyInternetGateWay is created when private subnet configured in dual stack' , ( ) => {
2769
+ test ( '(default) EgressOnlyInternetGateWay is created when private subnet configured in dual stack' , ( ) => {
2771
2770
// GIVEN
2772
2771
const app = new App ( ) ;
2773
2772
const stack = new Stack ( app , 'DualStackStack' ) ;
@@ -2791,6 +2790,50 @@ describe('vpc', () => {
2791
2790
Template . fromStack ( stack ) . resourceCountIs ( 'AWS::EC2::EgressOnlyInternetGateway' , 1 ) ;
2792
2791
} ) ;
2793
2792
2793
+ test ( '(feature flag ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC)EgressOnlyInternetGateWay is created when private subnet configured in dual stack' , ( ) => {
2794
+ // GIVEN
2795
+ const app = new App ( ) ;
2796
+ const stack = new Stack ( app , 'DualStackStack' ) ;
2797
+ // WHEN
2798
+ stack . node . setContext ( ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC , true ) ;
2799
+ const vpc = new Vpc ( stack , 'Vpc' , {
2800
+ ipProtocol : IpProtocol . DUAL_STACK ,
2801
+ subnetConfiguration : [
2802
+ {
2803
+ subnetType : SubnetType . PUBLIC ,
2804
+ name : 'public' ,
2805
+ } ,
2806
+ {
2807
+ subnetType : SubnetType . PRIVATE_WITH_EGRESS ,
2808
+ name : 'private' ,
2809
+ } ,
2810
+ ] ,
2811
+ } ) ;
2812
+
2813
+ // THEN
2814
+ Template . fromStack ( stack ) . resourceCountIs ( 'AWS::EC2::EgressOnlyInternetGateway' , 1 ) ;
2815
+ } ) ;
2816
+ test ( ' (feature flag ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC)EgressOnlyInternetGateWay is not created when private subnet configured in dual stack' , ( ) => {
2817
+ // GIVEN
2818
+ const app = new App ( ) ;
2819
+ const stack = new Stack ( app , 'DualStackStack' ) ;
2820
+
2821
+
2822
+ // WHEN
2823
+ stack . node . setContext ( ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC , true ) ;
2824
+ const vpc = new Vpc ( stack , 'Vpc' , {
2825
+ ipProtocol : IpProtocol . DUAL_STACK ,
2826
+ subnetConfiguration : [
2827
+ {
2828
+ subnetType : SubnetType . PUBLIC ,
2829
+ name : 'public' ,
2830
+ } ,
2831
+ ] ,
2832
+ } ) ;
2833
+ // THEN
2834
+ Template . fromStack ( stack ) . resourceCountIs ( 'AWS::EC2::EgressOnlyInternetGateway' , 0 ) ;
2835
+ } ) ;
2836
+
2794
2837
test ( 'error should occur if IPv6 properties are provided for a non-dual-stack VPC' , ( ) => {
2795
2838
// GIVEN
2796
2839
const app = new App ( ) ;
0 commit comments