Skip to content

Commit

Permalink
feat(apigateway): support imported roles for integrations (aws#3369)
Browse files Browse the repository at this point in the history
* feat(apigateway): support imported roles for intgrations

Change type of `IntegrationOptions.credentialsRole` to `IRole` to enable
using an imported role.

Fixes aws#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.
  • Loading branch information
Elad Ben-Israel authored and mergify[bot] committed Aug 13, 2019
1 parent 3a96c27 commit 15df3c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions allowed-breaking-changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.<initializer>
new-argument:@aws-cdk/aws-iam.ManagedPolicy.<initializer>
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
13 changes: 11 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-apigateway/lib/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down

0 comments on commit 15df3c7

Please sign in to comment.