Skip to content

Commit

Permalink
Merge branch 'main' into neptune-cw-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
humanzz authored Sep 25, 2022
2 parents 9a1d862 + 87e2020 commit fb6211f
Show file tree
Hide file tree
Showing 33 changed files with 705 additions and 404 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"fs-extra": "^9.1.0",
"graceful-fs": "^4.2.10",
"jest-junit": "^13.2.0",
"jsii-diff": "^1.67.0",
"jsii-pacmak": "^1.67.0",
"jsii-reflect": "^1.67.0",
"jsii-rosetta": "^1.67.0",
"jsii-diff": "^1.68.0",
"jsii-pacmak": "^1.68.0",
"jsii-reflect": "^1.68.0",
"jsii-rosetta": "^1.68.0",
"lerna": "^4.0.0",
"patch-package": "^6.4.7",
"semver": "^6.3.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export class InterfaceVpcEndpointAwsService implements IInterfaceVpcEndpointServ
public static readonly LAMBDA = new InterfaceVpcEndpointAwsService('lambda');
public static readonly TRANSCRIBE = new InterfaceVpcEndpointAwsService('transcribe');
public static readonly XRAY = new InterfaceVpcEndpointAwsService('xray');
public static readonly SECURITYHUB = new InterfaceVpcEndpointAwsService('securityhub');

