-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix(ec2): dual-stack vpc without private subnets creates EgressOnlyInternetGateway (under feature flag) #34437
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
base: main
Are you sure you want to change the base?
Changes from all commits
a0d2af6
13bd3c0
526ec3e
ee737a4
9b44c78
e1d3f5a
6b8d59f
427b4a2
ec230db
f5ef6fa
264f2cd
3d5ce70
6dedf32
d157dce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,7 @@ | ||||||
import { testDeprecated } from '@aws-cdk/cdk-build-tools'; | ||||||
import { Annotations, Match, Template } from '../../assertions'; | ||||||
import { App, CfnOutput, CfnResource, Fn, Lazy, Stack, Tags } from '../../core'; | ||||||
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from '../../cx-api'; | ||||||
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP, ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC } from '../../cx-api'; | ||||||
import { | ||||||
AclCidr, | ||||||
AclTraffic, | ||||||
|
@@ -2747,6 +2747,90 @@ describe('vpc', () => { | |||||
}, | ||||||
}); | ||||||
}); | ||||||
test('(default)EgressOnlyInternetGateWay is created when no private subnet configured in dual stack', () => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of |
||||||
// GIVEN | ||||||
const app = new App(); | ||||||
const stack = new Stack(app, 'DualStackStack'); | ||||||
|
||||||
// WHEN | ||||||
const vpc = new Vpc(stack, 'Vpc', { | ||||||
ipProtocol: IpProtocol.DUAL_STACK, | ||||||
subnetConfiguration: [ | ||||||
{ | ||||||
subnetType: SubnetType.PUBLIC, | ||||||
name: 'public', | ||||||
}, | ||||||
], | ||||||
}); | ||||||
|
||||||
// THEN | ||||||
Template.fromStack(stack).resourceCountIs('AWS::EC2::EgressOnlyInternetGateway', 1); | ||||||
}); | ||||||
test('(default)EgressOnlyInternetGateWay is created when private subnet configured in dual stack', () => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above test. |
||||||
// GIVEN | ||||||
const app = new App(); | ||||||
const stack = new Stack(app, 'DualStackStack'); | ||||||
|
||||||
// WHEN | ||||||
const vpc = new Vpc(stack, 'Vpc', { | ||||||
ipProtocol: IpProtocol.DUAL_STACK, | ||||||
subnetConfiguration: [ | ||||||
{ | ||||||
subnetType: SubnetType.PUBLIC, | ||||||
name: 'public', | ||||||
}, | ||||||
{ | ||||||
subnetType: SubnetType.PRIVATE_WITH_EGRESS, | ||||||
name: 'private', | ||||||
}, | ||||||
], | ||||||
}); | ||||||
|
||||||
// THEN | ||||||
Template.fromStack(stack).resourceCountIs('AWS::EC2::EgressOnlyInternetGateway', 1); | ||||||
}); | ||||||
|
||||||
test('(feature flag ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC)EgressOnlyInternetGateWay is created when private subnet configured in dual stack', () => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||
// GIVEN | ||||||
const app = new App(); | ||||||
const stack = new Stack(app, 'DualStackStack'); | ||||||
// WHEN | ||||||
stack.node.setContext(ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC, true); | ||||||
const vpc = new Vpc(stack, 'Vpc', { | ||||||
ipProtocol: IpProtocol.DUAL_STACK, | ||||||
subnetConfiguration: [ | ||||||
{ | ||||||
subnetType: SubnetType.PUBLIC, | ||||||
name: 'public', | ||||||
}, | ||||||
{ | ||||||
subnetType: SubnetType.PRIVATE_WITH_EGRESS, | ||||||
name: 'private', | ||||||
}, | ||||||
], | ||||||
}); | ||||||
|
||||||
// THEN | ||||||
Template.fromStack(stack).resourceCountIs('AWS::EC2::EgressOnlyInternetGateway', 1); | ||||||
}); | ||||||
test(' (feature flag ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC)EgressOnlyInternetGateWay is not created when private subnet configured in dual stack', () => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// GIVEN | ||||||
const app = new App(); | ||||||
const stack = new Stack(app, 'DualStackStack'); | ||||||
stack.node.setContext(ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC, true); | ||||||
// WHEN | ||||||
const vpc = new Vpc(stack, 'Vpc', { | ||||||
ipProtocol: IpProtocol.DUAL_STACK, | ||||||
subnetConfiguration: [ | ||||||
{ | ||||||
subnetType: SubnetType.PUBLIC, | ||||||
name: 'public', | ||||||
}, | ||||||
], | ||||||
}); | ||||||
// THEN | ||||||
Template.fromStack(stack).resourceCountIs('AWS::EC2::EgressOnlyInternetGateway', 0); | ||||||
}); | ||||||
|
||||||
test('error should occur if IPv6 properties are provided for a non-dual-stack VPC', () => { | ||||||
// GIVEN | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -137,6 +137,7 @@ export const DYNAMODB_TABLE_RETAIN_TABLE_REPLICA = '@aws-cdk/aws-dynamodb:retain | |||||
export const LOG_USER_POOL_CLIENT_SECRET_VALUE = '@aws-cdk/cognito:logUserPoolClientSecretValue'; | ||||||
export const PIPELINE_REDUCE_CROSS_ACCOUNT_ACTION_ROLE_TRUST_SCOPE = '@aws-cdk/pipelines:reduceCrossAccountActionRoleTrustScope'; | ||||||
export const S3_TRUST_KEY_POLICY_FOR_SNS_SUBSCRIPTIONS = '@aws-cdk/s3-notifications:addS3TrustKeyPolicyForSnsSubscriptions'; | ||||||
export const ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC = '@aws-cdk/ec2:removeEgressOnlyGatewayFromPublicSubnetVPC'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I know it's not consistent but the convention is to prefix the service here with
Suggested change
|
||||||
export const USE_RESOURCEID_FOR_VPCV2_MIGRATION = '@aws-cdk/aws-ec2-alpha:useResourceIdForVpcV2Migration'; | ||||||
|
||||||
export const FLAGS: Record<string, FlagInfo> = { | ||||||
|
@@ -1576,6 +1577,17 @@ export const FLAGS: Record<string, FlagInfo> = { | |||||
}, | ||||||
|
||||||
////////////////////////////////////////////////////////////////////// | ||||||
[ENABLE_E2_REMOVE_EGRESSONLYGATEWAY_FROM_PUBLIC_SUBNET_VPC]: { | ||||||
type: FlagType.BugFix, | ||||||
summary: 'Remove EgressOnlyGateway resource when a a double stack vpc has only public subnets', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem entirely correct. Rather than "removing |
||||||
detailsMd: ` | ||||||
When this feature flag is enabled, EgressOnlyGateway resource will not be created when you create a vpc with only public subnets. | ||||||
`, | ||||||
introducedIn: { v2: 'V2NEXT' }, | ||||||
recommendedValue: true, | ||||||
}, | ||||||
|
||||||
/// /////////////////////////////////////////////////////////////////// | ||||||
[USE_RESOURCEID_FOR_VPCV2_MIGRATION]: { | ||||||
type: FlagType.ApiDefault, | ||||||
summary: 'When enabled, use resource IDs for VPC V2 migration', | ||||||
|
@@ -1588,6 +1600,7 @@ export const FLAGS: Record<string, FlagInfo> = { | |||||
recommendedValue: false, | ||||||
defaults: { v2: false }, | ||||||
compatibilityWithOldBehaviorMd: 'Disable the feature flag to use getAtt references for VPC V2 migration', | ||||||
|
||||||
}, | ||||||
}; | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: variable name