Skip to content

Commit a8112fb

Browse files
authored
Merge branch 'main' into ecs-lambda-deployment-config
2 parents 62a2496 + 798f9e8 commit a8112fb

5 files changed

Lines changed: 175 additions & 9 deletions

File tree

CHANGELOG.v2.alpha.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [2.44.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.43.1-alpha.0...v2.44.0-alpha.0) (2022-09-28)
6+
7+
8+
### Features
9+
10+
* **integ-tests:** chain assertion api calls ([#22196](https://github.com/aws/aws-cdk/issues/22196)) ([530e07b](https://github.com/aws/aws-cdk/commit/530e07bdc87ab94bbd5ed28debac98400a8152cc))
11+
* **neptune:** introduce metric method to cluster and instance ([#21995](https://github.com/aws/aws-cdk/issues/21995)) ([02ed837](https://github.com/aws/aws-cdk/commit/02ed8371276d504ba9fe09687d45409ad7cca288)), closes [#20248](https://github.com/aws/aws-cdk/issues/20248)
12+
513
## [2.43.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.43.0-alpha.0...v2.43.1-alpha.0) (2022-09-23)
614

715
## [2.43.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.42.1-alpha.0...v2.43.0-alpha.0) (2022-09-21)

CHANGELOG.v2.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [2.44.0](https://github.com/aws/aws-cdk/compare/v2.43.1...v2.44.0) (2022-09-28)
6+
7+
8+
### Features
9+
10+
* **assets:** support drop-in docker replacements by setting `$CDK_DOCKER` ([#21838](https://github.com/aws/aws-cdk/issues/21838)) ([d52310e](https://github.com/aws/aws-cdk/commit/d52310ea2104dd1ed13761944d078ffce46a299f)), closes [40aws-cdk/core/lib/bundling.ts#L523](https://github.com/40aws-cdk/core/lib/bundling.ts/issues/L523) [#21836](https://github.com/aws/aws-cdk/issues/21836)
11+
* **backup:** add copy actions to backup plan rules ([#22244](https://github.com/aws/aws-cdk/issues/22244)) ([d87a651](https://github.com/aws/aws-cdk/commit/d87a651608d23f3bfc3c178093d92b5bdda71084)), closes [#22173](https://github.com/aws/aws-cdk/issues/22173)
12+
* **cfnspec:** cloudformation spec v89.0.0 ([#22232](https://github.com/aws/aws-cdk/issues/22232)) ([953d684](https://github.com/aws/aws-cdk/commit/953d6841fa3ed43258d0454e245cebcab6323e0d))
13+
* **cli:** `cdk deploy --method=direct` is faster ([#22079](https://github.com/aws/aws-cdk/issues/22079)) ([dd6ead4](https://github.com/aws/aws-cdk/commit/dd6ead447a80cdec3379a3ced2e04b7d15f9c55d))
14+
* **cloudwatch:** add gauge widget ([#22213](https://github.com/aws/aws-cdk/issues/22213)) ([d9f0e80](https://github.com/aws/aws-cdk/commit/d9f0e809d583d23cb83b4e2855574675a669c33f)), closes [#22136](https://github.com/aws/aws-cdk/issues/22136)
15+
* **core:** 'postCliContext' property allows context that cannot be overridden by the CLI ([#21743](https://github.com/aws/aws-cdk/issues/21743)) ([a618096](https://github.com/aws/aws-cdk/commit/a618096432a27a808a0352ea186fe1e4db2911c4))
16+
* **dynamodb:** Changes how metricForOperation methods are used ([#22097](https://github.com/aws/aws-cdk/issues/22097)) ([fcb311d](https://github.com/aws/aws-cdk/commit/fcb311d615422b76f18b6be60dd466b315fcd6b0)), closes [#21963](https://github.com/aws/aws-cdk/issues/21963)
17+
* **logs:** add dimensions to metric filter ([#21654](https://github.com/aws/aws-cdk/issues/21654)) ([f834a45](https://github.com/aws/aws-cdk/commit/f834a4537643b32131076111be0693c6f8f96b24)), closes [/github.com/aws/aws-cdk/issues/16999#issuecomment-1005172655](https://github.com/aws//github.com/aws/aws-cdk/issues/16999/issues/issuecomment-1005172655) [#16999](https://github.com/aws/aws-cdk/issues/16999)
18+
* **pipelines:** allow disabling use of change sets ([#21619](https://github.com/aws/aws-cdk/issues/21619)) ([05723e7](https://github.com/aws/aws-cdk/commit/05723e74cc0e760f570c36ec02a70e8936287814)), closes [#20827](https://github.com/aws/aws-cdk/issues/20827)
19+
* **s3-deployment:** extract flag to disable automatic unzipping ([#21805](https://github.com/aws/aws-cdk/issues/21805)) ([91898b5](https://github.com/aws/aws-cdk/commit/91898b51573c0bfd0f26ae7610feb6a400bc8159)), closes [#8065](https://github.com/aws/aws-cdk/issues/8065)
20+
21+
22+
### Bug Fixes
23+
24+
* **aws-elasticloadbalancingv2:** Validation for interval and timeout of application-target-group ([#22225](https://github.com/aws/aws-cdk/issues/22225)) ([6128e39](https://github.com/aws/aws-cdk/commit/6128e3908f4f6b6a1db66ebf7f77b6c966d1f9e7))
25+
* **cli:** SSO credentials do not work when using a proxy ([#22115](https://github.com/aws/aws-cdk/issues/22115)) ([c425e8c](https://github.com/aws/aws-cdk/commit/c425e8ca1a3d296eb6a7fd7e005d07c1eadd16aa)), closes [#21328](https://github.com/aws/aws-cdk/issues/21328)
26+
* **elbv2:** Use correct format for parsing imported target group ARNs ([#22153](https://github.com/aws/aws-cdk/issues/22153)) ([4704d4c](https://github.com/aws/aws-cdk/commit/4704d4c4ac065634dbada3732193a6753369dd12))
27+
* **rds:** changing engine versions would fail to update on DBInstances that were part of a DBCluster ([#22185](https://github.com/aws/aws-cdk/issues/22185)) ([c070ace](https://github.com/aws/aws-cdk/commit/c070acea1b12ec4f73c7d2087c5408d7e38a90a3)), closes [#21758](https://github.com/aws/aws-cdk/issues/21758) [#22180](https://github.com/aws/aws-cdk/issues/22180)
28+
* cannot use values that return an instance of a deprecated class for non TS / JS language ([#22204](https://github.com/aws/aws-cdk/issues/22204)) ([4cad2cf](https://github.com/aws/aws-cdk/commit/4cad2cf7e1ca41dedae6adc8866792e5f71b2123))
29+
530
## [2.43.1](https://github.com/aws/aws-cdk/compare/v2.43.0...v2.43.1) (2022-09-23)
631

732

packages/@aws-cdk/aws-ec2/lib/security-group.ts

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ abstract class SecurityGroupBase extends Resource implements ISecurityGroup {
6363

6464
public abstract readonly securityGroupId: string;
6565
public abstract readonly allowAllOutbound: boolean;
66+
public abstract readonly allowAllIpv6Outbound: boolean;
6667

6768
public readonly canInlineRule = false;
6869
public readonly connections: Connections = new Connections({ securityGroups: [this] });
@@ -237,10 +238,25 @@ export interface SecurityGroupProps {
237238
* outbound traffic. If this is set to false, no outbound traffic will be allowed by
238239
* default and all egress traffic must be explicitly authorized.
239240
*
241+
* To allow all ipv6 traffic use allowAllIpv6Outbound
242+
*
240243
* @default true
241244
*/
242245
readonly allowAllOutbound?: boolean;
243246

247+
/**
248+
* Whether to allow all outbound ipv6 traffic by default.
249+
*
250+
* If this is set to true, there will only be a single egress rule which allows all
251+
* outbound ipv6 traffic. If this is set to false, no outbound traffic will be allowed by
252+
* default and all egress ipv6 traffic must be explicitly authorized.
253+
*
254+
* To allow all ipv4 traffic use allowAllOutbound
255+
*
256+
* @default false
257+
*/
258+
readonly allowAllIpv6Outbound?: boolean;
259+
244260
/**
245261
* Whether to disable inline ingress and egress rule optimization.
246262
*
@@ -274,6 +290,17 @@ export interface SecurityGroupImportOptions {
274290
*/
275291
readonly allowAllOutbound?: boolean;
276292

293+
/**
294+
* Mark the SecurityGroup as having been created allowing all outbound ipv6 traffic
295+
*
296+
* Only if this is set to false will egress rules for ipv6 be added to this security
297+
* group. Be aware, this would undo any potential "all outbound traffic"
298+
* default.
299+
*
300+
* @default false
301+
*/
302+
readonly allowAllIpv6Outbound?: boolean;
303+
277304
/**
278305
* If a SecurityGroup is mutable CDK can add rules to existing groups
279306
*
@@ -360,6 +387,7 @@ export class SecurityGroup extends SecurityGroupBase {
360387
class MutableImport extends SecurityGroupBase {
361388
public securityGroupId = securityGroupId;
362389
public allowAllOutbound = options.allowAllOutbound ?? true;
390+
public allowAllIpv6Outbound = options.allowAllIpv6Outbound ?? false;
363391

364392
public addEgressRule(peer: IPeer, connection: Port, description?: string, remoteRule?: boolean) {
365393
// Only if allowAllOutbound has been disabled
@@ -372,6 +400,7 @@ export class SecurityGroup extends SecurityGroupBase {
372400
class ImmutableImport extends SecurityGroupBase {
373401
public securityGroupId = securityGroupId;
374402
public allowAllOutbound = options.allowAllOutbound ?? true;
403+
public allowAllIpv6Outbound = options.allowAllIpv6Outbound ?? false;
375404

376405
public addEgressRule(_peer: IPeer, _connection: Port, _description?: string, _remoteRule?: boolean) {
377406
// do nothing
@@ -441,6 +470,11 @@ export class SecurityGroup extends SecurityGroupBase {
441470
*/
442471
public readonly allowAllOutbound: boolean;
443472

473+
/**
474+
* Whether the SecurityGroup has been configured to allow all outbound ipv6 traffic
475+
*/
476+
public readonly allowAllIpv6Outbound: boolean;
477+
444478
private readonly securityGroup: CfnSecurityGroup;
445479
private readonly directIngressRules: CfnSecurityGroup.IngressProperty[] = [];
446480
private readonly directEgressRules: CfnSecurityGroup.EgressProperty[] = [];
@@ -458,6 +492,7 @@ export class SecurityGroup extends SecurityGroupBase {
458492
const groupDescription = props.description || this.node.path;
459493

460494
this.allowAllOutbound = props.allowAllOutbound !== false;
495+
this.allowAllIpv6Outbound = props.allowAllIpv6Outbound ?? false;
461496

462497
this.disableInlineRules = props.disableInlineRules !== undefined ?
463498
!!props.disableInlineRules :
@@ -476,6 +511,7 @@ export class SecurityGroup extends SecurityGroupBase {
476511
this.securityGroupName = this.securityGroup.ref;
477512

478513
this.addDefaultEgressRule();
514+
this.addDefaultIpv6EgressRule();
479515
}
480516

481517
public addIngressRule(peer: IPeer, connection: Port, description?: string, remoteRule?: boolean) {
@@ -496,21 +532,33 @@ export class SecurityGroup extends SecurityGroupBase {
496532
}
497533

498534
public addEgressRule(peer: IPeer, connection: Port, description?: string, remoteRule?: boolean) {
499-
if (this.allowAllOutbound) {
535+
const isIpv6 = peer.toEgressRuleConfig().hasOwnProperty('cidrIpv6');
536+
537+
if (!isIpv6 && this.allowAllOutbound) {
500538
// In the case of "allowAllOutbound", we don't add any more rules. There
501539
// is only one rule which allows all traffic and that subsumes any other
502540
// rule.
503541
if (!remoteRule) { // Warn only if addEgressRule() was explicitely called
504542
Annotations.of(this).addWarning('Ignoring Egress rule since \'allowAllOutbound\' is set to true; To add customized rules, set allowAllOutbound=false on the SecurityGroup');
505543
}
506544
return;
507-
} else {
545+
} else if (!isIpv6 && !this.allowAllOutbound) {
508546
// Otherwise, if the bogus rule exists we can now remove it because the
509547
// presence of any other rule will get rid of EC2's implicit "all
510548
// outbound" rule anyway.
511549
this.removeNoTrafficRule();
512550
}
513551

552+
if (isIpv6 && this.allowAllIpv6Outbound) {
553+
// In the case of "allowAllIpv6Outbound", we don't add any more rules. There
554+
// is only one rule which allows all traffic and that subsumes any other
555+
// rule.
556+
if (!remoteRule) { // Warn only if addEgressRule() was explicitely called
557+
Annotations.of(this).addWarning('Ignoring Egress rule since \'allowAllIpv6Outbound\' is set to true; To add customized rules, set allowAllIpv6Outbound=false on the SecurityGroup');
558+
}
559+
return;
560+
}
561+
514562
if (!peer.canInlineRule || !connection.canInlineRule || this.disableInlineRules) {
515563
super.addEgressRule(peer, connection, description, remoteRule);
516564
return;
@@ -532,7 +580,7 @@ export class SecurityGroup extends SecurityGroupBase {
532580
// to "allOutbound=true" mode, because we might have already emitted
533581
// EgressRule objects (which count as rules added later) and there's no way
534582
// to recall those. Better to prevent this for now.
535-
throw new Error('Cannot add an "all traffic" egress rule in this way; set allowAllOutbound=true on the SecurityGroup instead.');
583+
throw new Error('Cannot add an "all traffic" egress rule in this way; set allowAllOutbound=true (for ipv6) or allowAllIpv6Outbound=true (for ipv6) on the SecurityGroup instead.');
536584
}
537585

538586
this.addDirectEgressRule(rule);
@@ -596,6 +644,31 @@ export class SecurityGroup extends SecurityGroupBase {
596644
}
597645
}
598646

647+
/**
648+
* Add a allow all ipv6 egress rule to the securityGroup
649+
*
650+
* This depends on allowAllIpv6Outbound:
651+
*
652+
* - If allowAllIpv6Outbound is true, we will add an allow all rule.
653+
* - If allowAllOutbound is false, we don't do anything since EC2 does not add
654+
* a default allow all ipv6 rule.
655+
*/
656+
private addDefaultIpv6EgressRule() {
657+
const description = 'Allow all outbound ipv6 traffic by default';
658+
const peer = Peer.anyIpv6();
659+
if (this.allowAllIpv6Outbound) {
660+
if (this.disableInlineRules) {
661+
super.addEgressRule(peer, Port.allTraffic(), description, false);
662+
} else {
663+
this.directEgressRules.push({
664+
ipProtocol: '-1',
665+
cidrIp: peer.uniqueId,
666+
description,
667+
});
668+
}
669+
}
670+
}
671+
599672
/**
600673
* Remove the bogus rule if it exists
601674
*/
@@ -721,7 +794,7 @@ function egressRulesEqual(a: CfnSecurityGroup.EgressProperty, b: CfnSecurityGrou
721794
* Whether this rule refers to all traffic
722795
*/
723796
function isAllTrafficRule(rule: any) {
724-
return rule.cidrIp === '0.0.0.0/0' && rule.ipProtocol === '-1';
797+
return (rule.cidrIp === '0.0.0.0/0' || rule.cidrIpv6 === '::/0') && rule.ipProtocol === '-1';
725798
}
726799

727800
/**

packages/@aws-cdk/aws-ec2/test/security-group.test.ts

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,59 @@ describe('security group', () => {
2424
},
2525
],
2626
});
27+
});
28+
29+
test('security group can allows all ipv6 outbound traffic by default', () => {
30+
// GIVEN
31+
const stack = new Stack();
32+
const vpc = new Vpc(stack, 'VPC');
33+
34+
// WHEN
35+
new SecurityGroup(stack, 'SG1', { vpc, allowAllIpv6Outbound: true });
36+
37+
// THEN
38+
Template.fromStack(stack).hasResourceProperties('AWS::EC2::SecurityGroup', {
39+
SecurityGroupEgress: [
40+
{
41+
CidrIp: '0.0.0.0/0',
42+
Description: 'Allow all outbound traffic by default',
43+
IpProtocol: '-1',
44+
},
45+
{
46+
CidrIp: '::/0',
47+
Description: 'Allow all outbound ipv6 traffic by default',
48+
IpProtocol: '-1',
49+
},
50+
],
51+
});
52+
});
53+
54+
test('can add ipv6 rules even if allowAllOutbound=true', () => {
55+
// GIVEN
56+
const stack = new Stack();
57+
const vpc = new Vpc(stack, 'VPC');
2758

59+
// WHEN
60+
const sg = new SecurityGroup(stack, 'SG1', { vpc });
61+
sg.addEgressRule(Peer.ipv6('2001:db8::/128'), Port.tcp(80));
62+
63+
// THEN
64+
Template.fromStack(stack).hasResourceProperties('AWS::EC2::SecurityGroup', {
65+
SecurityGroupEgress: [
66+
{
67+
CidrIp: '0.0.0.0/0',
68+
Description: 'Allow all outbound traffic by default',
69+
IpProtocol: '-1',
70+
},
71+
{
72+
CidrIpv6: '2001:db8::/128',
73+
Description: 'from 2001:db8::/128:80',
74+
FromPort: 80,
75+
ToPort: 80,
76+
IpProtocol: 'tcp',
77+
},
78+
],
79+
});
2880

2981
});
3082

@@ -96,8 +148,6 @@ describe('security group', () => {
96148
},
97149
],
98150
});
99-
100-
101151
});
102152

103153
test('all outbound rule cannot be added after creation', () => {
@@ -110,8 +160,18 @@ describe('security group', () => {
110160
expect(() => {
111161
sg.addEgressRule(Peer.anyIpv4(), Port.allTraffic(), 'All traffic');
112162
}).toThrow(/Cannot add/);
163+
});
113164

165+
test('all ipv6 outbound rule cannot be added after creation', () => {
166+
// GIVEN
167+
const stack = new Stack();
168+
const vpc = new Vpc(stack, 'VPC');
114169

170+
// WHEN
171+
const sg = new SecurityGroup(stack, 'SG1', { vpc, allowAllOutbound: false });
172+
expect(() => {
173+
sg.addEgressRule(Peer.anyIpv6(), Port.allTraffic(), 'All traffic');
174+
}).toThrow(/Cannot add/);
115175
});
116176

117177
test('immutable imports do not add rules', () => {
@@ -171,7 +231,7 @@ describe('security group', () => {
171231
// GIVEN
172232
const stack = new Stack(undefined, 'TestStack', { env: { account: '12345678', region: 'dummy' } });
173233
const vpc = new Vpc(stack, 'VPC');
174-
const sg = new SecurityGroup(stack, 'SG', { vpc });
234+
const sg = new SecurityGroup(stack, 'SG', { vpc, allowAllIpv6Outbound: true });
175235

176236
const peers = [
177237
new SecurityGroup(stack, 'PeerGroup', { vpc }),

version.v2.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"version": "2.43.1",
3-
"alphaVersion": "2.43.1-alpha.0"
2+
"version": "2.44.0",
3+
"alphaVersion": "2.44.0-alpha.0"
44
}

0 commit comments

Comments
 (0)