Skip to content

Commit

Permalink
chore(release): 1.122.0 (#16416)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Sep 8, 2021
2 parents 026cb8f + e00abff commit ae09c16
Show file tree
Hide file tree
Showing 223 changed files with 9,684 additions and 6,006 deletions.
30 changes: 30 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,36 @@

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.122.0](https://github.com/aws/aws-cdk/compare/v1.121.0...v1.122.0) (2021-09-08)


### Features

* **ec2:** Allow ApplyCloudformationInitOptions to set additional params ([#16121](https://github.com/aws/aws-cdk/issues/16121)) ([1d94646](https://github.com/aws/aws-cdk/commit/1d94646bd50cbbbc1ace3732a7b8ebb313ed3ddf)), closes [#16004](https://github.com/aws/aws-cdk/issues/16004)
* **backup:** option to prevent recovery point deletions ([#16282](https://github.com/aws/aws-cdk/issues/16282)) ([6e71806](https://github.com/aws/aws-cdk/commit/6e718067b6c4e1a2c905fedcc60a6863ba3add12))
* **cli:** hotswap deployments ([#15748](https://github.com/aws/aws-cdk/issues/15748)) ([6e55c95](https://github.com/aws/aws-cdk/commit/6e55c952d683f87bb815deb29124b9a37824749a))
* **config:** EC2_INSTANCE_PROFILE_ATTACHED managed rule ([#16011](https://github.com/aws/aws-cdk/issues/16011)) ([816a319](https://github.com/aws/aws-cdk/commit/816a31984b5c6e08c4c7dd740919e0c1f5d0e196))
* **ec2:** rename SubnetTypes to improve clarity with EC2 conventions ([#16348](https://github.com/aws/aws-cdk/issues/16348)) ([2023004](https://github.com/aws/aws-cdk/commit/2023004cc941a0e7a908bf3c90ad9887c6679564)), closes [#15929](https://github.com/aws/aws-cdk/issues/15929)
* **ec2:** vpc endpoint for aws keyspaces ([#16306](https://github.com/aws/aws-cdk/issues/16306)) ([ad425d0](https://github.com/aws/aws-cdk/commit/ad425d004dd9154c367622733e2a2e36a38f1cef))
* **ecs-service-extensions:** Subscribe Extension ([#16049](https://github.com/aws/aws-cdk/issues/16049)) ([66baca5](https://github.com/aws/aws-cdk/commit/66baca58adc294d5c5924cf8f8c5fa122c6d6dfc))
* **elasticloadbalancingv2:** ALPN policy support for NLB listener ([#15956](https://github.com/aws/aws-cdk/issues/15956)) ([5427578](https://github.com/aws/aws-cdk/commit/5427578515c0b65d172f95c27f32f1933fcf8d60))
* **kms:** support fromLookup in KMS key to get key by alias name ([#15652](https://github.com/aws/aws-cdk/issues/15652)) ([34a57ed](https://github.com/aws/aws-cdk/commit/34a57eda01ab816cd77f260b10ca466a749586bf)), closes [#8822](https://github.com/aws/aws-cdk/issues/8822)
* **lambda:** python 3.9 runtime ([#16366](https://github.com/aws/aws-cdk/issues/16366)) ([a534829](https://github.com/aws/aws-cdk/commit/a534829b2458c5ed54d05fd5cca025cba2ddaaa7))
* **pipelines:** stack-level steps ([#16215](https://github.com/aws/aws-cdk/issues/16215)) ([d499c85](https://github.com/aws/aws-cdk/commit/d499c85e4c09cc00b457ca7f2f4611a925ca8aeb)), closes [#16148](https://github.com/aws/aws-cdk/issues/16148)
* **stepfunctions-tasks:** await the eval so async ops can be passed to tasks.EvaluateExpression ([#16290](https://github.com/aws/aws-cdk/issues/16290)) ([174b066](https://github.com/aws/aws-cdk/commit/174b066634755c76d1b78d05ca9b403145dedc47))


### Bug Fixes

* **apigatewayv2:** some methods of the `defaultStage` are not available without casting it to `IHttpStage` ([#15607](https://github.com/aws/aws-cdk/issues/15607)) ([27a0113](https://github.com/aws/aws-cdk/commit/27a0113ac68a05360faa22fa8897609f2f90b764))
* **assets:** run executable command of container assets in cloud assembly root directory ([#16094](https://github.com/aws/aws-cdk/issues/16094)) ([c2852c9](https://github.com/aws/aws-cdk/commit/c2852c9c524a639a312bf296f7f23b0e3b112f6b)), closes [#15721](https://github.com/aws/aws-cdk/issues/15721)
* **autoscaling:** EbsDeviceVolumeType.IO2 is not a valid CloudFormation value ([#16028](https://github.com/aws/aws-cdk/issues/16028)) ([492d33b](https://github.com/aws/aws-cdk/commit/492d33b27bc5b935e3da75f0bddd875bb6f9c15d)), closes [#16027](https://github.com/aws/aws-cdk/issues/16027)
* **cli:** 'deploy' and 'diff' silently does nothing when given unknown stack name ([#16150](https://github.com/aws/aws-cdk/issues/16150)) ([74776f3](https://github.com/aws/aws-cdk/commit/74776f393462f7e7d23cb1953ef786a823adc896)), closes [#15866](https://github.com/aws/aws-cdk/issues/15866)
* **cloudwatch:** cross account alarms does not support math expressions ([#16333](https://github.com/aws/aws-cdk/issues/16333)) ([1ffd897](https://github.com/aws/aws-cdk/commit/1ffd89714f8b1c1389d4e43383cc77d16d00ed9e)), closes [#16331](https://github.com/aws/aws-cdk/issues/16331)
* **core:** allow asset bundling when selinux is enabled ([#15742](https://github.com/aws/aws-cdk/issues/15742)) ([dbfebb4](https://github.com/aws/aws-cdk/commit/dbfebb47a8ae61b2bb0557b6ba79a7b073f9d0df))
* **iam:** permissions boundary aspect doesn't always recognize roles ([#16154](https://github.com/aws/aws-cdk/issues/16154)) ([c8bfcf6](https://github.com/aws/aws-cdk/commit/c8bfcf650070a0138b148645f997f542431f70cf))
* **stepfunctions-tasks:** Athena StartQueryExecution includes QueryExecutionContext even when object is empty ([#16141](https://github.com/aws/aws-cdk/issues/16141)) ([6e2a3e0](https://github.com/aws/aws-cdk/commit/6e2a3e0f855221df98f78f6465586d5524f5c7d5)), closes [#16133](https://github.com/aws/aws-cdk/issues/16133) [#16133](https://github.com/aws/aws-cdk/issues/16133)

## [1.121.0](https://github.com/aws/aws-cdk/compare/v1.120.0...v1.121.0) (2021-09-01)


Expand Down
4 changes: 4 additions & 0 deletions allowed-breaking-changes.txt
Expand Up @@ -74,3 +74,7 @@ removed:@aws-cdk/aws-stepfunctions-tasks.BatchSubmitJobProps.jobDefinition
strengthened:@aws-cdk/aws-stepfunctions-tasks.BatchSubmitJobProps
removed:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps.cluster
strengthened:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps

# Remove IO2 from autoscaling EbsDeviceVolumeType. This value is not supported
# at the moment and was not supported in the past.
removed:@aws-cdk/aws-autoscaling.EbsDeviceVolumeType.IO2
4 changes: 3 additions & 1 deletion buildspec-pr.yaml
Expand Up @@ -14,4 +14,6 @@ phases:
- yarn --version || npm -g install yarn
build:
commands:
- /bin/bash ./build.sh --extract && git diff-index --exit-code --ignore-space-at-eol --stat HEAD
- /bin/bash ./build.sh --extract
- /bin/bash ./scripts/transform.sh --extract
- git diff-index --exit-code --ignore-space-at-eol --stat HEAD
1 change: 1 addition & 0 deletions buildspec.yaml
Expand Up @@ -17,6 +17,7 @@ phases:
- 'if ${BUMP_CANDIDATE:-false}; then /bin/bash ./scripts/bump-candidate.sh; fi'
- /bin/bash ./scripts/align-version.sh
- /bin/bash ./build.sh
- /bin/bash ./scripts/transform.sh
post_build:
commands:
- "[ -f .BUILD_COMPLETED ] && /bin/bash ./pack.sh"
Expand Down
10 changes: 10 additions & 0 deletions package.json
Expand Up @@ -71,6 +71,16 @@
"nohoist": [
"**/jszip",
"**/jszip/**",
"@aws-cdk/assertions-alpha/colors",
"@aws-cdk/assertions-alpha/colors/**",
"@aws-cdk/assertions-alpha/diff",
"@aws-cdk/assertions-alpha/diff/**",
"@aws-cdk/assertions-alpha/fast-deep-equal",
"@aws-cdk/assertions-alpha/fast-deep-equal/**",
"@aws-cdk/assertions-alpha/string-width",
"@aws-cdk/assertions-alpha/string-width/**",
"@aws-cdk/assertions-alpha/table",
"@aws-cdk/assertions-alpha/table/**",
"@aws-cdk/assertions/colors",
"@aws-cdk/assertions/colors/**",
"@aws-cdk/assertions/diff",
Expand Down
35 changes: 35 additions & 0 deletions packages/@aws-cdk-containers/ecs-service-extensions/README.md
Expand Up @@ -19,6 +19,7 @@ The `Service` construct provided by this module can be extended with optional `S
- [AWS AppMesh](https://aws.amazon.com/app-mesh/) for adding your application to a service mesh
- [Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html), for exposing your service to the public
- [AWS FireLens](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_firelens.html), for filtering and routing application logs
- Queue to allow your service to consume messages from an SQS Queue which is populated by one or more SNS Topics that it is subscribed to
- [Community Extensions](#community-extensions), providing support for advanced use cases

The `ServiceExtension` class is an abstract class which you can also implement in
Expand Down Expand Up @@ -321,6 +322,40 @@ const environment = Environment.fromEnvironmentAttributes(stack, 'Environment',

```

## Queue Extension

This service extension creates a default SQS Queue `eventsQueue` for the service (if not provided) and accepts a list of `ISubscribable` objects that the `eventsQueue` can subscribe to. The service extension creates the subscriptions and sets up permissions for the service to consume messages from the SQS Queue.

### Setting up SNS Topic Subscriptions for SQS Queues

You can use this extension to set up SNS Topic subscriptions for the `eventsQueue`. To do this, create a new object of type `TopicSubscription` for every SNS Topic you want the `eventsQueue` to subscribe to and provide it as input to the service extension.

```ts
const myServiceDescription = nameDescription.add(new QueueExtension({
// Provide list of topic subscriptions that you want the `eventsQueue` to subscribe to
subscriptions: [new TopicSubscription({
topic: new sns.Topic(stack, 'my-topic'),
}],
}));

// To access the `eventsQueue` for the service, use the `eventsQueue` getter for the extension
const myQueueExtension = myServiceDescription.extensions.queue as QueueExtension;
const myEventsQueue = myQueueExtension.eventsQueue;
```
For setting up a topic-specific queue subscription, you can provide a custom queue in the `TopicSubscription` object along with the SNS Topic. The extension will set up a topic subscription for the provided queue instead of the default `eventsQueue` of the service.
```ts
nameDescription.add(new QueueExtension({
queue: myEventsQueue,
subscriptions: [new TopicSubscription({
topic: new sns.Topic(stack, 'my-topic'),
// `myTopicQueue` will subscribe to the `my-topic` instead of `eventsQueue`
queue: myTopicQueue,
}],
}));
```
## Community Extensions
We encourage the development of Community Service Extensions that support
Expand Down
Expand Up @@ -6,3 +6,4 @@ export * from './cloudwatch-agent';
export * from './scale-on-cpu-utilization';
export * from './xray';
export * from './assign-public-ip';
export * from './queue';
@@ -0,0 +1,212 @@
import * as ecs from '@aws-cdk/aws-ecs';
import * as sns from '@aws-cdk/aws-sns';
import * as subscription from '@aws-cdk/aws-sns-subscriptions';
import * as sqs from '@aws-cdk/aws-sqs';
import * as cdk from '@aws-cdk/core';
import { Service } from '../service';
import { Container } from './container';
import { ContainerMutatingHook, ServiceExtension } from './extension-interfaces';

// Keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* An interface that will be implemented by all the resources that can be subscribed to.
*/
export interface ISubscribable {
/**
* All classes implementing this interface must also implement the `subscribe()` method
*/
subscribe(extension: QueueExtension): sqs.IQueue;
}

/**
* The settings for the Queue extension.
*/
export interface QueueExtensionProps {
/**
* The list of subscriptions for this service.
*
* @default none
*/
readonly subscriptions?: ISubscribable[];

/**
* The user-provided default queue for this service.
*
* @default If the `eventsQueue` is not provided, a default SQS Queue is created for the service.
*/
readonly eventsQueue?: sqs.IQueue;
}

/**
* The topic-specific settings for creating the queue subscriptions.
*/
export interface TopicSubscriptionProps {
/**
* The SNS Topic to subscribe to.
*/
readonly topic: sns.ITopic;

/**
* The user-provided queue to subscribe to the given topic.
* If the `queue` is not provided, the default `eventsQueue` will subscribe to the given topic.
*
* @default none
*/
readonly queue?: sqs.IQueue;
}

/**
* The `TopicSubscription` class represents an SNS Topic resource that can be subscribed to by the service queues.
*/
export class TopicSubscription implements ISubscribable {
public readonly topic: sns.ITopic;

public readonly queue?: sqs.IQueue;

constructor(props: TopicSubscriptionProps) {
this.topic = props.topic;
this.queue = props.queue;
}

/**
* This method sets up SNS Topic subscriptions for the SQS queue provided by the user. If a `queue` is not provided,
* the default `eventsQueue` subscribes to the given topic.
*
* @param extension `QueueExtension` added to the service
* @returns the queue subscribed to the given topic
*/
public subscribe(extension: QueueExtension) : sqs.IQueue {
let queue = extension.eventsQueue;
if (this.queue) {
queue = this.queue;
}
this.topic.addSubscription(new subscription.SqsSubscription(queue));
return queue;
}
}

/**
* Settings for the hook which mutates the application container
* to add the events queue URI to its environment.
*/
interface ContainerMutatingProps {
/**
* The events queue name and URI to be added to the container environment.
*/
readonly environment: { [key: string]: string };
}

/**
* This hook modifies the application container's environment to
* add the queue URL for the events queue of the service.
*/
class QueueExtensionMutatingHook extends ContainerMutatingHook {
private environment: { [key: string]: string };

constructor(props: ContainerMutatingProps) {
super();
this.environment = props.environment;
}

public mutateContainerDefinition(props: ecs.ContainerDefinitionOptions): ecs.ContainerDefinitionOptions {
return {
...props,

environment: { ...(props.environment || {}), ...this.environment },
} as ecs.ContainerDefinitionOptions;
}
}

/**
* This extension creates a default `eventsQueue` for the service (if not provided) and accepts a list of objects of
* type `ISubscribable` that the `eventsQueue` subscribes to. It creates the subscriptions and sets up permissions
* for the service to consume messages from the SQS Queues.
*
* The default queue for this service can be accessed using the getter `<extension>.eventsQueue`.
*/
export class QueueExtension extends ServiceExtension {
private _eventsQueue!: sqs.IQueue;

private subscriptionQueues = new Set<sqs.IQueue>();

private environment: { [key: string]: string } = {};

private props?: QueueExtensionProps;

constructor(props?: QueueExtensionProps) {
super('queue');

this.props = props;
}

/**
* This hook creates (if required) and sets the default queue `eventsQueue`. It also sets up the subscriptions for
* the provided `ISubscribable` objects.
*
* @param service The parent service which this extension has been added to
* @param scope The scope that this extension should create resources in
*/
public prehook(service: Service, scope: Construct) {
this.parentService = service;
this.scope = scope;

let eventsQueue = this.props?.eventsQueue;
if (!eventsQueue) {
const deadLetterQueue = new sqs.Queue(this.scope, 'EventsDeadLetterQueue', {
retentionPeriod: cdk.Duration.days(14),
});

eventsQueue = new sqs.Queue(this.scope, 'EventsQueue', {
deadLetterQueue: {
queue: deadLetterQueue,
maxReceiveCount: 3,
},
});
}
this._eventsQueue = eventsQueue;

this.environment[`${this.parentService.id.toUpperCase()}_QUEUE_URI`] = this._eventsQueue.queueUrl;

if (this.props?.subscriptions) {
for (const subs of this.props.subscriptions) {
const subsQueue = subs.subscribe(this);
this.subscriptionQueues.add(subsQueue);
}
}
}

/**
* Add hooks to the main application extension so that it is modified to
* add the events queue URL to the container environment.
*/
public addHooks() {
const container = this.parentService.serviceDescription.get('service-container') as Container;

if (!container) {
throw new Error('Queue Extension requires an application extension');
}

container.addContainerMutatingHook(new QueueExtensionMutatingHook({
environment: this.environment,
}));
}

/**
* After the task definition has been created, this hook grants SQS permissions to the task role.
*
* @param taskDefinition The created task definition
*/
public useTaskDefinition(taskDefinition: ecs.TaskDefinition) {
this._eventsQueue.grantConsumeMessages(taskDefinition.taskRole);
for (const queue of this.subscriptionQueues) {
queue.grantConsumeMessages(taskDefinition.taskRole);
}
}

public get eventsQueue() : sqs.IQueue {
return this._eventsQueue;
}
}
Expand Up @@ -64,6 +64,8 @@
"@aws-cdk/aws-route53": "0.0.0",
"@aws-cdk/aws-route53-targets": "0.0.0",
"@aws-cdk/aws-servicediscovery": "0.0.0",
"@aws-cdk/aws-sns": "0.0.0",
"@aws-cdk/aws-sns-subscriptions": "0.0.0",
"@aws-cdk/aws-sqs": "0.0.0",
"@aws-cdk/core": "0.0.0",
"@aws-cdk/custom-resources": "0.0.0",
Expand All @@ -89,6 +91,8 @@
"@aws-cdk/aws-route53": "0.0.0",
"@aws-cdk/aws-route53-targets": "0.0.0",
"@aws-cdk/aws-servicediscovery": "0.0.0",
"@aws-cdk/aws-sns": "0.0.0",
"@aws-cdk/aws-sns-subscriptions": "0.0.0",
"@aws-cdk/aws-sqs": "0.0.0",
"@aws-cdk/core": "0.0.0",
"@aws-cdk/custom-resources": "0.0.0",
Expand Down

0 comments on commit ae09c16

Please sign in to comment.