Skip to content

Commit d8272ef

Browse files
authored
feat(ec2): restrict access to default security group (under feature flag) (#25297)
This PR implements functionality which will remove the default ingress/egress rules from the VPC default security group. When a VPC is created, the default security group is created as well with default ingress/egress rules which allow _all_ traffic. It is not possible to delete the default security group, but you should never use it. As a result there are a log of security standards that recommend removing the default rules so that the security group denies all traffic by default. See [this rule](https://docs.aws.amazon.com/securityhub/latest/userguide/ec2-controls.html#ec2-2). Since the default security group cannot be managed through a CloudFormation resource, this PR introduces a new Custom Resource which will remove the ingress/egress rules. I also think that this should be the default behavior so I have introduced a new feature flag to make this the default for new apps. As a result I had to update _a lot_ of integration tests. Since This feature flag would only be introduced on new VPCs it didn't make sense to run the update workflow on all these integration tests so I updated them to disable this new feature. I added one new integration test to test this functionality. fixes #19394 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 04427e3 commit d8272ef

File tree

234 files changed

+4298
-162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+4298
-162
lines changed

lerna.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"useWorkspaces": true,
44
"packages": [
55
"packages/aws-cdk-lib",
6-
"packages/cdk-cli-wrapper",
76
"packages/cdk-assets",
87
"packages/aws-cdk",
98
"packages/cdk",

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"workspaces": {
7070
"packages": [
7171
"packages/aws-cdk-lib",
72-
"packages/cdk-cli-wrapper",
7372
"packages/aws-cdk",
7473
"packages/cdk",
7574
"packages/cdk-assets",

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.restapi.vpc-endpoint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Test extends cdk.Stack {
1313
constructor(scope: cdk.App, id: string) {
1414
super(scope, id);
1515

16-
const vpc = new ec2.Vpc(this, 'MyVpc', {});
16+
const vpc = new ec2.Vpc(this, 'MyVpc', { restrictDefaultSecurityGroup: false });
1717

1818
const vpcEndpoint = vpc.addInterfaceEndpoint('MyVpcEndpoint', {
1919
service: ec2.InterfaceVpcEndpointAwsService.APIGATEWAY,

packages/@aws-cdk-testing/framework-integ/test/aws-appmesh/test/integ.mesh.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const app = new cdk.App();
88
const stack = new cdk.Stack(app, 'mesh-stack', {});
99

1010
const vpc = new ec2.Vpc(stack, 'vpc', {
11+
restrictDefaultSecurityGroup: false,
1112
natGateways: 1,
1213
});
1314

packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling-hooktargets/test/integ.queue-hook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TestStack extends cdk.Stack {
1919
const queue = new Queue(this, 'HookQueue');
2020
this.queueUrl = queue.queueUrl;
2121
const group = new scaling.AutoScalingGroup(this, 'Group', {
22-
vpc: new Vpc(this, 'Vpc'),
22+
vpc: new Vpc(this, 'Vpc', { restrictDefaultSecurityGroup: false }),
2323
maxCapacity: 1,
2424
minCapacity: 0,
2525
instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.SMALL),

packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.amazonlinux2.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-autoscaling-integ');
88

99
const vpc = new ec2.Vpc(stack, 'VPC', {
1010
maxAzs: 2,
11+
restrictDefaultSecurityGroup: false,
1112
});
1213

1314
new autoscaling.AutoScalingGroup(stack, 'Fleet', {

packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.asg-capacity-rebalance.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-autoscaling-integ');
99

1010
const vpc = new ec2.Vpc(stack, 'VPC', {
1111
maxAzs: 2,
12+
restrictDefaultSecurityGroup: false,
1213
});
1314

1415
new autoscaling.AutoScalingGroup(stack, 'CapacityRebalance', {

packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.asg-lt.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const ltOverrideT4g = new ec2.LaunchTemplate(stack, 'T4gLT', {
2323
});
2424

2525
const vpc = new ec2.Vpc(stack, 'VPC', {
26+
restrictDefaultSecurityGroup: false,
2627
maxAzs: 2,
2728
});
2829

packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.asg-w-classic-loadbalancer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-asg-integ');
99

1010
const vpc = new ec2.Vpc(stack, 'VPC', {
1111
maxAzs: 3,
12+
restrictDefaultSecurityGroup: false,
1213
});
1314

1415
const asg = new autoscaling.AutoScalingGroup(stack, 'Fleet', {

packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.asg-w-elbv2.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class ElbV2AsgStack extends cdk.Stack {
1313

1414
const vpc = new ec2.Vpc(this, 'VPC', {
1515
maxAzs: 2,
16+
restrictDefaultSecurityGroup: false,
1617
});
1718

1819
const asg = new autoscaling.AutoScalingGroup(this, 'Fleet', {
@@ -50,6 +51,7 @@ class ElbV2AsgAtgStack extends cdk.Stack {
5051
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
5152
super(scope, id, props);
5253
const vpc = new ec2.Vpc(this, 'VPC', {
54+
restrictDefaultSecurityGroup: false,
5355
maxAzs: 2,
5456
});
5557
const alb = new elbv2.ApplicationLoadBalancer(this, 'alb', {

packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.custom-scaling.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-autoscaling-integ');
88

99
const vpc = new ec2.Vpc(stack, 'VPC', {
1010
maxAzs: 2,
11+
restrictDefaultSecurityGroup: false,
1112
});
1213

1314
const asg = new autoscaling.AutoScalingGroup(stack, 'Fleet', {

packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.external-role.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class TestStack extends cdk.Stack {
77
constructor(scope: cdk.App, id: string) {
88
super(scope, id);
99

10-
const vpc = new ec2.Vpc(this, 'VPC');
10+
const vpc = new ec2.Vpc(this, 'VPC', { restrictDefaultSecurityGroup: false });
1111
const role = new iam.Role(this, 'Role', {
1212
assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com'),
1313
});

packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.role-target-hook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class TestStack extends cdk.Stack {
3535
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
3636
super(scope, id, props);
3737

38-
let vpc = new ec2.Vpc(this, 'myVpcAuto', {});
38+
let vpc = new ec2.Vpc(this, 'myVpcAuto', { restrictDefaultSecurityGroup: false });
3939
const myrole = new iam.Role(this, 'MyRole', {
4040
assumedBy: new iam.ServicePrincipal('autoscaling.amazonaws.com'),
4141
});

packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.spot-instances.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-autoscaling-integ');
88

99
const vpc = new ec2.Vpc(stack, 'VPC', {
1010
maxAzs: 2,
11+
restrictDefaultSecurityGroup: false,
1112
});
1213

1314
new autoscaling.AutoScalingGroup(stack, 'Fleet', {

packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.warm-pool.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-autoscaling-integ');
1313

1414
const vpc = new ec2.Vpc(stack, 'VPC', {
1515
maxAzs: 2,
16+
restrictDefaultSecurityGroup: false,
1617
});
1718

1819
const asg = new autoscaling.AutoScalingGroup(stack, 'Fleet', {

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront-origins/test/integ.load-balancer-origin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as origins from 'aws-cdk-lib/aws-cloudfront-origins';
77
const app = new cdk.App();
88
const stack = new cdk.Stack(app, 'cloudfront-load-balancer-origin');
99

10-
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2 });
10+
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2, restrictDefaultSecurityGroup: false });
1111
const loadbalancer = new elbv2.ApplicationLoadBalancer(stack, 'LB', { vpc, internetFacing: true });
1212

1313
new cloudfront.Distribution(stack, 'Distribution', {

packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-file-system-location.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-codebuild-file-system-locations');
88
const vpc = new ec2.Vpc(stack, 'MyVPC', {
99
maxAzs: 1,
1010
natGateways: 1,
11+
restrictDefaultSecurityGroup: false,
1112
});
1213
const securityGroup = new ec2.SecurityGroup(stack, 'SecurityGroup1', {
1314
allowAllOutbound: true,

packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-vpc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-codebuild-project-vpc');
99
const vpc = new ec2.Vpc(stack, 'MyVPC', {
1010
maxAzs: 1,
1111
natGateways: 1,
12+
restrictDefaultSecurityGroup: false,
1213
});
1314
const securityGroup = new ec2.SecurityGroup(stack, 'SecurityGroup1', {
1415
allowAllOutbound: true,

packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const app = new cdk.App();
7373
const stack = new cdk.Stack(app, 'aws-cdk-codedeploy-ecs-dg');
7474

7575
// Network infrastructure
76-
const vpc = new ec2.Vpc(stack, 'VPC', { maxAzs: 2 });
76+
const vpc = new ec2.Vpc(stack, 'VPC', { maxAzs: 2, restrictDefaultSecurityGroup: false });
7777

7878
// ECS service
7979
const cluster = new ecs.Cluster(stack, 'EcsCluster', {

packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/server/integ.deployment-group.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const app = new cdk.App();
99

1010
const stack = new cdk.Stack(app, 'aws-cdk-codedeploy-server-dg');
1111

12-
const vpc = new ec2.Vpc(stack, 'VPC');
12+
const vpc = new ec2.Vpc(stack, 'VPC', { restrictDefaultSecurityGroup: false });
1313

1414
const asg = new autoscaling.AutoScalingGroup(stack, 'ASG', {
1515
instanceType: ec2.InstanceType.of(ec2.InstanceClass.M5, ec2.InstanceSize.LARGE),

packages/@aws-cdk-testing/framework-integ/test/aws-codepipeline-actions/test/integ.pipeline-ecs-deploy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const app = new cdk.App();
1414
const stack = new cdk.Stack(app, 'aws-cdk-codepipeline-ecs-deploy');
1515

1616
const vpc = new ec2.Vpc(stack, 'VPC', {
17+
restrictDefaultSecurityGroup: false,
1718
maxAzs: 1,
1819
});
1920
const cluster = new ecs.Cluster(stack, 'EcsCluster', {

packages/@aws-cdk-testing/framework-integ/test/aws-codepipeline-actions/test/integ.pipeline-ecs-separate-source.lit.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class EcsAppStack extends cdk.Stack {
4949
taskDefinition,
5050
cluster: new ecs.Cluster(this, 'Cluster', {
5151
vpc: new ec2.Vpc(this, 'Vpc', {
52+
restrictDefaultSecurityGroup: false,
5253
maxAzs: 1,
5354
}),
5455
}),

packages/@aws-cdk-testing/framework-integ/test/aws-docdb/test/integ.cluster-rotation.lit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import * as docdb from 'aws-cdk-lib/aws-docdb';
1313
const app = new cdk.App();
1414
const stack = new cdk.Stack(app, 'aws-cdk-docdb-cluster-rotation');
1515

16-
const vpc = new ec2.Vpc(stack, 'VPC');
16+
const vpc = new ec2.Vpc(stack, 'VPC', { restrictDefaultSecurityGroup: false });
1717

1818
/// !show
1919
const cluster = new docdb.DatabaseCluster(stack, 'Database', {

packages/@aws-cdk-testing/framework-integ/test/aws-docdb/test/integ.cluster.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TestStack extends cdk.Stack {
1313
constructor(scope: constructs.Construct, id: string, props?: cdk.StackProps) {
1414
super(scope, id, props);
1515

16-
const vpc = new ec2.Vpc(this, 'VPC', { maxAzs: 2 });
16+
const vpc = new ec2.Vpc(this, 'VPC', { maxAzs: 2, restrictDefaultSecurityGroup: false });
1717

1818
const params = new ClusterParameterGroup(this, 'Params', {
1919
family: 'docdb3.6',

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host-arm-support.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
*/
66
import * as cdk from 'aws-cdk-lib';
77
import * as ec2 from 'aws-cdk-lib/aws-ec2';
8+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
89

910
const app = new cdk.App();
1011

1112
class TestStack extends cdk.Stack {
1213
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
1314
super(scope, id, props);
15+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
1416

1517
const vpc = new ec2.Vpc(this, 'VPC');
1618

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.bastion-host.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/// !cdk-integ *
22
import * as cdk from 'aws-cdk-lib';
33
import * as ec2 from 'aws-cdk-lib/aws-ec2';
4+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
45

56
const app = new cdk.App();
67

78
class TestStack extends cdk.Stack {
89
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
910
super(scope, id, props);
11+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
1012

1113
const vpc = new ec2.Vpc(this, 'VPC');
1214

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.client-vpn-endpoint.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import * as logs from 'aws-cdk-lib/aws-logs';
33
import { App, CustomResource, CustomResourceProvider, CustomResourceProviderRuntime, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib';
44
import { Construct } from 'constructs';
55
import * as ec2 from 'aws-cdk-lib/aws-ec2';
6+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
67

78
class TestStack extends Stack {
89
constructor(scope: Construct, id: string, props?: StackProps) {
910
super(scope, id, props);
11+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
1012

1113
// Import server and client certificates in ACM
1214
const certificates = new ImportCertificates(this, 'ImportCertificates');

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.core-cross-stack-string-list-references.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { App, CfnParameter, Stack, StackProps } from 'aws-cdk-lib';
33
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
44
import { Construct } from 'constructs';
55
import { InterfaceVpcEndpoint, InterfaceVpcEndpointAwsService, Vpc } from 'aws-cdk-lib/aws-ec2';
6+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
67

78
// GIVEN
89
const app = new App({
@@ -16,6 +17,7 @@ class ProducerStack extends Stack {
1617

1718
constructor(scope: Construct, id: string, props?: StackProps) {
1819
super(scope, id, props);
20+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
1921

2022
const vpc = new Vpc(this, 'vpc');
2123
this.stringListGetAtt = new InterfaceVpcEndpoint(this, 'endpoint', {
@@ -43,6 +45,7 @@ export interface consumerDeployProps extends StackProps {
4345
class ConsumerStack extends Stack {
4446
constructor(scope: Construct, id: string, props: consumerDeployProps) {
4547
super(scope, id, props);
48+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
4649

4750
new ssm.StringListParameter(this, 'GetAtt', {
4851
stringListValue: props.stringListGetAtt,

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.graviton3.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
import { PolicyStatement } from 'aws-cdk-lib/aws-iam';
33
import * as cdk from 'aws-cdk-lib';
44
import * as ec2 from 'aws-cdk-lib/aws-ec2';
5+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
56

67
const app = new cdk.App();
78

89
class TestStack extends cdk.Stack {
910
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
1011
super(scope, id, props);
12+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
1113

1214
const vpc = new ec2.Vpc(this, 'VPC');
1315

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import * as fs from 'fs';
33
import * as path from 'path';
44
import * as cdk from 'aws-cdk-lib';
55
import * as ec2 from 'aws-cdk-lib/aws-ec2';
6+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
67

78
const app = new cdk.App();
89
const stack = new cdk.Stack(app, 'integ-init');
10+
stack.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
911

1012
const vpc = new ec2.Vpc(stack, 'IntegInitVpc');
1113

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import { PolicyStatement } from 'aws-cdk-lib/aws-iam';
22
import * as cdk from 'aws-cdk-lib';
33
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
44
import * as ec2 from 'aws-cdk-lib/aws-ec2';
5+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
56

67
const app = new cdk.App();
78

89
class TestStack extends cdk.Stack {
910
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
1011
super(scope, id, props);
12+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
1113

1214
const vpc = new ec2.Vpc(this, 'VPC');
1315
const securityGroup = new ec2.SecurityGroup(this, 'IntegSg', {

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import {
66
aws_ec2 as ec2,
77
} from 'aws-cdk-lib';
88
import { Construct } from 'constructs';
9+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
910

1011

1112
export class TestCase extends Stack {
1213
constructor(scope: Construct, id: string, props?: StackProps) {
1314
super(scope, id, props);
15+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
1416
const vpc = new ec2.Vpc(this, 'Vpc');
1517
new ec2.Instance(this, 'amzn2', {
1618
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.NANO),

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.nat-instances.lit.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import * as cdk from 'aws-cdk-lib';
22
import * as ec2 from 'aws-cdk-lib/aws-ec2';
33
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
4+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
45

56
class NatInstanceStack extends cdk.Stack {
67
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
78
super(scope, id, props);
9+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
810

911
/// !show
1012
// Configure the `natGatewayProvider` when defining a Vpc

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.ports.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import * as cdk from 'aws-cdk-lib';
22
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
33
import * as ec2 from 'aws-cdk-lib/aws-ec2';
4+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
45

56
const app = new cdk.App();
67

78
class TestStack extends cdk.Stack {
89
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
910
super(scope, id, props);
11+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
1012

1113
const vpc = new ec2.Vpc(this, 'VPC');
1214

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.reserved-private-subnet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as cdk from 'aws-cdk-lib';
2+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
23
import * as ec2 from 'aws-cdk-lib/aws-ec2';
34

45
/*
@@ -15,6 +16,7 @@ const app = new cdk.App();
1516
class VpcReservedPrivateSubnetStack extends cdk.Stack {
1617
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
1718
super(scope, id, props);
19+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
1820

1921
/// !show
2022
// Specify no NAT gateways with a reserved private subnet

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.share-vpcs.lit.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import * as cdk from 'aws-cdk-lib';
33
import { Construct } from 'constructs';
44
import * as ec2 from 'aws-cdk-lib/aws-ec2';
5+
import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api';
56

67
const app = new cdk.App();
78

@@ -30,6 +31,7 @@ class Stack1 extends cdk.Stack {
3031
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
3132
super(scope, id, props);
3233

34+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
3335
this.vpc = new ec2.Vpc(this, 'VPC');
3436
}
3537
}
@@ -45,6 +47,7 @@ class Stack2 extends cdk.Stack {
4547
constructor(scope: cdk.App, id: string, props: Stack2Props) {
4648
super(scope, id, props);
4749

50+
this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false);
4851
// Pass the VPC to a construct that needs it
4952
new ConstructThatTakesAVpc(this, 'Construct', {
5053
vpc: props.vpc,

0 commit comments

Comments
 (0)