From 15df3c7f08ae2843671b463fa380fe36182bef19 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Tue, 13 Aug 2019 21:27:32 +0300 Subject: [PATCH] feat(apigateway): support imported roles for integrations (#3369) * feat(apigateway): support imported roles for intgrations Change type of `IntegrationOptions.credentialsRole` to `IRole` to enable using an imported role. Fixes #2860 * make `Integration.props` internal Since this is read only by `Method`. This is technically a breaking change, but props is not part of the expected API. --- allowed-breaking-changes.txt | 5 +++++ packages/@aws-cdk/aws-apigateway/lib/integration.ts | 13 +++++++++++-- packages/@aws-cdk/aws-apigateway/lib/method.ts | 8 ++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/allowed-breaking-changes.txt b/allowed-breaking-changes.txt index dd731604f58d6..2d9ccc62c0ae0 100644 --- a/allowed-breaking-changes.txt +++ b/allowed-breaking-changes.txt @@ -7,3 +7,8 @@ incompatible-argument:@aws-cdk/aws-ecs.TaskDefinition.addVolume change-return-type:@aws-cdk/core.Fn.getAtt new-argument:@aws-cdk/aws-iam.ManagedPolicy. new-argument:@aws-cdk/aws-iam.ManagedPolicy. +removed:@aws-cdk/aws-apigateway.AwsIntegration.props +removed:@aws-cdk/aws-apigateway.HttpIntegration.props +removed:@aws-cdk/aws-apigateway.Integration.props +removed:@aws-cdk/aws-apigateway.LambdaIntegration.props +removed:@aws-cdk/aws-apigateway.MockIntegration.props diff --git a/packages/@aws-cdk/aws-apigateway/lib/integration.ts b/packages/@aws-cdk/aws-apigateway/lib/integration.ts index 306d70b76a19a..56b61e86920e8 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/integration.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/integration.ts @@ -31,7 +31,7 @@ export interface IntegrationOptions { * * @default A role is not assumed */ - readonly credentialsRole?: iam.Role; + readonly credentialsRole?: iam.IRole; /** * Requires that the caller's identity be passed through from the request. @@ -139,7 +139,16 @@ export interface IntegrationProps { * or implement on your own by specifying the set of props. */ export class Integration { - constructor(readonly props: IntegrationProps) { } + constructor(private readonly props: IntegrationProps) { } + + /** + * Allows `Method` to access the integration props. + * + * @internal + */ + public get _props() { + return this.props; + } /** * Can be overridden by subclasses to allow the integration to interact with the method diff --git a/packages/@aws-cdk/aws-apigateway/lib/method.ts b/packages/@aws-cdk/aws-apigateway/lib/method.ts index f4c1125772e0b..0a35acfcab2d3 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/method.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/method.ts @@ -188,7 +188,7 @@ export class Method extends Resource { integration.bind(this); - const options = integration.props.options || { }; + const options = integration._props.options || { }; let credentials; if (options.credentialsPassthrough !== undefined && options.credentialsRole !== undefined) { @@ -212,12 +212,12 @@ export class Method extends Resource { } return { - type: integration.props.type, - uri: integration.props.uri, + type: integration._props.type, + uri: integration._props.uri, cacheKeyParameters: options.cacheKeyParameters, cacheNamespace: options.cacheNamespace, contentHandling: options.contentHandling, - integrationHttpMethod: integration.props.integrationHttpMethod, + integrationHttpMethod: integration._props.integrationHttpMethod, requestParameters: options.requestParameters, requestTemplates: options.requestTemplates, passthroughBehavior: options.passthroughBehavior,