Skip to content

Commit 3eae89d

Browse files
authored
Merge branch 'main' into aws-events_archive_default_child
2 parents c2c97ff + 92b2c84 commit 3eae89d

File tree

57 files changed

+5591
-453
lines changed

Some content is hidden

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

57 files changed

+5591
-453
lines changed

.github/semantic.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"fs-extra": "^9.1.0",
2424
"graceful-fs": "^4.2.10",
2525
"jest-junit": "^13.2.0",
26-
"jsii-diff": "^1.63.0",
27-
"jsii-pacmak": "^1.62.0",
28-
"jsii-reflect": "^1.63.0",
29-
"jsii-rosetta": "^1.63.0",
26+
"jsii-diff": "^1.63.2",
27+
"jsii-pacmak": "^1.63.2",
28+
"jsii-reflect": "^1.63.2",
29+
"jsii-rosetta": "^1.63.2",
3030
"lerna": "^4.0.0",
3131
"patch-package": "^6.4.7",
3232
"semver": "^6.3.0",
@@ -36,8 +36,7 @@
3636
"resolutions": {
3737
"colors": "1.4.0",
3838
"markdown-it": "^12.3.2",
39-
"string-width": "^4.2.3",
40-
"jsii-pacmak": "1.62.0"
39+
"string-width": "^4.2.3"
4140
},
4241
"repository": {
4342
"type": "git",

packages/@aws-cdk/aws-appmesh/lib/route-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ function renderWeightedTargets(weightedTargets: WeightedTarget[]): CfnRoute.Weig
585585
for (const t of weightedTargets) {
586586
renderedTargets.push({
587587
virtualNode: t.virtualNode.virtualNodeName,
588-
weight: t.weight || 1,
588+
weight: t.weight == undefined ? 1 : t.weight,
589589
});
590590
}
591591
return renderedTargets;

packages/@aws-cdk/aws-appmesh/test/route.test.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,77 @@ describe('route', () => {
13611361
});
13621362
});
13631363

