Skip to content

Commit

Permalink
chore(release): 1.49.1 (#8871)
Browse files Browse the repository at this point in the history
See [CHANGELOG](https://github.com/aws/aws-cdk/blob/patch/v1.49.1/CHANGELOG.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mergify[bot] authored Jul 2, 2020
2 parents 99488f2 + d97fa6b commit 7d6321f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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.49.1](https://github.com/aws/aws-cdk/compare/v1.49.0...v1.49.1) (2020-07-02)

### Bug Fixes

* **apigateway:** Lambda integration for imported functions ([#8870](https://github.com/aws/aws-cdk/issues/8870)) ([c017f88](https://github.com/aws/aws-cdk/commit/c017f887770174437de3b772edf0034604890ac3)), closes [#8869](https://github.com/aws/aws-cdk/issues/8869)

## [1.49.0](https://github.com/aws/aws-cdk/compare/v1.48.0...v1.49.0) (2020-07-02)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"tools/*"
],
"rejectCycles": "true",
"version": "1.49.0"
"version": "1.49.1"
}
16 changes: 13 additions & 3 deletions packages/@aws-cdk/aws-apigateway/lib/integrations/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,20 @@ export class LambdaIntegration extends AwsIntegration {
});
}

const cfnFunction = this.handler.node.defaultChild as lambda.CfnFunction;
let functionName;

if (this.handler instanceof lambda.Function) {
// if not imported, extract the name from the CFN layer to reach
// the literal value if it is given (rather than a token)
functionName = (this.handler.node.defaultChild as lambda.CfnFunction).functionName;
} else {
// imported, just take the function name.
functionName = this.handler.functionName;
}

let deploymentToken;
if (!Token.isUnresolved(cfnFunction.functionName)) {
deploymentToken = JSON.stringify({ functionName: cfnFunction.functionName });
if (!Token.isUnresolved(functionName)) {
deploymentToken = JSON.stringify({ functionName });
}
return {
deploymentToken,
Expand Down
19 changes: 19 additions & 0 deletions packages/@aws-cdk/aws-apigateway/test/test.lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,23 @@ export = {

test.done();
},

'bind works for integration with imported functions'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const restapi = new apigateway.RestApi(stack, 'RestApi');
const method = restapi.root.addMethod('ANY');
const handler = lambda.Function.fromFunctionArn(stack, 'MyFunc', 'arn:aws:lambda:region:account:function:myfunc');
const integration = new apigateway.LambdaIntegration(handler);

// WHEN
const bindResult = integration.bind(method);

// the deployment token should be defined since the function name
// should be a literal string.
test.equal(bindResult?.deploymentToken, JSON.stringify({functionName: 'myfunc'}));

test.done();
},

};

0 comments on commit 7d6321f

Please sign in to comment.