/**
* The name of the service. e.g. com.amazonaws.us-east-1.ecs
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-ec2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
"docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.LAMBDA",
"docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.TRANSCRIBE",
"docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.XRAY",
"docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.SECURITYHUB",
"docs-public-apis:@aws-cdk/aws-ec2.Port.toString",
"docs-public-apis:@aws-cdk/aws-ec2.PrivateSubnet.fromPrivateSubnetAttributes",
"docs-public-apis:@aws-cdk/aws-ec2.PublicSubnet.fromPublicSubnetAttributes",
Expand Down
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-ecs/lib/base/task-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ export interface TaskDefinitionProps extends CommonTaskDefinitionProps {
*
* 4096 (4 vCPU) - Available memory values: Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB)
*
* 8192 (8 vCPU) - Available memory values: Between 16384 (16 GB) and 61440 (60 GB) in increments of 4096 (4 GB)
*
* 16384 (16 vCPU) - Available memory values: Between 32768 (32 GB) and 122880 (120 GB) in increments of 8192 (8 GB)
*
* @default - CPU units are not specified.
*/
readonly cpu?: string;
Expand All @@ -170,6 +174,10 @@ export interface TaskDefinitionProps extends CommonTaskDefinitionProps {
*
* Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available cpu values: 4096 (4 vCPU)
*
* Between 16384 (16 GB) and 61440 (60 GB) in increments of 4096 (4 GB) - Available cpu values: 8192 (8 vCPU)
*
* Between 32768 (32 GB) and 122880 (120 GB) in increments of 8192 (8 GB) - Available cpu values: 16384 (16 vCPU)
*
* @default - Memory used by task is not specified.
*/
readonly memoryMiB?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export interface FargateTaskDefinitionProps extends CommonTaskDefinitionProps {
*
* 4096 (4 vCPU) - Available memory values: Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB)
*
* 8192 (8 vCPU) - Available memory values: Between 16384 (16 GB) and 61440 (60 GB) in increments of 4096 (4 GB)
*
* 16384 (16 vCPU) - Available memory values: Between 32768 (32 GB) and 122880 (120 GB) in increments of 8192 (8 GB)
*
* @default 256
*/
readonly cpu?: number;
Expand All @@ -48,6 +52,10 @@ export interface FargateTaskDefinitionProps extends CommonTaskDefinitionProps {
*
* Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available cpu values: 4096 (4 vCPU)
*
* Between 16384 (16 GB) and 61440 (60 GB) in increments of 4096 (4 GB) - Available cpu values: 8192 (8 vCPU)
*
* Between 32768 (32 GB) and 122880 (120 GB) in increments of 8192 (8 GB) - Available cpu values: 16384 (16 vCPU)
*
* @default 512
*/
readonly memoryLimitMiB?: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-eks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"@types/sinon": "^9.0.11",
"@types/yaml": "1.9.6",
"aws-sdk": "^2.848.0",
"cdk8s": "^2.4.27",
"cdk8s": "^2.4.33",
"cdk8s-plus-21": "^2.0.0-beta.12",
"jest": "^27.5.1",
"sinon": "^9.2.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export abstract class ImportedTargetGroupBase extends Construct implements ITarg
super(scope, id);

this.targetGroupArn = props.targetGroupArn;
this.targetGroupName = cdk.Stack.of(scope).splitArn(props.targetGroupArn, cdk.ArnFormat.SLASH_RESOURCE_SLASH_RESOURCE_NAME).resourceName!.split('/')[0];
this.targetGroupName = cdk.Stack.of(scope).splitArn(props.targetGroupArn, cdk.ArnFormat.SLASH_RESOURCE_NAME).resourceName!.split('/')[0];
this.loadBalancerArns = props.loadBalancerArns || cdk.Aws.NO_VALUE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,51 @@ describe('tests', () => {
// THEN
expect(importedTg.targetGroupName).toEqual('myAlbTargetGroup');
});

test('imported targetGroup with imported ARN has targetGroupName', () => {
// GIVEN
const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack');

// WHEN
const importedTgArn = cdk.Fn.importValue('ImportTargetGroupArn');
const importedTg = elbv2.ApplicationTargetGroup.fromTargetGroupAttributes(stack, 'importedTg', {
targetGroupArn: importedTgArn,
});
new cdk.CfnOutput(stack, 'TargetGroupOutput', {
value: importedTg.targetGroupName,
});

// THEN
Template.fromStack(stack).hasOutput('TargetGroupOutput', {
Value: {
'Fn::Select': [
// myAlbTargetGroup
1,
{
'Fn::Split': [
// [targetgroup, myAlbTargetGroup, 73e2d6bc24d8a067]
'/',
{
'Fn::Select': [
// targetgroup/myAlbTargetGroup/73e2d6bc24d8a067
5,
{
'Fn::Split': [
// [arn, aws, elasticloadbalancing, us-west-2, 123456789012, targetgroup/myAlbTargetGroup/73e2d6bc24d8a067]
':',
{
// arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/myAlbTargetGroup/73e2d6bc24d8a067
'Fn::ImportValue': 'ImportTargetGroupArn',
},
],
},
],
},
],
},
],
},
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,51 @@ describe('tests', () => {
// THEN
expect(importedTg.targetGroupName).toEqual('myNlbTargetGroup');
});

test('imported targetGroup with imported ARN has targetGroupName', () => {
// GIVEN
const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack');

// WHEN
const importedTgArn = cdk.Fn.importValue('ImportTargetGroupArn');
const importedTg = elbv2.ApplicationTargetGroup.fromTargetGroupAttributes(stack, 'importedTg', {
targetGroupArn: importedTgArn,
});
new cdk.CfnOutput(stack, 'TargetGroupOutput', {
value: importedTg.targetGroupName,
});

// THEN
Template.fromStack(stack).hasOutput('TargetGroupOutput', {
Value: {
'Fn::Select': [
// myNlbTargetGroup
1,
{
'Fn::Split': [
// [targetgroup, myNlbTargetGroup, 73e2d6bc24d8a067]
'/',
{
'Fn::Select': [
// targetgroup/myNlbTargetGroup/73e2d6bc24d8a067
5,
{
'Fn::Split': [
// [arn, aws, elasticloadbalancing, us-west-2, 123456789012, targetgroup/myNlbTargetGroup/73e2d6bc24d8a067]
':',
{
// arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/myNlbTargetGroup/73e2d6bc24d8a067
'Fn::ImportValue': 'ImportTargetGroupArn',
},
],
},
],
},
],
},
],
},
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as events from '@aws-cdk/aws-events';
import * as logs from '@aws-cdk/aws-logs';
import * as sqs from '@aws-cdk/aws-sqs';
import * as cdk from '@aws-cdk/core';
import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests';
import * as targets from '../../lib';
import { IntegTest, ExpectedResult, AssertionsProvider } from '@aws-cdk/integ-tests';
import { LogGroupTargetInput } from '../../lib';

const app = new cdk.App();
Expand Down Expand Up @@ -71,16 +71,15 @@ const putEvent = integ.assertions.awsApiCall('EventBridge', 'putEvents', {
},
],
});
const assertionProvider = putEvent.node.tryFindChild('SdkProvider') as AssertionsProvider;
assertionProvider.addPolicyStatementFromSdkCall('events', 'PutEvents');
putEvent.provider.addPolicyStatementFromSdkCall('events', 'PutEvents');

const logEvents = integ.assertions.awsApiCall('CloudWatchLogs', 'filterLogEvents', {
logGroupName: logGroup2.logGroupName,
startTime: putEventsDate,
limit: 1,
});

logEvents.node.addDependency(putEvent);
putEvent.next(logEvents);

logEvents.assertAtPath('events.0.message', ExpectedResult.stringLikeRegexp(expectedValue));

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"delay": "5.0.0",
"esbuild": "^0.15.7"
"esbuild": "^0.15.8"
},
"dependencies": {
"@aws-cdk/aws-lambda": "0.0.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-rds/lib/instance-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,8 @@ export class PostgresEngineVersion {
public static readonly VER_11_14 = PostgresEngineVersion.of('11.14', '11', { s3Import: true, s3Export: true });
/** Version "11.15". */
public static readonly VER_11_15 = PostgresEngineVersion.of('11.15', '11', { s3Import: true, s3Export: true });
/** Version "11.16". */
public static readonly VER_11_16 = PostgresEngineVersion.of('11.16', '11', { s3Import: true, s3Export: true });

/** Version "12" (only a major version, without a specific minor version). */
public static readonly VER_12 = PostgresEngineVersion.of('12', '12', { s3Import: true });
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RE

----------------

** aws-sdk@2.1215.0 - https://www.npmjs.com/package/aws-sdk/v/2.1215.0 | Apache-2.0
** aws-sdk@2.1220.0 - https://www.npmjs.com/package/aws-sdk/v/2.1220.0 | Apache-2.0
AWS SDK for JavaScript
Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Expand Down
20 changes: 19 additions & 1 deletion packages/@aws-cdk/integ-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ There are two main scenarios in which assertions are created.
- Part of an integration test using `integ-runner`

In this case you would create an integration test using the `IntegTest` construct and then make assertions using the `assert` property.
You should **not** utilize the assertion constructs directly, but should instead use the `methods` on `IntegTest.assert`.
You should **not** utilize the assertion constructs directly, but should instead use the `methods` on `IntegTest.assertions`.

```ts
declare const app: App;
Expand Down Expand Up @@ -410,3 +410,21 @@ describe.expect(ExpectedResult.objectLike({
}));
```

#### Chain ApiCalls

Sometimes it may be necessary to chain API Calls. Since each API call is its own resource, all you
need to do is add a dependency between the calls. There is an helper method `next` that can be used.

```ts
declare const integ: IntegTest;

integ.assertions.awsApiCall('S3', 'putObject', {
Bucket: 'my-bucket',
Key: 'my-key',
Body: 'helloWorld',
}).next(integ.assertions.awsApiCall('S3', 'getObject', {
Bucket: 'my-bucket',
Key: 'my-key',
}));
```

Loading

0 comments on commit fb6211f

Please sign in to comment.