Skip to content

Commit

Permalink
Merge branch 'master' into pr/eks-k8s-network-config
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Oct 17, 2021
2 parents 41c9619 + b6cb382 commit e7fae33
Show file tree
Hide file tree
Showing 69 changed files with 1,818 additions and 545 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ yarn-error.log
.nzm-*

/.versionrc.json
RELEASE_NOTES.md
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@

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.128.0](https://github.com/aws/aws-cdk/compare/v1.127.0...v1.128.0) (2021-10-14)


### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES

* **assertions:** Starting this release, the `assertions` module will be
published to Maven with the name 'assertions' instead of
'cdk-assertions'.

### Features

* **apigatewayv2-integrations:** http api - support for request parameter mapping ([#15630](https://github.com/aws/aws-cdk/issues/15630)) ([0452aed](https://github.com/aws/aws-cdk/commit/0452aed2f00198e05bd65b1d20246f7de0b24e20))
* **cli:** hotswap deployments for ECS Services ([#16864](https://github.com/aws/aws-cdk/issues/16864)) ([ad7288f](https://github.com/aws/aws-cdk/commit/ad7288f35a17fcfbecd7080e99ece4873fa99ad2))
* **codepipeline:** add support for string user parameters to the Lambda invoke action ([#16946](https://github.com/aws/aws-cdk/issues/16946)) ([e19ea31](https://github.com/aws/aws-cdk/commit/e19ea31dbf62446edaf5131c75246098ab05da6e)), closes [#16776](https://github.com/aws/aws-cdk/issues/16776)
* **lambda:** docker platform for architecture ([#16858](https://github.com/aws/aws-cdk/issues/16858)) ([5c258a3](https://github.com/aws/aws-cdk/commit/5c258a30367a4922e404eb26e5aa076720846fbe))
* **lambda-event-sources:** self managed kafka: support sasl/plain authentication ([#16712](https://github.com/aws/aws-cdk/issues/16712)) ([d4ad93f](https://github.com/aws/aws-cdk/commit/d4ad93f30877b26b851caa81d3a4a1d80df55164))
* **stepfunctions-tasks:** AWS SDK service integrations ([#16746](https://github.com/aws/aws-cdk/issues/16746)) ([ae840ff](https://github.com/aws/aws-cdk/commit/ae840ff1abb8283a1290dae5859f5729a9cf72b1)), closes [#16780](https://github.com/aws/aws-cdk/issues/16780)


### Bug Fixes

* **ecs:** add ASG capacity via Capacity Provider by not specifying machineImageType ([#16361](https://github.com/aws/aws-cdk/issues/16361)) ([93b3fdc](https://github.com/aws/aws-cdk/commit/93b3fdce80f0997d7b809f9ef7e3edd1e75e1f42)), closes [#16360](https://github.com/aws/aws-cdk/issues/16360)
* **servicecatalog:** Allow users to create multiple product versions from assets. ([#16914](https://github.com/aws/aws-cdk/issues/16914)) ([958d755](https://github.com/aws/aws-cdk/commit/958d755ff7acaf016e3f8969bf5ab07d4dc2977b))
* **codebuild:** add build image AMAZON_LINUX_2_ARM_2 ([#16931](https://github.com/aws/aws-cdk/issues/16931)) ([370cb31](https://github.com/aws/aws-cdk/commit/370cb310cce3fccc5381d8d53130e21b266de868)), closes [#16930](https://github.com/aws/aws-cdk/issues/16930)
* **core:** asset hash is different between linux and windows ([#16945](https://github.com/aws/aws-cdk/issues/16945)) ([59950dd](https://github.com/aws/aws-cdk/commit/59950dd331635fb707aac819529614c0f3e47ee5)), closes [#14555](https://github.com/aws/aws-cdk/issues/14555) [#16928](https://github.com/aws/aws-cdk/issues/16928)
* **ecs-patterns:** minScalingCapacity cannot be set to 0 ([#16961](https://github.com/aws/aws-cdk/issues/16961)) ([589f284](https://github.com/aws/aws-cdk/commit/589f284acec8530aa9824b75a5daef4632e98985)), closes [#15632](https://github.com/aws/aws-cdk/issues/15632) [#14336](https://github.com/aws/aws-cdk/issues/14336)
* **ssm:** StringParameter accepts ParameterType.AWS_EC2_IMAGE_ID as type ([#16884](https://github.com/aws/aws-cdk/issues/16884)) ([2b353be](https://github.com/aws/aws-cdk/commit/2b353be5291cbcdc56a8863038eed4a5f2adc65f)), closes [#16806](https://github.com/aws/aws-cdk/issues/16806)
* use registry.npmjs.com to fix shinkwrap resolves ([#16607](https://github.com/aws/aws-cdk/issues/16607)) ([8f91531](https://github.com/aws/aws-cdk/commit/8f91531c3c25900316d40d5564450566a03e27ee))


### Miscellaneous Chores

* **assertions:** consistent naming in maven ([#16921](https://github.com/aws/aws-cdk/issues/16921)) ([0dcd9ec](https://github.com/aws/aws-cdk/commit/0dcd9eca3a1014c39f92d9e052b67974fc751af0))

## [1.127.0](https://github.com/aws/aws-cdk/compare/v1.126.0...v1.127.0) (2021-10-08)


Expand Down
7 changes: 7 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,11 @@ if [ "$check_compat" == "true" ]; then
/bin/bash scripts/check-api-compatibility.sh
fi

# Create the release notes for the current version. These are ephemeral and not saved in source.
# Skip this step for a "bump candidate" build, where a new, fake version number has been created
# without any corresponding changelog entries.
if ! ${BUMP_CANDIDATE:-false}; then
node ./scripts/create-release-notes.js
fi

touch $BUILD_INDICATOR
35 changes: 35 additions & 0 deletions packages/@aws-cdk/aws-apigatewayv2-integrations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [Lambda Integration](#lambda)
- [HTTP Proxy Integration](#http-proxy)
- [Private Integration](#private-integration)
- [Request Parameters](#request-parameters)
- [WebSocket APIs](#websocket-apis)
- [Lambda WebSocket Integration](#lambda-websocket-integration)

Expand Down Expand Up @@ -149,6 +150,40 @@ const httpEndpoint = new HttpApi(stack, 'HttpProxyPrivateApi', {
});
```

### Request Parameters

Request parameter mapping allows API requests from clients to be modified before they reach backend integrations.
Parameter mapping can be used to specify modifications to request parameters. See [Transforming API requests and
responses](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-parameter-mapping.html).

The following example creates a new header - `header2` - as a copy of `header1` and removes `header1`.

```ts
const httpEndpoint = new HttpApi(stack, 'HttpProxyPrivateApi', {
defaultIntegration: new HttpAlbIntegration({
// ...
requestParameters: new ParameterMapping()
.appendHeader('header2', MappingValue.header('header1'))
.removeHeader('header1');
}),
}),
});
```

To add mapping keys and values not yet supported by the CDK, use the `custom()` method:

```ts
const httpEndpoint = new HttpApi(stack, 'HttpProxyPrivateApi', {
defaultIntegration: new HttpAlbIntegration({
listener,
requestParameters: new ParameterMapping()
.custom('myKey', 'myValue'),
}),
}),
});
```


## WebSocket APIs

WebSocket integrations connect a route to backend resources. The following integrations are supported in the CDK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class HttpAlbIntegration extends HttpPrivateIntegration {
connectionId: vpcLink.vpcLinkId,
uri: this.props.listener.listenerArn,
secureServerName: this.props.secureServerName,
parameterMapping: this.props.parameterMapping,
};
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpMethod, IVpcLink } from '@aws-cdk/aws-apigatewayv2';
import { HttpMethod, IVpcLink, ParameterMapping } from '@aws-cdk/aws-apigatewayv2';

/**
* Base options for private integration
Expand All @@ -24,4 +24,11 @@ export interface HttpPrivateIntegrationOptions {
*/

readonly secureServerName?: string;

/**
* Specifies how to transform HTTP requests before sending them to the backend
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-parameter-mapping.html
* @default undefined requests are sent to the backend unmodified
*/
readonly parameterMapping?: ParameterMapping;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
HttpRouteIntegrationConfig,
HttpMethod,
IHttpRouteIntegration,
ParameterMapping,
PayloadFormatVersion,
} from '@aws-cdk/aws-apigatewayv2';

Expand All @@ -21,6 +22,13 @@ export interface HttpProxyIntegrationProps {
* @default HttpMethod.ANY
*/
readonly method?: HttpMethod;

/**
* Specifies how to transform HTTP requests before sending them to the backend
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-parameter-mapping.html
* @default undefined requests are sent to the backend unmodified
*/
readonly parameterMapping?: ParameterMapping;
}

/**
Expand All @@ -36,6 +44,7 @@ export class HttpProxyIntegration implements IHttpRouteIntegration {
payloadFormatVersion: PayloadFormatVersion.VERSION_1_0, // 1.0 is required and is the only supported format
type: HttpIntegrationType.HTTP_PROXY,
uri: this.props.url,
parameterMapping: this.props.parameterMapping,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
HttpRouteIntegrationConfig,
IHttpRouteIntegration,
PayloadFormatVersion,
ParameterMapping,
} from '@aws-cdk/aws-apigatewayv2';
import { ServicePrincipal } from '@aws-cdk/aws-iam';
import { IFunction } from '@aws-cdk/aws-lambda';
Expand All @@ -24,6 +25,13 @@ export interface LambdaProxyIntegrationProps {
* @default PayloadFormatVersion.VERSION_2_0
*/
readonly payloadFormatVersion?: PayloadFormatVersion;

/**
* Specifies how to transform HTTP requests before sending them to the backend
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-parameter-mapping.html
* @default undefined requests are sent to the backend unmodified
*/
readonly parameterMapping?: ParameterMapping;
}

/**
Expand All @@ -50,6 +58,7 @@ export class LambdaProxyIntegration implements IHttpRouteIntegration {
type: HttpIntegrationType.LAMBDA_PROXY,
uri: this.props.handler.functionArn,
payloadFormatVersion: this.props.payloadFormatVersion ?? PayloadFormatVersion.VERSION_2_0,
parameterMapping: this.props.parameterMapping,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class HttpNlbIntegration extends HttpPrivateIntegration {
connectionId: vpcLink.vpcLinkId,
uri: this.props.listener.listenerArn,
secureServerName: this.props.secureServerName,
parameterMapping: this.props.parameterMapping,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class HttpServiceDiscoveryIntegration extends HttpPrivateIntegration {
connectionId: this.props.vpcLink.vpcLinkId,
uri: this.props.service.serviceArn,
secureServerName: this.props.secureServerName,
parameterMapping: this.props.parameterMapping,
};
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Template } from '@aws-cdk/assertions';
import { HttpApi, HttpMethod, HttpRoute, HttpRouteKey, VpcLink } from '@aws-cdk/aws-apigatewayv2';
import { HttpApi, HttpMethod, HttpRoute, HttpRouteKey, VpcLink, ParameterMapping, MappingValue } from '@aws-cdk/aws-apigatewayv2';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2';
import { Stack } from '@aws-cdk/core';
Expand Down Expand Up @@ -143,4 +143,34 @@ describe('HttpAlbIntegration', () => {
},
});
});

test('parameterMapping option is correctly recognized', () => {
// GIVEN
const stack = new Stack();
const vpc = new ec2.Vpc(stack, 'VPC');
const lb = new elbv2.ApplicationLoadBalancer(stack, 'lb', { vpc });
const listener = lb.addListener('listener', { port: 80 });
listener.addTargets('target', { port: 80 });

// WHEN
const api = new HttpApi(stack, 'HttpApi');
new HttpRoute(stack, 'HttpProxyPrivateRoute', {
httpApi: api,
integration: new HttpAlbIntegration({
listener,
parameterMapping: new ParameterMapping()
.appendHeader('header2', MappingValue.requestHeader('header1'))
.removeHeader('header1'),
}),
routeKey: HttpRouteKey.with('/pets'),
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Integration', {
RequestParameters: {
'append:header.header2': '$request.header.header1',
'remove:header.header1': '',
},
});
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Template } from '@aws-cdk/assertions';
import { HttpApi, HttpIntegration, HttpIntegrationType, HttpMethod, HttpRoute, HttpRouteKey, PayloadFormatVersion } from '@aws-cdk/aws-apigatewayv2';
import { HttpApi, HttpIntegration, HttpIntegrationType, HttpMethod, HttpRoute, HttpRouteKey, MappingValue, ParameterMapping, PayloadFormatVersion } from '@aws-cdk/aws-apigatewayv2';
import { Stack } from '@aws-cdk/core';
import { HttpProxyIntegration } from '../../lib';

Expand Down Expand Up @@ -71,4 +71,26 @@ describe('HttpProxyIntegration', () => {
IntegrationUri: 'some-target-url',
});
});

test('parameterMapping is correctly recognized', () => {
const stack = new Stack();
const api = new HttpApi(stack, 'HttpApi');
new HttpIntegration(stack, 'HttpInteg', {
httpApi: api,
integrationType: HttpIntegrationType.HTTP_PROXY,
integrationUri: 'some-target-url',
parameterMapping: new ParameterMapping()
.appendHeader('header2', MappingValue.requestHeader('header1'))
.removeHeader('header1'),
});

Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Integration', {
IntegrationType: 'HTTP_PROXY',
IntegrationUri: 'some-target-url',
RequestParameters: {
'append:header.header2': '$request.header.header1',
'remove:header.header1': '',
},
});
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Template } from '@aws-cdk/assertions';
import { HttpApi, HttpRoute, HttpRouteKey, PayloadFormatVersion } from '@aws-cdk/aws-apigatewayv2';
import { HttpApi, HttpRoute, HttpRouteKey, MappingValue, ParameterMapping, PayloadFormatVersion } from '@aws-cdk/aws-apigatewayv2';
import { Code, Function, Runtime } from '@aws-cdk/aws-lambda';
import { App, Stack } from '@aws-cdk/core';
import { LambdaProxyIntegration } from '../../lib';
Expand Down Expand Up @@ -41,6 +41,28 @@ describe('LambdaProxyIntegration', () => {
});
});

test('parameterMapping selection', () => {
const stack = new Stack();
const api = new HttpApi(stack, 'HttpApi');
new HttpRoute(stack, 'LambdaProxyRoute', {
httpApi: api,
integration: new LambdaProxyIntegration({
handler: fooFunction(stack, 'Fn'),
parameterMapping: new ParameterMapping()
.appendHeader('header2', MappingValue.requestHeader('header1'))
.removeHeader('header1'),
}),
routeKey: HttpRouteKey.with('/pets'),
});

Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Integration', {
RequestParameters: {
'append:header.header2': '$request.header.header1',
'remove:header.header1': '',
},
});
});

test('no dependency cycles', () => {
const app = new App();
const lambdaStack = new Stack(app, 'lambdaStack');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Template } from '@aws-cdk/assertions';
import { HttpApi, HttpMethod, HttpRoute, HttpRouteKey, VpcLink } from '@aws-cdk/aws-apigatewayv2';
import { HttpApi, HttpMethod, HttpRoute, HttpRouteKey, MappingValue, ParameterMapping, VpcLink } from '@aws-cdk/aws-apigatewayv2';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2';
import { Stack } from '@aws-cdk/core';
Expand Down Expand Up @@ -140,4 +140,34 @@ describe('HttpNlbIntegration', () => {
},
});
});

test('paramaterMapping option is correctly recognized', () => {
// GIVEN
const stack = new Stack();
const vpc = new ec2.Vpc(stack, 'VPC');
const lb = new elbv2.NetworkLoadBalancer(stack, 'lb', { vpc });
const listener = lb.addListener('listener', { port: 80 });
listener.addTargets('target', { port: 80 });

// WHEN
const api = new HttpApi(stack, 'HttpApi');
new HttpRoute(stack, 'HttpProxyPrivateRoute', {
httpApi: api,
integration: new HttpNlbIntegration({
listener,
parameterMapping: new ParameterMapping()
.appendHeader('header2', MappingValue.requestHeader('header1'))
.removeHeader('header1'),
}),
routeKey: HttpRouteKey.with('/pets'),
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Integration', {
RequestParameters: {
'append:header.header2': '$request.header.header1',
'remove:header.header1': '',
},
});
});
});
Loading

0 comments on commit e7fae33

Please sign in to comment.