Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jan 13, 2022
2 parents 4d2dcbd + b6e3e51 commit c6cc384
Show file tree
Hide file tree
Showing 373 changed files with 5,642 additions and 1,848 deletions.
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,52 @@

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.139.0](https://github.com/aws/aws-cdk/compare/v1.138.2...v1.139.0) (2022-01-11)


### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES

* **apigatewayv2-authorizers:** `WebSocketLambdaAuthorizerProps.identitySource` default changes from `['$request.header.Authorization']` to `['route.request.header.Authorization']`.
* **cfn2ts:** some "complex" property types within the generated
CloudFormation interfaces (i.e: properties of `Cfn*` constructs) with
names starting with a capital letter `I` followed by another capital
letter are no longer incorrectly treated as behavioral interfaces, and
might hence have different usage patterns in non-TypeScript languages.
Such interfaces were previously very difficult to use in non-TypeScript
languages, and required convoluted workarounds, which can now be removed.

### Features

* **aws-ecs:** support runtime platform property for create fargate windows runtime. ([#17622](https://github.com/aws/aws-cdk/issues/17622)) ([fa8f2e2](https://github.com/aws/aws-cdk/commit/fa8f2e2180d60e5621d2ae9606a3d1b2dcb681d9)), closes [#17242](https://github.com/aws/aws-cdk/issues/17242)
* **bootstrap:** ECR `ScanOnPush` is now enabled by default ([#17994](https://github.com/aws/aws-cdk/issues/17994)) ([7588b51](https://github.com/aws/aws-cdk/commit/7588b517eb17bb5198f91056113eb79a34830867))
* **cfnspec:** cloudformation spec v51.0.0 ([#18274](https://github.com/aws/aws-cdk/issues/18274)) ([c208e60](https://github.com/aws/aws-cdk/commit/c208e6043e4a184b4d3ac2508ebef1cb31bace43))
* **cli:** diff now uses the lookup Role for new-style synthesis ([#18277](https://github.com/aws/aws-cdk/issues/18277)) ([2256680](https://github.com/aws/aws-cdk/commit/225668050caef9bfdaa25b8ae984d3886108397f))
* **eks:** cluster tagging ([#4995](https://github.com/aws/aws-cdk/issues/4995)) ([#18109](https://github.com/aws/aws-cdk/issues/18109)) ([304f5b6](https://github.com/aws/aws-cdk/commit/304f5b6974f1121a8a5ff802076dffe2eff9f407))
* **iam:** generate AccessKeys ([#18180](https://github.com/aws/aws-cdk/issues/18180)) ([beb5706](https://github.com/aws/aws-cdk/commit/beb5706e0c80300c8adba2b75b573f6c6def3de6)), closes [#8432](https://github.com/aws/aws-cdk/issues/8432)
* **lambda-event-sources:** adds `AuthenticationMethod.CLIENT_CERTIFICATE_TLS_AUTH` to kafka ([#17920](https://github.com/aws/aws-cdk/issues/17920)) ([93cd776](https://github.com/aws/aws-cdk/commit/93cd7769b7b68ab6985c357c4d2f2137bb631553))
* **pipelines:** step dependencies ([#18256](https://github.com/aws/aws-cdk/issues/18256)) ([e3359e0](https://github.com/aws/aws-cdk/commit/e3359e0b79a8b999ed32c93fdbd19625bbbefaf8)), closes [#17945](https://github.com/aws/aws-cdk/issues/17945)
* **pipelines:** support timeout in CodeBuildStep ([#17351](https://github.com/aws/aws-cdk/issues/17351)) ([2aa3b8e](https://github.com/aws/aws-cdk/commit/2aa3b8e6e3ce75aaa7d4158f55e162eb26050ba1))
* **s3:** add EventBridge bucket notifications ([#18150](https://github.com/aws/aws-cdk/issues/18150)) ([912aeda](https://github.com/aws/aws-cdk/commit/912aeda295820920ed880b9c85a98c56421647b8)), closes [#18076](https://github.com/aws/aws-cdk/issues/18076)
* **sqs:** add DLQ readonly property to Queue ([#18232](https://github.com/aws/aws-cdk/issues/18232)) ([caa6788](https://github.com/aws/aws-cdk/commit/caa6788781690c629226a54bb1f9529722d67887)), closes [#18083](https://github.com/aws/aws-cdk/issues/18083)


### Bug Fixes

* **apigatewayv2-authorizers:** incorrect `identitySource` default for `WebSocketLambdaAuthorizer` ([#18315](https://github.com/aws/aws-cdk/issues/18315)) ([74eee1e](https://github.com/aws/aws-cdk/commit/74eee1e5b8fa404dde129f001b986d615f435c73)), closes [#18307](https://github.com/aws/aws-cdk/issues/18307)
* **appmesh:** allow a Virtual Node have as a backend a Virtual Service whose provider is that Node ([#18265](https://github.com/aws/aws-cdk/issues/18265)) ([272b6b1](https://github.com/aws/aws-cdk/commit/272b6b1abe22b7415eed5cdba82056d154fc31d7)), closes [#17322](https://github.com/aws/aws-cdk/issues/17322)
* **aws-kinesis:** remove default shard count when stream mode is on-demand and set default mode to provisioned ([#18221](https://github.com/aws/aws-cdk/issues/18221)) ([cac11bb](https://github.com/aws/aws-cdk/commit/cac11bba2ea0714dec8e23b069496d1b9d940685)), closes [#18139](https://github.com/aws/aws-cdk/issues/18139)
* **aws-lambda-event-sources:** unsupported properties for SelfManagedKafkaEventSource and ManagedKafkaEventSource ([#17965](https://github.com/aws/aws-cdk/issues/17965)) ([5ddaef4](https://github.com/aws/aws-cdk/commit/5ddaef491d7962616f75f170cf7547cd9229338f)), closes [#17934](https://github.com/aws/aws-cdk/issues/17934)
* **cfn2ts:** some property times have behavioral-interface names ([#18275](https://github.com/aws/aws-cdk/issues/18275)) ([6359c12](https://github.com/aws/aws-cdk/commit/6359c12e3242e23d9b3bf0a42cac7c361c8d4d8a))
* **cli:** assets are KMS-encrypted using wrong key ([#18340](https://github.com/aws/aws-cdk/issues/18340)) ([64ae9f3](https://github.com/aws/aws-cdk/commit/64ae9f3dc8a169ad0a7a2d02cb04f857debd3653)), closes [#17668](https://github.com/aws/aws-cdk/issues/17668) [#18262](https://github.com/aws/aws-cdk/issues/18262)
* **cli:** breaks due to faulty version of `colors` ([#18324](https://github.com/aws/aws-cdk/issues/18324)) ([ddc2bc6](https://github.com/aws/aws-cdk/commit/ddc2bc6ae64fe14ddb4a03122c90dfcf954f149f))
* **codebuild:** setting Cache.none() renders nothing in the template ([#18194](https://github.com/aws/aws-cdk/issues/18194)) ([cd51a5d](https://github.com/aws/aws-cdk/commit/cd51a5dae1780e34aecd90d85783fb6d3c239903)), closes [#18165](https://github.com/aws/aws-cdk/issues/18165)
* **lambda:** imported Function still has region and account from its Stack, instead of its ARN ([#18255](https://github.com/aws/aws-cdk/issues/18255)) ([01bbe4c](https://github.com/aws/aws-cdk/commit/01bbe4ca6c38ca7fe2239f8885bbec5ab537c9ad)), closes [#18228](https://github.com/aws/aws-cdk/issues/18228)
* **lambda-python:** asset files are generated inside the 'asset-input' folder ([#18306](https://github.com/aws/aws-cdk/issues/18306)) ([aff607a](https://github.com/aws/aws-cdk/commit/aff607a65e061ade5c3ec9e29f82fdaa8b57f638))
* **lambda-python:** bundle asset files correctly ([#18335](https://github.com/aws/aws-cdk/issues/18335)) ([3822c85](https://github.com/aws/aws-cdk/commit/3822c855cf92ee0cd4539dee33e55f57d995bf89)), closes [#18301](https://github.com/aws/aws-cdk/issues/18301)
* **logs:** respect region when importing log group ([#18215](https://github.com/aws/aws-cdk/issues/18215)) ([be909bc](https://github.com/aws/aws-cdk/commit/be909bc90822db947ec0a932621709d0cb07e50e)), closes [#18214](https://github.com/aws/aws-cdk/issues/18214)
* **pipelines:** `DockerCredential.dockerHub()` silently fails auth ([#18313](https://github.com/aws/aws-cdk/issues/18313)) ([c2c87d9](https://github.com/aws/aws-cdk/commit/c2c87d9dd861a25dcbd9aa830e81ecb4d76ba509)), closes [#15737](https://github.com/aws/aws-cdk/issues/15737)
* **route53:** support multiple cross account DNS delegations ([#17837](https://github.com/aws/aws-cdk/issues/17837)) ([76b5c0d](https://github.com/aws/aws-cdk/commit/76b5c0d12e1e692efcf6a557ee4ddb6df3709e4d)), closes [#17836](https://github.com/aws/aws-cdk/issues/17836)

## [1.138.2](https://github.com/aws/aws-cdk/compare/v1.138.1...v1.138.2) (2022-01-09)


Expand Down
2 changes: 2 additions & 0 deletions buildspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ phases:
- /bin/bash ./scripts/transform.sh
post_build:
commands:
# Short-circuit: Don't run pack if the above build failed.
- '[ ${CODEBUILD_BUILD_SUCCEEDING:-0} -eq 1 ] || exit 1'
- "[ -f .BUILD_COMPLETED ] && /bin/bash ./pack.sh"
- /bin/bash ./scripts/cache-store.sh
artifacts:
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
},
"devDependencies": {
"@yarnpkg/lockfile": "^1.1.0",
"cdk-generate-synthetic-examples": "^0.1.1",
"cdk-generate-synthetic-examples": "^0.1.2",
"conventional-changelog-cli": "^2.2.2",
"fs-extra": "^9.1.0",
"graceful-fs": "^4.2.8",
"graceful-fs": "^4.2.9",
"jest-junit": "^13.0.0",
"jsii-diff": "^1.50.0",
"jsii-pacmak": "^1.50.0",
"jsii-reflect": "^1.50.0",
"jsii-rosetta": "^1.50.0",
"jsii-diff": "^1.52.1",
"jsii-pacmak": "^1.52.1",
"jsii-reflect": "^1.52.1",
"jsii-rosetta": "^1.52.1",
"lerna": "^4.0.0",
"patch-package": "^6.4.7",
"standard-version": "^9.3.2",
Expand Down Expand Up @@ -123,8 +123,8 @@
"aws-cdk-lib/@balena/dockerignore/**",
"aws-cdk-lib/case",
"aws-cdk-lib/case/**",
"aws-cdk-lib/colors",
"aws-cdk-lib/colors/**",
"aws-cdk-lib/chalk",
"aws-cdk-lib/chalk/**",
"aws-cdk-lib/diff",
"aws-cdk-lib/diff/**",
"aws-cdk-lib/fast-deep-equal",
Expand All @@ -151,8 +151,8 @@
"monocdk/@balena/dockerignore/**",
"monocdk/case",
"monocdk/case/**",
"monocdk/colors",
"monocdk/colors/**",
"monocdk/chalk",
"monocdk/chalk/**",
"monocdk/diff",
"monocdk/diff/**",
"monocdk/fast-deep-equal",
Expand Down Expand Up @@ -180,4 +180,4 @@
"dependencies": {
"string-width": "^4.2.3"
}
}
}
38 changes: 37 additions & 1 deletion packages/@aws-cdk-containers/ecs-service-extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,43 @@ nameDescription.add(new Container({
Every `ServiceDescription` requires at minimum that you add a `Container` extension
which defines the main application (essential) container to run for the service.

After that, you can optionally enable additional features for the service using the `ServiceDescription.add()` method:
### Logging using `awslogs` log driver

If no observability extensions have been configured for a service, the ECS Service Extensions configures an `awslogs` log driver for the application container of the service to send the container logs to CloudWatch Logs.

You can either provide a log group to the `Container` extension or one will be created for you by the CDK.

Following is an example of an application with an `awslogs` log driver configured for the application container:

```ts
const environment = new Environment(stack, 'production');

const nameDescription = new ServiceDescription();
nameDescription.add(new Container({
cpu: 1024,
memoryMiB: 2048,
trafficPort: 80,
image: ContainerImage.fromRegistry('nathanpeck/name'),
environment: {
PORT: '80',
},
logGroup: new awslogs.LogGroup(stack, 'MyLogGroup'),
}));
```

If a log group is not provided, no observability extensions have been created, and the `ECS_SERVICE_EXTENSIONS_ENABLE_DEFAULT_LOG_DRIVER` feature flag is enabled, then logging will be configured by default and a log group will be created for you.

The `ECS_SERVICE_EXTENSIONS_ENABLE_DEFAULT_LOG_DRIVER` feature flag is enabled by default in any CDK apps that are created with CDK v1.140.0 or v2.8.0 and later.

To enable default logging for previous versions, ensure that the `ECS_SERVICE_EXTENSIONS_ENABLE_DEFAULT_LOG_DRIVER` flag within the application stack context is set to true, like so:

```ts
stack.node.setContext(cxapi.ECS_SERVICE_EXTENSIONS_ENABLE_DEFAULT_LOG_DRIVER, true);
```

Alternatively, you can also set the feature flag in the `cdk.json` file. For more information, refer the [docs](https://docs.aws.amazon.com/cdk/v2/guide/featureflags.html).

After adding the `Container` extension, you can optionally enable additional features for the service using the `ServiceDescription.add()` method:

```ts
nameDescription.add(new AppMeshExtension({ mesh }));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import * as ecs from '@aws-cdk/aws-ecs';
import * as awslogs from '@aws-cdk/aws-logs';
import * as cdk from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';
import { Service } from '../service';
import { ServiceExtension } from './extension-interfaces';

Expand Down Expand Up @@ -38,6 +41,13 @@ export interface ContainerExtensionProps {
readonly environment?: {
[key: string]: string,
}

/**
* The log group into which application container logs should be routed.
*
* @default - A log group is automatically created for you if the `ECS_SERVICE_EXTENSIONS_ENABLE_DEFAULT_LOG_DRIVER` feature flag is set.
*/
readonly logGroup?: awslogs.ILogGroup;
}

/**
Expand All @@ -51,6 +61,11 @@ export class Container extends ServiceExtension {
*/
public readonly trafficPort: number;

/**
* The log group into which application container logs should be routed.
*/
public logGroup?: awslogs.ILogGroup;

/**
* The settings for the container.
*/
Expand All @@ -60,11 +75,12 @@ export class Container extends ServiceExtension {
super('service-container');
this.props = props;
this.trafficPort = props.trafficPort;
this.logGroup = props.logGroup;
}

// @ts-ignore - Ignore unused params that are required for abstract class extend
public prehook(service: Service, scope: Construct) {
this.parentService = service;
this.scope = scope;
}

// This hook sets the overall task resource requirements to the
Expand Down Expand Up @@ -93,6 +109,31 @@ export class Container extends ServiceExtension {
containerProps = hookProvider.mutateContainerDefinition(containerProps);
});

// If no observability extensions have been added to the service description then we can configure the `awslogs` log driver
if (!containerProps.logging) {
// Create a log group for the service if one is not provided by the user (only if feature flag is set)
if (!this.logGroup && this.parentService.node.tryGetContext(cxapi.ECS_SERVICE_EXTENSIONS_ENABLE_DEFAULT_LOG_DRIVER)) {
this.logGroup = new awslogs.LogGroup(this.scope, `${this.parentService.id}-logs`, {
logGroupName: `${this.parentService.id}-logs`,
removalPolicy: cdk.RemovalPolicy.DESTROY,
retention: awslogs.RetentionDays.ONE_MONTH,
});
}

if (this.logGroup) {
containerProps = {
...containerProps,
logging: new ecs.AwsLogDriver({
streamPrefix: this.parentService.id,
logGroup: this.logGroup,
}),
};
}
} else {
if (this.logGroup) {
throw Error(`Log configuration already specified. You cannot provide a log group for the application container of service '${this.parentService.id}' while also adding log configuration separately using service extensions.`);
}
}
this.container = taskDefinition.addContainer('app', containerProps);

// Create a port mapping for the container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ import * as ecs from '@aws-cdk/aws-ecs';
import * as cdk from '@aws-cdk/core';
import { ServiceExtension, ServiceBuild } from './extension-interfaces';


/**
* The autoscaling settings.
*
* @deprecated use the `minTaskCount` and `maxTaskCount` properties of `autoScaleTaskCount` in the `Service` construct
* to configure the auto scaling target for the service. For more information, please refer
* https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk-containers/ecs-service-extensions/README.md#task-auto-scaling .
*/
export interface CpuScalingProps {
/**
Expand Down Expand Up @@ -61,6 +66,9 @@ const cpuScalingPropsDefault = {

/**
* This extension helps you scale your service according to CPU utilization.
*
* @deprecated To enable target tracking based on CPU utilization, use the `targetCpuUtilization` property of `autoScaleTaskCount` in the `Service` construct.
* For more information, please refer https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk-containers/ecs-service-extensions/README.md#task-auto-scaling .
*/
export class ScaleOnCpuUtilization extends ServiceExtension {
/**
Expand Down Expand Up @@ -126,6 +134,9 @@ export class ScaleOnCpuUtilization extends ServiceExtension {
// This hook utilizes the resulting service construct
// once it is created.
public useService(service: ecs.Ec2Service | ecs.FargateService) {
if (this.parentService.scalableTaskCount) {
throw Error('Cannot specify \'autoScaleTaskCount\' in the Service construct and also provide a \'ScaleOnCpuUtilization\' extension. \'ScaleOnCpuUtilization\' is deprecated. Please only provide \'autoScaleTaskCount\'.');
}
const scalingTarget = service.autoScaleTaskCount({
minCapacity: this.minTaskCount,
maxCapacity: this.maxTaskCount,
Expand All @@ -136,5 +147,6 @@ export class ScaleOnCpuUtilization extends ServiceExtension {
scaleInCooldown: this.scaleInCooldown,
scaleOutCooldown: this.scaleOutCooldown,
});
this.parentService.enableAutoScalingPolicy();
}
}
28 changes: 17 additions & 11 deletions packages/@aws-cdk-containers/ecs-service-extensions/lib/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export interface ServiceProps {

/**
* The options for configuring the auto scaling target.
*
* @default none
*/
readonly autoScaleTaskCount?: AutoScalingOptions;
}
Expand Down Expand Up @@ -196,7 +198,6 @@ export class Service extends Construct {
// Ensure that the task definition supports both EC2 and Fargate
compatibility: ecs.Compatibility.EC2_AND_FARGATE,
} as ecs.TaskDefinitionProps;

for (const extensions in this.serviceDescription.extensions) {
if (this.serviceDescription.extensions[extensions]) {
taskDefProps = this.serviceDescription.extensions[extensions].modifyTaskDefinitionProps(taskDefProps);
Expand All @@ -221,17 +222,14 @@ export class Service extends Construct {
}
}

// Set desiredCount to `undefined` if auto scaling is configured for the service
const desiredCount = props.autoScaleTaskCount ? undefined : (props.desiredCount || 1);

// Give each extension a chance to mutate the service props before
// service creation
let serviceProps = {
cluster: this.cluster,
taskDefinition: this.taskDefinition,
minHealthyPercent: 100,
maxHealthyPercent: 200,
desiredCount,
desiredCount: props.desiredCount ?? 1,
} as ServiceBuild;

for (const extensions in this.serviceDescription.extensions) {
Expand Down Expand Up @@ -273,6 +271,14 @@ export class Service extends Construct {
}
}

// Set desiredCount to `undefined` if auto scaling is configured for the service
if (props.autoScaleTaskCount || this.autoScalingPoliciesEnabled) {
serviceProps = {
...serviceProps,
desiredCount: undefined,
};
}

// Now that the service props are determined we can create
// the service
if (this.capacityType === EnvironmentCapacityType.EC2) {
Expand All @@ -291,17 +297,17 @@ export class Service extends Construct {
});

if (props.autoScaleTaskCount.targetCpuUtilization) {
const targetUtilizationPercent = props.autoScaleTaskCount.targetCpuUtilization;
this.scalableTaskCount.scaleOnCpuUtilization(`${this.id}-target-cpu-utilization-${targetUtilizationPercent}`, {
targetUtilizationPercent,
const targetCpuUtilizationPercent = props.autoScaleTaskCount.targetCpuUtilization;
this.scalableTaskCount.scaleOnCpuUtilization(`${this.id}-target-cpu-utilization-${targetCpuUtilizationPercent}`, {
targetUtilizationPercent: targetCpuUtilizationPercent,
});
this.enableAutoScalingPolicy();
}

if (props.autoScaleTaskCount.targetMemoryUtilization) {
const targetUtilizationPercent = props.autoScaleTaskCount.targetMemoryUtilization;
this.scalableTaskCount.scaleOnMemoryUtilization(`${this.id}-target-memory-utilization-${targetUtilizationPercent}`, {
targetUtilizationPercent,
const targetMemoryUtilizationPercent = props.autoScaleTaskCount.targetMemoryUtilization;
this.scalableTaskCount.scaleOnMemoryUtilization(`${this.id}-target-memory-utilization-${targetMemoryUtilizationPercent}`, {
targetUtilizationPercent: targetMemoryUtilizationPercent,
});
this.enableAutoScalingPolicy();
}
Expand Down
Loading

0 comments on commit c6cc384

Please sign in to comment.