1364+
test('should allow zero weight route', () => {
1365+
// GIVEN
1366+
const stack = new cdk.Stack();
1367+
const mesh = new appmesh.Mesh(stack, 'mesh', {
1368+
meshName: 'test-mesh',
1369+
});
1370+
1371+
const router = new appmesh.VirtualRouter(stack, 'router', {
1372+
mesh,
1373+
});
1374+
1375+
const virtualNode = mesh.addVirtualNode('test-node', {
1376+
serviceDiscovery: appmesh.ServiceDiscovery.dns('test'),
1377+
listeners: [appmesh.VirtualNodeListener.http()],
1378+
});
1379+
1380+
// WHEN
1381+
router.addRoute('http2', {
1382+
routeSpec: appmesh.RouteSpec.http2({
1383+
priority: 50,
1384+
weightedTargets: [
1385+
{
1386+
virtualNode: virtualNode,
1387+
weight: 0,
1388+
},
1389+
],
1390+
}),
1391+
});
1392+
router.addRoute('http', {
1393+
routeSpec: appmesh.RouteSpec.http({
1394+
priority: 10,
1395+
weightedTargets: [
1396+
{
1397+
virtualNode: virtualNode,
1398+
weight: 0,
1399+
},
1400+
],
1401+
}),
1402+
});
1403+
1404+
// THEN
1405+
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::Route', {
1406+
Spec: {
1407+
Priority: 50,
1408+
Http2Route: {
1409+
Action: {
1410+
WeightedTargets: [
1411+
{
1412+
Weight: 0,
1413+
},
1414+
],
1415+
},
1416+
},
1417+
},
1418+
});
1419+
Template.fromStack(stack).hasResourceProperties('AWS::AppMesh::Route', {
1420+
Spec: {
1421+
Priority: 10,
1422+
HttpRoute: {
1423+
Action: {
1424+
WeightedTargets: [
1425+
{
1426+
Weight: 0,
1427+
},
1428+
],
1429+
},
1430+
},
1431+
},
1432+
});
1433+
});
1434+
13641435
test('Can import Routes using an ARN', () => {
13651436
const app = new cdk.App();
13661437
// GIVEN

packages/@aws-cdk/aws-ecs-patterns/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,77 @@ const loadBalancedFargateService = new ecsPatterns.ApplicationLoadBalancedFargat
653653
});
654654
```
655655

656+
### Select idleTimeout for ApplicationMultipleTargetGroupsFargateService
657+
658+
```ts
659+
import { Certificate } from '@aws-cdk/aws-certificatemanager';
660+
import { InstanceType } from '@aws-cdk/aws-ec2';
661+
import { Cluster, ContainerImage } from '@aws-cdk/aws-ecs';
662+
import { ApplicationProtocol, SslPolicy } from '@aws-cdk/aws-elasticloadbalancingv2';
663+
import { PublicHostedZone } from '@aws-cdk/aws-route53';
664+
const vpc = new ec2.Vpc(this, 'Vpc', { maxAzs: 1 });
665+
const loadBalancedFargateService = new ecsPatterns.ApplicationMultipleTargetGroupsFargateService(this, 'myService', {
666+
cluster: new ecs.Cluster(this, 'EcsCluster', { vpc }),
667+
memoryLimitMiB: 256,
668+
taskImageOptions: {
669+
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
670+
},
671+
enableExecuteCommand: true,
672+
loadBalancers: [
673+
{
674+
name: 'lb',
675+
idleTimeout: Duration.seconds(400),
676+
domainName: 'api.example.com',
677+
domainZone: new PublicHostedZone(this, 'HostedZone', { zoneName: 'example.com' }),
678+
listeners: [
679+
{
680+
name: 'listener',
681+
protocol: ApplicationProtocol.HTTPS,
682+
certificate: Certificate.fromCertificateArn(this, 'Cert', 'helloworld'),
683+
sslPolicy: SslPolicy.TLS12_EXT,
684+
},
685+
],
686+
},
687+
{
688+
name: 'lb2',
689+
idleTimeout: Duration.seconds(120),
690+
domainName: 'frontend.com',
691+
domainZone: new PublicHostedZone(this, 'HostedZone', { zoneName: 'frontend.com' }),
692+
listeners: [
693+
{
694+
name: 'listener2',
695+
protocol: ApplicationProtocol.HTTPS,
696+
certificate: Certificate.fromCertificateArn(this, 'Cert2', 'helloworld'),
697+
sslPolicy: SslPolicy.TLS12_EXT,
698+
},
699+
],
700+
},
701+
],
702+
targetGroups: [
703+
{
704+
containerPort: 80,
705+
listener: 'listener',
706+
},
707+
{
708+
containerPort: 90,
709+
pathPattern: 'a/b/c',
710+
priority: 10,
711+
listener: 'listener',
712+
},
713+
{
714+
containerPort: 443,
715+
listener: 'listener2',
716+
},
717+
{
718+
containerPort: 80,
719+
pathPattern: 'a/b/c',
720+
priority: 10,
721+
listener: 'listener2',
722+
},
723+
],
724+
});
725+
```
726+
656727
### Set PlatformVersion for ScheduledFargateTask
657728

658729
```ts

packages/@aws-cdk/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,13 @@ export interface ApplicationLoadBalancerProps {
304304
* @default - No Route53 hosted domain zone.
305305
*/
306306
readonly domainZone?: IHostedZone;
307+
308+
/**
309+
* The load balancer idle timeout, in seconds
310+
*
311+
* @default - CloudFormation sets idle timeout to 60 seconds
312+
*/
313+
readonly idleTimeout?: Duration;
307314
}
308315

