Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aws-apigateway): add integrationHttpMethod prop to AwsIntegration #2160

Merged
merged 1 commit into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/integrations/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ export interface AwsIntegrationProps {
*/
readonly actionParameters?: { [key: string]: string };

/**
* The integration's HTTP method type.
*
* @default POST
*/
readonly integrationHttpMethod?: string;

/**
* Integration options, such as content handling, request/response mapping, etc.
*/
Expand All @@ -70,7 +77,7 @@ export class AwsIntegration extends Integration {
const { apiType, apiValue } = parseAwsApiCall(props.path, props.action, props.actionParameters);
super({
type,
integrationHttpMethod: 'POST',
integrationHttpMethod: props.integrationHttpMethod || 'POST',
uri: new cdk.Token(() => {
if (!this.scope) { throw new Error('AwsIntegration must be used in API'); }
return this.scope.node.stack.formatArn({
Expand Down
22 changes: 22 additions & 0 deletions packages/@aws-cdk/aws-apigateway/test/test.method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ export = {
test.done();
},

'integration with a custom http method can be set via a property'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const api = new apigateway.RestApi(stack, 'test-api', { cloudWatchRole: false, deploy: false });

// WHEN
new apigateway.Method(stack, 'my-method', {
httpMethod: 'POST',
resource: api.root,
integration: new apigateway.AwsIntegration({ service: 's3', path: 'bucket/key', integrationHttpMethod: 'GET' })
});

// THEN
expect(stack).to(haveResourceLike('AWS::ApiGateway::Method', {
Integration: {
IntegrationHttpMethod: "GET"
}
}));

test.done();
},

'use default integration from api'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down