Skip to content
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

pr #1

Merged
merged 59 commits into from
Dec 28, 2020
Merged

pr #1

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
88d4149
feat(ecs-patterns): containerName for QueueProcessingEc2Service
iRoachie Oct 25, 2020
1a87cd6
Merge branch 'master' into container-name
iRoachie Oct 26, 2020
fad27f6
feat: Configre containerName for QueueProcessingFargateService
iRoachie Nov 3, 2020
bd1a780
Merge branch 'master' into container-name
SoManyHs Nov 10, 2020
f2ecaf2
chore(rds): document DatabaseInstance.fromDatabaseInstanceAttributes(…
ktheory Dec 15, 2020
bab21b3
feat(lambda-nodejs): expose more esbuild options (#12063)
jogold Dec 15, 2020
bc5b9b6
chore(apigatewayv2): apiEndpoint is elevated to the IHttpApi interfac…
Dec 15, 2020
1078bea
feat(eks): attach cluster security group to self-managed nodes (#12042)
iliapolo Dec 15, 2020
946db91
chore(stepfunctions-tasks): update doc strings to point to correct re…
shivlaks Dec 15, 2020
0802c13
chore(eks): log the command before invoking aws eks (#12088)
valters Dec 15, 2020
78c185d
feat(appmesh): add timeout support to Routes (#11973)
skiyani Dec 15, 2020
bf05092
feat(stepfunctions-tasks): add support for ModelClientConfig to SageM…
setu4993 Dec 15, 2020
054610f
revert(rds): document DatabaseInstance.fromDatabaseInstanceAttributes…
iliapolo Dec 15, 2020
607d320
chore: update module ownership (#11967)
njlynch Dec 16, 2020
d10ea63
feat(elasticsearch): support audit logs (#12106)
Ruben-E Dec 16, 2020
8f6f9a8
feat(route53): Vpc endpoint service private dns (#10780)
flemjame-at-amazon Dec 17, 2020
9b19e29
chore(release): 1.79.0
Dec 17, 2020
d5afb55
fix(lambda-nodejs): local bundling fails with relative depsLockFilePa…
jogold Dec 17, 2020
8b3bf9c
chore(release): 1.79.0
iliapolo Dec 17, 2020
751c80f
Merge branch 'master' into merge-back/1.79.0
mergify[bot] Dec 17, 2020
184b0eb
chore(merge-back): 1.79.0 (#12135)
mergify[bot] Dec 17, 2020
7a120f3
chore(logs): Fix typo (#12133)
deepyaman Dec 17, 2020
4e1d951
chore(iam): fix typo in policy.ts (#12124)
pirosikick Dec 17, 2020
23d10df
chore: compat script will now also install peer dependencies (#12142)
Dec 18, 2020
ecc98ac
feat(lambda-nodejs): Expose optional props for advanced usage of esbu…
hassanazharkhan Dec 21, 2020
eaa8222
feat(eks): connect all custom resources to the cluster VPC (#10200)
iliapolo Dec 21, 2020
71cd38c
fix(core): capturing stack traces still takes a long time (#12180)
rix0rrr Dec 21, 2020
7951756
chore: rename .github/semantic.yaml to .github/semantic.yml (no "a") …
NetaNir Dec 21, 2020
73ef6b1
feat(ec2): Add VPC endpoints for Athena and Glue (#12073)
Wenger Dec 22, 2020
c3e8519
Merge branch 'master' into container-name
SoManyHs Dec 22, 2020
b1318bd
feat(ecs-patterns): add ruleName optional parameter for ScheduledTask…
SoManyHs Dec 22, 2020
ab5a383
fix(dynamodb): allow global replicas with Provisioned billing mode (#…
skinny85 Dec 22, 2020
6a20e61
chore(eks): Remove legacy and deprecated code (#12189)
iliapolo Dec 22, 2020
2ab7db6
chore(release): 1.80.0
Dec 22, 2020
bcce027
Update CHANGELOG.md
Dec 22, 2020
e425ffa
Update CHANGELOG.md
Dec 22, 2020
31132ca
chore(release): 1.80.0 (#12195)
mergify[bot] Dec 22, 2020
3d1ba38
chore(merge-back): 1.80.0 (#12197)
mergify[bot] Dec 22, 2020
1a13d8f
fix(codebuild): missing permissions for SecretsManager environment va…
skinny85 Dec 22, 2020
9d4479e
Merge branch 'master' into container-name
SoManyHs Dec 22, 2020
579b923
feat(eks): option to disable manifest validation (#12012)
ayush987goyal Dec 22, 2020
e19f4ba
Merge branch 'master' into container-name
SoManyHs Dec 22, 2020
6ccd00f
feat(eks): spot support for managed nodegroups (#11962)
pahud Dec 22, 2020
1d0148a
Merge branch 'master' into container-name
SoManyHs Dec 22, 2020
52a80bb
Merge pull request #11093 from iRoachie/container-name
SoManyHs Dec 23, 2020
e8801a0
feat(ecs): deployment circuit breaker support (#12168)
pahud Dec 23, 2020
336788d
chore: discourage AdministratorAccess policy (#12196)
rix0rrr Dec 23, 2020
53f092f
chore: upgrade node-notifier (#12209)
rix0rrr Dec 23, 2020
b92ed51
fix(codebuild): Project lacks permissions to its log destinations (#1…
skinny85 Dec 23, 2020
63bc98f
feat(eks): bundle kubectl, helm and awscli instead of SAR app (#12129)
Dec 24, 2020
a4934be
chore(s3-deployment): restore lambda tests (#12220)
Dec 24, 2020
5279f37
fix(codepipeline-actions): use codebuild batch iam permissions when `…
tjenkinson Dec 24, 2020
d9353b7
feat(codebuild): add `startBatchBuild` option (#11743)
tjenkinson Dec 24, 2020
998af8f
feat(codebuild): prevent using Secrets in plain-text environment vari…
skinny85 Dec 24, 2020
09d1f6c
feat(elasticsearch): add support for version 7_8 and 7_9 (#12222)
Dec 25, 2020
c752fab
feat(eks): aws-node-termination-handler for spot instances now pulls …
neilkuan Dec 25, 2020
32e9c23
feat(s3): option to auto delete objects upon bucket removal (#12090)
jogold Dec 26, 2020
14f8b06
feat(elasticsearch): Support `EnableVersionUpgrade` update policy (#1…
hassanazharkhan Dec 27, 2020
6be8500
chore(lambda-nodejs): always use globally installed esbuild in Docker…
jogold Dec 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
74 changes: 37 additions & 37 deletions .github/workflows/issue-label-assign.yml

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,70 @@

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.

## [1.80.0](https://github.com/aws/aws-cdk/compare/v1.79.0...v1.80.0) (2020-12-22)


### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES

* **eks:** `LegacyCluster` was removed since it existed only for a transition period to allow gradual migration to the current cluster class.
* **eks:** `kubectlEnabled` property was removed, all clusters now support `kubectl`.
* **core:** Creation stack traces for `Lazy` values are no longer
captured by default in order to speed up tests. Run with
`CDK_DEBUG=true` (or `cdk --debug`) to capture stack traces.

### Features

* **ec2:** Add VPC endpoints for Athena and Glue ([#12073](https://github.com/aws/aws-cdk/issues/12073)) ([73ef6b1](https://github.com/aws/aws-cdk/commit/73ef6b180c8a7c3d8e984b308149eeb9eb78b40b)), closes [#12072](https://github.com/aws/aws-cdk/issues/12072)
* **ecs-patterns:** add ruleName optional parameter for ScheduledTask constructs ([#12190](https://github.com/aws/aws-cdk/issues/12190)) ([b1318bd](https://github.com/aws/aws-cdk/commit/b1318bda54d1c0955a371eccce76b748d312b570))
* **eks:** connect all custom resources to the cluster VPC ([#10200](https://github.com/aws/aws-cdk/issues/10200)) ([eaa8222](https://github.com/aws/aws-cdk/commit/eaa82222349fcce1ef4b80e873a35002d6f036e5))
* **lambda-nodejs:** Expose optional props for advanced usage of esbuild ([#12123](https://github.com/aws/aws-cdk/issues/12123)) ([ecc98ac](https://github.com/aws/aws-cdk/commit/ecc98ac75acb1adbb4f5e66f853dc3226e490c98))


### Bug Fixes

* **core:** capturing stack traces still takes a long time ([#12180](https://github.com/aws/aws-cdk/issues/12180)) ([71cd38c](https://github.com/aws/aws-cdk/commit/71cd38c8fac276e34b79ad416305b214a57af25a)), closes [#11170](https://github.com/aws/aws-cdk/issues/11170)
* **dynamodb:** allow global replicas with Provisioned billing mode ([#12159](https://github.com/aws/aws-cdk/issues/12159)) ([ab5a383](https://github.com/aws/aws-cdk/commit/ab5a38379999bb57f28bbf22ec09d315df6b358a)), closes [#11346](https://github.com/aws/aws-cdk/issues/11346)
* **lambda-nodejs:** local bundling fails with relative depsLockFilePath ([#12125](https://github.com/aws/aws-cdk/issues/12125)) ([d5afb55](https://github.com/aws/aws-cdk/commit/d5afb555b983c8c034f63dd58d1fa24b82b6e9fe)), closes [#12115](https://github.com/aws/aws-cdk/issues/12115)
* **eks:** Remove legacy and deprecated code ([#12189](https://github.com/aws/aws-cdk/issues/12189)) ([6a20e61](https://github.com/aws/aws-cdk/commit/6a20e61dd2ed8366cbff1451c943a02b79380de2))

## [1.79.0](https://github.com/aws/aws-cdk/compare/v1.78.0...v1.79.0) (2020-12-17)


### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES

* **apigatewayv2:** `HttpApi.fromApiId()` has been replaced with
`HttpApi.fromHttpApiAttributes()`.
* **elasticsearch:** ES Domain LogGroup LogicalId will change, which will trigger new log group resources to be created

### Features

* **appmesh:** add timeout support to Routes ([#11973](https://github.com/aws/aws-cdk/issues/11973)) ([78c185d](https://github.com/aws/aws-cdk/commit/78c185d15e64e81ee86ee71cd6430cd80fdbb8fe))
* **core:** expose custom resource provider's role ([#11923](https://github.com/aws/aws-cdk/issues/11923)) ([06f26d3](https://github.com/aws/aws-cdk/commit/06f26d390707b0e2a4e05e36405a4751c907a234)), closes [/github.com/aws/aws-cdk/pull/9751#issuecomment-723554595](https://github.com/aws//github.com/aws/aws-cdk/pull/9751/issues/issuecomment-723554595)
* **ec2:** add r5b instance type to instance class ([#12027](https://github.com/aws/aws-cdk/issues/12027)) ([d276b02](https://github.com/aws/aws-cdk/commit/d276b020e61ee4455c7ed9f093436d1aab319e76)), closes [#12025](https://github.com/aws/aws-cdk/issues/12025)
* **ecs-patterns:** Add DeploymentController option to Fargate services ([#10452](https://github.com/aws/aws-cdk/issues/10452)) ([2cd233a](https://github.com/aws/aws-cdk/commit/2cd233a94fc2f3cb06211157738e59e8c7ee85e5)), closes [aws/containers-roadmap#130](https://github.com/aws/containers-roadmap/issues/130) [#10971](https://github.com/aws/aws-cdk/issues/10971)
* **eks:** attach cluster security group to self-managed nodes ([#12042](https://github.com/aws/aws-cdk/issues/12042)) ([1078bea](https://github.com/aws/aws-cdk/commit/1078bea4c90afaac76a5e81328a9d6ec44a79e9a))
* **elasticsearch:** support audit logs ([#12106](https://github.com/aws/aws-cdk/issues/12106)) ([d10ea63](https://github.com/aws/aws-cdk/commit/d10ea631f8699385cadf61d6e0a067b68da37df6)), closes [#12105](https://github.com/aws/aws-cdk/issues/12105)
* **ivs:** add IVS L2 Constructs ([#11454](https://github.com/aws/aws-cdk/issues/11454)) ([f813bff](https://github.com/aws/aws-cdk/commit/f813bff2da4792cfa7bfce6f572a7d2bb5c4759d))
* **lambda:** encryption key for environment variables ([#11893](https://github.com/aws/aws-cdk/issues/11893)) ([ccbaf83](https://github.com/aws/aws-cdk/commit/ccbaf8399c3a9f3ff6e60758e0b713d82f37420b)), closes [#10837](https://github.com/aws/aws-cdk/issues/10837)
* **lambda-nodejs:** expose more esbuild options ([#12063](https://github.com/aws/aws-cdk/issues/12063)) ([bab21b3](https://github.com/aws/aws-cdk/commit/bab21b377593b7475b047d05a54914344352c054)), closes [#12046](https://github.com/aws/aws-cdk/issues/12046)
* **route53:** Vpc endpoint service private dns ([#10780](https://github.com/aws/aws-cdk/issues/10780)) ([8f6f9a8](https://github.com/aws/aws-cdk/commit/8f6f9a8678496e131a43ca4c76e561d50a0a0de8))
* **s3-deployment:** support vpc in BucketDeploymentProps ([#12035](https://github.com/aws/aws-cdk/issues/12035)) ([6caf72f](https://github.com/aws/aws-cdk/commit/6caf72f67d6d3373186e57f32671369c2cc8b56e)), closes [#11734](https://github.com/aws/aws-cdk/issues/11734)
* **stepfunctions-tasks:** add support for ModelClientConfig to SageMakerCreateTransformJob ([#11892](https://github.com/aws/aws-cdk/issues/11892)) ([bf05092](https://github.com/aws/aws-cdk/commit/bf050928c033328b259746c0a7f33038aadc4c17))


### Bug Fixes

* **ec2:** 'encoded list token' error using Vpc imported from deploy-time lists ([#12040](https://github.com/aws/aws-cdk/issues/12040)) ([0690da9](https://github.com/aws/aws-cdk/commit/0690da925144c821a73bfab4ae8d678a8c074357))
* **ec2:** fromInterfaceVpcEndpointAttributes: Security Groups should not be required ([#11857](https://github.com/aws/aws-cdk/issues/11857)) ([86ae5d6](https://github.com/aws/aws-cdk/commit/86ae5d6ec5291f7a8da37bbf021c31f88e66d283)), closes [#11050](https://github.com/aws/aws-cdk/issues/11050)
* **eks:** failure to deploy cluster since aws-auth configmap exists ([#12068](https://github.com/aws/aws-cdk/issues/12068)) ([dc8a98a](https://github.com/aws/aws-cdk/commit/dc8a98a5436a7a2347fa9676d84f73a8cf00cd49)), closes [#12053](https://github.com/aws/aws-cdk/issues/12053)
* **eks:** k8s resources accidentally deleted due to logical ID change ([#12053](https://github.com/aws/aws-cdk/issues/12053)) ([019852e](https://github.com/aws/aws-cdk/commit/019852e4834327d848c9fe8dc271f1d4d5117fb8)), closes [#10397](https://github.com/aws/aws-cdk/issues/10397) [#10397](https://github.com/aws/aws-cdk/issues/10397)
* **elasticsearch:** Defining 2 domains with logging enabled in the same stack fails on construct id conflict ([#12055](https://github.com/aws/aws-cdk/issues/12055)) ([ec3ce19](https://github.com/aws/aws-cdk/commit/ec3ce19bc8203703cb1abcecdb2afc674c2013f6)), closes [#12017](https://github.com/aws/aws-cdk/issues/12017)
* **elasticsearch:** log policies are overwritten when creating 2 domains which also results in a failure while destroying the stack ([#12056](https://github.com/aws/aws-cdk/issues/12056)) ([889d089](https://github.com/aws/aws-cdk/commit/889d0892bae10243e03900f0ae6db078fc7eb320)), closes [#12016](https://github.com/aws/aws-cdk/issues/12016)
* **stepfunctions-tasks:** policies created for EMR tasks have ARNs that are not partition-aware ([#11553](https://github.com/aws/aws-cdk/issues/11553)) ([1cf6713](https://github.com/aws/aws-cdk/commit/1cf6713b778c789af7a420ad890910a9516473f0)), closes [#11503](https://github.com/aws/aws-cdk/issues/11503)


* **apigatewayv2:** apiEndpoint is elevated to the IHttpApi interface ([#11988](https://github.com/aws/aws-cdk/issues/11988)) ([bc5b9b6](https://github.com/aws/aws-cdk/commit/bc5b9b659444bfbef9cfc3c8666fce7e6f45465a))

## [1.78.0](https://github.com/aws/aws-cdk/compare/v1.77.0...v1.78.0) (2020-12-11)


Expand Down
40 changes: 32 additions & 8 deletions packages/@aws-cdk/aws-apigatewayv2/lib/http/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export interface IHttpApi extends IResource {
*/
readonly httpApiId: string;

/**
* The default endpoint for an API
* @attribute
*/
readonly apiEndpoint: string;

/**
* The default stage
*/
Expand Down Expand Up @@ -184,6 +190,7 @@ export interface AddRoutesOptions extends BatchHttpRouteOptions {
abstract class HttpApiBase extends Resource implements IHttpApi { // note that this is not exported

public abstract readonly httpApiId: string;
public abstract readonly apiEndpoint: string;
private vpcLinks: Record<string, VpcLink> = {};

public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
Expand Down Expand Up @@ -233,6 +240,21 @@ abstract class HttpApiBase extends Resource implements IHttpApi { // note that t
}
}

/**
* Attributes for importing an HttpApi into the CDK
*/
export interface HttpApiAttributes {
/**
* The identifier of the HttpApi
*/
readonly httpApiId: string;
/**
* The endpoint URL of the HttpApi
* @default - throws an error if apiEndpoint is accessed.
*/
readonly apiEndpoint?: string;
}

/**
* Create a new API Gateway HTTP API endpoint.
* @resource AWS::ApiGatewayV2::Api
Expand All @@ -241,9 +263,17 @@ export class HttpApi extends HttpApiBase {
/**
* Import an existing HTTP API into this CDK app.
*/
public static fromApiId(scope: Construct, id: string, httpApiId: string): IHttpApi {
public static fromHttpApiAttributes(scope: Construct, id: string, attrs: HttpApiAttributes): IHttpApi {
class Import extends HttpApiBase {
public readonly httpApiId = httpApiId;
public readonly httpApiId = attrs.httpApiId;
private readonly _apiEndpoint = attrs.apiEndpoint;

public get apiEndpoint(): string {
if (!this._apiEndpoint) {
throw new Error('apiEndpoint is not configured on the imported HttpApi.');
}
return this._apiEndpoint;
}
}
return new Import(scope, id);
}
Expand All @@ -252,13 +282,7 @@ export class HttpApi extends HttpApiBase {
* A human friendly name for this HTTP API. Note that this is different from `httpApiId`.
*/
public readonly httpApiName?: string;

public readonly httpApiId: string;

/**
* The default endpoint for an API
* @attribute
*/
public readonly apiEndpoint: string;

/**
Expand Down
16 changes: 11 additions & 5 deletions packages/@aws-cdk/aws-apigatewayv2/test/http/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ describe('HttpApi', () => {

test('import', () => {
const stack = new Stack();
const api = new HttpApi(stack, 'api', { apiName: 'customName' });
const imported = HttpApi.fromApiId(stack, 'imported', api.httpApiId );

expect(imported.httpApiId).toEqual(api.httpApiId);
const imported = HttpApi.fromHttpApiAttributes(stack, 'imported', { httpApiId: 'http-1234', apiEndpoint: 'api-endpoint' });

expect(imported.httpApiId).toEqual('http-1234');
expect(imported.apiEndpoint).toEqual('api-endpoint');
});

test('unsetting createDefaultStage', () => {
Expand Down Expand Up @@ -188,7 +187,7 @@ describe('HttpApi', () => {
// GIVEN
const stack = new Stack();
const apiId = 'importedId';
const api = HttpApi.fromApiId(stack, 'test-api', apiId);
const api = HttpApi.fromHttpApiAttributes(stack, 'test-api', { httpApiId: apiId });
const metricName = '4xxError';
const statistic = 'Sum';

Expand Down Expand Up @@ -261,6 +260,13 @@ describe('HttpApi', () => {

expect(api.apiEndpoint).toBeDefined();
});

test('apiEndpoint for imported', () => {
const stack = new Stack();
const api = HttpApi.fromHttpApiAttributes(stack, 'imported', { httpApiId: 'api-1234' });

expect(() => api.apiEndpoint).toThrow(/apiEndpoint is not configured/);
});
});

class DummyRouteIntegration implements IHttpRouteIntegration {
Expand Down
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-appmesh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ The `tcp()`, `http()` and `http2()` methods provide the spec necessary to define

For HTTP based routes, the match field can be used to match on a route prefix.
By default, an HTTP based route will match on `/`. All matches must start with a leading `/`.
The timeout field can also be specified for `idle` and `perRequest` timeouts.

```ts
router.addRoute('route-http', {
Expand All @@ -301,6 +302,10 @@ router.addRoute('route-http', {
match: {
serviceName: 'my-service.default.svc.cluster.local',
},
timeout: {
idle : Duration.seconds(2),
perRequest: Duration.seconds(1),
},
}),
});
```
Expand Down
62 changes: 61 additions & 1 deletion packages/@aws-cdk/aws-appmesh/lib/route-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as cdk from '@aws-cdk/core';
import { CfnRoute } from './appmesh.generated';
import { Protocol } from './shared-interfaces';
import { Protocol, HttpTimeout, GrpcTimeout, TcpTimeout } from './shared-interfaces';
import { IVirtualNode } from './virtual-node';

/**
Expand Down Expand Up @@ -58,6 +58,13 @@ export interface HttpRouteSpecOptions {
* List of targets that traffic is routed to when a request matches the route
*/
readonly weightedTargets: WeightedTarget[];

/**
* An object that represents a http timeout
*
* @default - None
*/
readonly timeout?: HttpTimeout;
}

/**
Expand All @@ -68,6 +75,13 @@ export interface TcpRouteSpecOptions {
* List of targets that traffic is routed to when a request matches the route
*/
readonly weightedTargets: WeightedTarget[];

/**
* An object that represents a tcp timeout
*
* @default - None
*/
readonly timeout?: TcpTimeout;
}

/**
Expand All @@ -79,6 +93,13 @@ export interface GrpcRouteSpecOptions {
*/
readonly match: GrpcRouteMatch;

/**
* An object that represents a grpc timeout
*
* @default - None
*/
readonly timeout?: GrpcTimeout;

/**
* List of targets that traffic is routed to when a request matches the route
*/
Expand Down Expand Up @@ -169,6 +190,11 @@ class HttpRouteSpec extends RouteSpec {
*/
public readonly match?: HttpRouteMatch;

/**
* The criteria for determining a timeout configuration
*/
public readonly timeout?: HttpTimeout;

/**
* List of targets that traffic is routed to when a request matches the route
*/
Expand All @@ -179,6 +205,7 @@ class HttpRouteSpec extends RouteSpec {
this.protocol = protocol;
this.match = props.match;
this.weightedTargets = props.weightedTargets;
this.timeout = props.timeout;
}

public bind(_scope: cdk.Construct): RouteSpecConfig {
Expand All @@ -193,6 +220,7 @@ class HttpRouteSpec extends RouteSpec {
match: {
prefix: prefixPath,
},
timeout: renderTimeout(this.timeout),
};
return {
httpRouteSpec: this.protocol === Protocol.HTTP ? httpConfig : undefined,
Expand All @@ -207,9 +235,15 @@ class TcpRouteSpec extends RouteSpec {
*/
public readonly weightedTargets: WeightedTarget[];

/**
* The criteria for determining a timeout configuration
*/
public readonly timeout?: TcpTimeout;

constructor(props: TcpRouteSpecOptions) {
super();
this.weightedTargets = props.weightedTargets;
this.timeout = props.timeout;
}

public bind(_scope: cdk.Construct): RouteSpecConfig {
Expand All @@ -218,6 +252,7 @@ class TcpRouteSpec extends RouteSpec {
action: {
weightedTargets: renderWeightedTargets(this.weightedTargets),
},
timeout: renderTimeout(this.timeout),
},
};
}
Expand All @@ -226,11 +261,13 @@ class TcpRouteSpec extends RouteSpec {
class GrpcRouteSpec extends RouteSpec {
public readonly weightedTargets: WeightedTarget[];
public readonly match: GrpcRouteMatch;
public readonly timeout?: GrpcTimeout;

constructor(props: GrpcRouteSpecOptions) {
super();
this.weightedTargets = props.weightedTargets;
this.match = props.match;
this.timeout = props.timeout;
}

public bind(_scope: cdk.Construct): RouteSpecConfig {
Expand All @@ -242,6 +279,7 @@ class GrpcRouteSpec extends RouteSpec {
match: {
serviceName: this.match.serviceName,
},
timeout: renderTimeout(this.timeout),
},
};
}
Expand All @@ -260,3 +298,25 @@ function renderWeightedTargets(weightedTargets: WeightedTarget[]): CfnRoute.Weig
}
return renderedTargets;
}

/**
* Utility method to construct a route timeout object
*/
function renderTimeout(timeout?: HttpTimeout): CfnRoute.HttpTimeoutProperty | undefined {
return timeout
? {
idle: timeout?.idle !== undefined
? {
unit: 'ms',
value: timeout?.idle.toMilliseconds(),
}
: undefined,
perRequest: timeout?.perRequest !== undefined
? {
unit: 'ms',
value: timeout?.perRequest.toMilliseconds(),
}
: undefined,
}
: undefined;
}
Loading