309316
/**
@@ -408,8 +415,9 @@ export abstract class ApplicationMultipleTargetGroupsServiceBase extends Constru
408415
}
409416

410417
if (props.loadBalancers) {
418+
this.validateLbProps(props.loadBalancers);
411419
for (const lbProps of props.loadBalancers) {
412-
const lb = this.createLoadBalancer(lbProps.name, lbProps.publicLoadBalancer);
420+
const lb = this.createLoadBalancer(lbProps.name, lbProps.publicLoadBalancer, lbProps.idleTimeout);
413421
this.loadBalancers.push(lb);
414422
const protocolType = new Set<ApplicationProtocol>();
415423
for (const listenerProps of lbProps.listeners) {
@@ -564,11 +572,23 @@ export abstract class ApplicationMultipleTargetGroupsServiceBase extends Constru
564572
}
565573
}
566574

567-
private createLoadBalancer(name: string, publicLoadBalancer?: boolean): ApplicationLoadBalancer {
575+
private validateLbProps(props: ApplicationLoadBalancerProps[]) {
576+
for (let prop of props) {
577+
if (prop.idleTimeout) {
578+
if (prop.idleTimeout > Duration.seconds(4000) || prop.idleTimeout < Duration.seconds(1)) {
579+
throw new Error('Load balancer idle timeout must be between 1 and 4000 seconds.');
580+
}
581+
}
582+
}
583+
584+
}
585+
586+
private createLoadBalancer(name: string, publicLoadBalancer?: boolean, idleTimeout?: Duration): ApplicationLoadBalancer {
568587
const internetFacing = publicLoadBalancer ?? true;
569588
const lbProps = {
570589
vpc: this.cluster.vpc,
571590
internetFacing,
591+
idleTimeout: idleTimeout,
572592
};
573593

574594
return new ApplicationLoadBalancer(this, name, lbProps);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
{
22
"version": "20.0.0",
33
"testCases": {
4-
"@aws-cdk/aws-ecs-patterns/test/ec2/integ.application-load-balanced-ecs-service": {
4+
"applicationLoadBalancedEc2ServiceTest/DefaultTest": {
55
"stacks": [
66
"aws-ecs-integ"
77
],
8-
"diffAssets": false,
9-
"stackUpdateWorkflow": true
8+
"assertionStack": "applicationLoadBalancedEc2ServiceTestDefaultTestDeployAssert3356477A"
109
}
11-
},
12-
"synthContext": {},
13-
"enableLookups": false
10+
}
1411
}

packages/@aws-cdk/aws-ecs-patterns/test/ec2/application-load-balanced-ecs-service.integ.snapshot/manifest.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,15 @@
329329
]
330330
},
331331
"displayName": "aws-ecs-integ"
332+
},
333+
"applicationLoadBalancedEc2ServiceTestDefaultTestDeployAssert3356477A": {
334+
"type": "aws:cloudformation:stack",
335+
"environment": "aws://unknown-account/unknown-region",
336+
"properties": {
337+
"templateFile": "applicationLoadBalancedEc2ServiceTestDefaultTestDeployAssert3356477A.template.json",
338+
"validateOnSynth": false
339+
},
340+
"displayName": "applicationLoadBalancedEc2ServiceTest/DefaultTest/DeployAssert"
332341
}
333342
}
334343
}

packages/@aws-cdk/aws-ecs-patterns/test/ec2/application-load-balanced-ecs-service.integ.snapshot/tree.json

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"path": "Tree",
1010
"constructInfo": {
1111
"fqn": "constructs.Construct",
12-
"version": "10.1.33"
12+
"version": "10.1.49"
1313
}
1414
},
1515
"aws-ecs-integ": {
@@ -1803,6 +1803,42 @@
18031803
"fqn": "@aws-cdk/core.Stack",
18041804
"version": "0.0.0"
18051805
}
1806+
},
1807+
"applicationLoadBalancedEc2ServiceTest": {
1808+
"id": "applicationLoadBalancedEc2ServiceTest",
1809+
"path": "applicationLoadBalancedEc2ServiceTest",
1810+
"children": {
1811+
"DefaultTest": {
1812+
"id": "DefaultTest",
1813+
"path": "applicationLoadBalancedEc2ServiceTest/DefaultTest",
1814+
"children": {
1815+
"Default": {
1816+
"id": "Default",
1817+
"path": "applicationLoadBalancedEc2ServiceTest/DefaultTest/Default",
1818+
"constructInfo": {
1819+
"fqn": "constructs.Construct",
1820+
"version": "10.1.49"
1821+
}
1822+
},
1823+
"DeployAssert": {
1824+
"id": "DeployAssert",
1825+
"path": "applicationLoadBalancedEc2ServiceTest/DefaultTest/DeployAssert",
1826+
"constructInfo": {
1827+
"fqn": "@aws-cdk/core.Stack",
1828+
"version": "0.0.0"
1829+
}
1830+
}
1831+
},
1832+
"constructInfo": {
1833+
"fqn": "@aws-cdk/integ-tests.IntegTestCase",
1834+
"version": "0.0.0"
1835+
}
1836+
}
1837+
},
1838+
"constructInfo": {
1839+
"fqn": "@aws-cdk/integ-tests.IntegTest",
1840+
"version": "0.0.0"
1841+
}
18061842
}
18071843
},
18081844
"constructInfo": {

0 commit comments

Comments
 (0)