HttpSqsIntegration Class
The Sqs integration resource for HTTP API.
Example
ts
import * as sqs from 'aws-cdk-lib/aws-sqs';
import { HttpSqsIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
declare const queue: sqs.IQueue;
declare const httpApi: apigwv2.HttpApi;
// default integration (send message)
httpApi.addRoutes({
path: '/default',
methods: [apigwv2.HttpMethod.POST],
integration: new HttpSqsIntegration('defaultIntegration', {
queue,
}),
});
// send message integration
httpApi.addRoutes({
path: '/send-message',
methods: [apigwv2.HttpMethod.POST],
integration: new HttpSqsIntegration('sendMessageIntegration', {
queue,
subtype: apigwv2.HttpIntegrationSubtype.SQS_SEND_MESSAGE,
}),
});
// receive message integration
httpApi.addRoutes({
path: '/receive-message',
methods: [apigwv2.HttpMethod.POST],
integration: new HttpSqsIntegration('receiveMessageIntegration', {
queue,
subtype: apigwv2.HttpIntegrationSubtype.SQS_RECEIVE_MESSAGE,
}),
});
// delete message integration
httpApi.addRoutes({
path: '/delete-message',
methods: [apigwv2.HttpMethod.POST],
integration: new HttpSqsIntegration('deleteMessageIntegration', {
queue,
subtype: apigwv2.HttpIntegrationSubtype.SQS_DELETE_MESSAGE,
}),
});
// purge queue integration
httpApi.addRoutes({
path: '/purge-queue',
methods: [apigwv2.HttpMethod.POST],
integration: new HttpSqsIntegration('purgeQueueIntegration', {
queue,
subtype: apigwv2.HttpIntegrationSubtype.SQS_PURGE_QUEUE,
}),
});
python
import aws_cdk.aws_sqs as sqs
from aws_cdk.aws_apigatewayv2_integrations import HttpSqsIntegration
# queue: sqs.IQueue
# http_api: apigwv2.HttpApi
# default integration (send message)
http_api.add_routes(
path="/default",
methods=[apigwv2.HttpMethod.POST],
integration=HttpSqsIntegration("defaultIntegration",
queue=queue
)
)
# send message integration
http_api.add_routes(
path="/send-message",
methods=[apigwv2.HttpMethod.POST],
integration=HttpSqsIntegration("sendMessageIntegration",
queue=queue,
subtype=apigwv2.HttpIntegrationSubtype.SQS_SEND_MESSAGE
)
)
# receive message integration
http_api.add_routes(
path="/receive-message",
methods=[apigwv2.HttpMethod.POST],
integration=HttpSqsIntegration("receiveMessageIntegration",
queue=queue,
subtype=apigwv2.HttpIntegrationSubtype.SQS_RECEIVE_MESSAGE
)
)
# delete message integration
http_api.add_routes(
path="/delete-message",
methods=[apigwv2.HttpMethod.POST],
integration=HttpSqsIntegration("deleteMessageIntegration",
queue=queue,
subtype=apigwv2.HttpIntegrationSubtype.SQS_DELETE_MESSAGE
)
)
# purge queue integration
http_api.add_routes(
path="/purge-queue",
methods=[apigwv2.HttpMethod.POST],
integration=HttpSqsIntegration("purgeQueueIntegration",
queue=queue,
subtype=apigwv2.HttpIntegrationSubtype.SQS_PURGE_QUEUE
)
)
java
import software.amazon.awscdk.services.sqs.*;
import software.amazon.awscdk.aws_apigatewayv2_integrations.HttpSqsIntegration;
IQueue queue;
HttpApi httpApi;
// default integration (send message)
httpApi.addRoutes(AddRoutesOptions.builder()
.path("/default")
.methods(List.of(HttpMethod.POST))
.integration(HttpSqsIntegration.Builder.create("defaultIntegration")
.queue(queue)
.build())
.build());
// send message integration
httpApi.addRoutes(AddRoutesOptions.builder()
.path("/send-message")
.methods(List.of(HttpMethod.POST))
.integration(HttpSqsIntegration.Builder.create("sendMessageIntegration")
.queue(queue)
.subtype(HttpIntegrationSubtype.SQS_SEND_MESSAGE)
.build())
.build());
// receive message integration
httpApi.addRoutes(AddRoutesOptions.builder()
.path("/receive-message")
.methods(List.of(HttpMethod.POST))
.integration(HttpSqsIntegration.Builder.create("receiveMessageIntegration")
.queue(queue)
.subtype(HttpIntegrationSubtype.SQS_RECEIVE_MESSAGE)
.build())
.build());
// delete message integration
httpApi.addRoutes(AddRoutesOptions.builder()
.path("/delete-message")
.methods(List.of(HttpMethod.POST))
.integration(HttpSqsIntegration.Builder.create("deleteMessageIntegration")
.queue(queue)
.subtype(HttpIntegrationSubtype.SQS_DELETE_MESSAGE)
.build())
.build());
// purge queue integration
httpApi.addRoutes(AddRoutesOptions.builder()
.path("/purge-queue")
.methods(List.of(HttpMethod.POST))
.integration(HttpSqsIntegration.Builder.create("purgeQueueIntegration")
.queue(queue)
.subtype(HttpIntegrationSubtype.SQS_PURGE_QUEUE)
.build())
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.SQS;
using Amazon.CDK.AwsApigatewayv2Integrations;
IQueue queue;
HttpApi httpApi;
// default integration (send message)
httpApi.AddRoutes(new AddRoutesOptions {
Path = "/default",
Methods = new [] { HttpMethod.POST },
Integration = new HttpSqsIntegration("defaultIntegration", new HttpSqsIntegrationProps {
Queue = queue
})
});
// send message integration
httpApi.AddRoutes(new AddRoutesOptions {
Path = "/send-message",
Methods = new [] { HttpMethod.POST },
Integration = new HttpSqsIntegration("sendMessageIntegration", new HttpSqsIntegrationProps {
Queue = queue,
Subtype = HttpIntegrationSubtype.SQS_SEND_MESSAGE
})
});
// receive message integration
httpApi.AddRoutes(new AddRoutesOptions {
Path = "/receive-message",
Methods = new [] { HttpMethod.POST },
Integration = new HttpSqsIntegration("receiveMessageIntegration", new HttpSqsIntegrationProps {
Queue = queue,
Subtype = HttpIntegrationSubtype.SQS_RECEIVE_MESSAGE
})
});
// delete message integration
httpApi.AddRoutes(new AddRoutesOptions {
Path = "/delete-message",
Methods = new [] { HttpMethod.POST },
Integration = new HttpSqsIntegration("deleteMessageIntegration", new HttpSqsIntegrationProps {
Queue = queue,
Subtype = HttpIntegrationSubtype.SQS_DELETE_MESSAGE
})
});
// purge queue integration
httpApi.AddRoutes(new AddRoutesOptions {
Path = "/purge-queue",
Methods = new [] { HttpMethod.POST },
Integration = new HttpSqsIntegration("purgeQueueIntegration", new HttpSqsIntegrationProps {
Queue = queue,
Subtype = HttpIntegrationSubtype.SQS_PURGE_QUEUE
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import sqs "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
var queue IQueue
var httpApi HttpApi
// default integration (send message)
httpApi.AddRoutes(&AddRoutesOptions{
Path: jsii.String("/default"),
Methods: []HttpMethod{
apigwv2.HttpMethod_POST,
},
Integration: awscdk.NewHttpSqsIntegration(jsii.String("defaultIntegration"), &HttpSqsIntegrationProps{
Queue: *Queue,
}),
})
// send message integration
httpApi.AddRoutes(&AddRoutesOptions{
Path: jsii.String("/send-message"),
Methods: []HttpMethod{
apigwv2.HttpMethod_POST,
},
Integration: awscdk.NewHttpSqsIntegration(jsii.String("sendMessageIntegration"), &HttpSqsIntegrationProps{
Queue: *Queue,
Subtype: apigwv2.HttpIntegrationSubtype_SQS_SEND_MESSAGE,
}),
})
// receive message integration
httpApi.AddRoutes(&AddRoutesOptions{
Path: jsii.String("/receive-message"),
Methods: []HttpMethod{
apigwv2.HttpMethod_POST,
},
Integration: awscdk.NewHttpSqsIntegration(jsii.String("receiveMessageIntegration"), &HttpSqsIntegrationProps{
Queue: *Queue,
Subtype: apigwv2.HttpIntegrationSubtype_SQS_RECEIVE_MESSAGE,
}),
})
// delete message integration
httpApi.AddRoutes(&AddRoutesOptions{
Path: jsii.String("/delete-message"),
Methods: []HttpMethod{
apigwv2.HttpMethod_POST,
},
Integration: awscdk.NewHttpSqsIntegration(jsii.String("deleteMessageIntegration"), &HttpSqsIntegrationProps{
Queue: *Queue,
Subtype: apigwv2.HttpIntegrationSubtype_SQS_DELETE_MESSAGE,
}),
})
// purge queue integration
httpApi.AddRoutes(&AddRoutesOptions{
Path: jsii.String("/purge-queue"),
Methods: []HttpMethod{
apigwv2.HttpMethod_POST,
},
Integration: awscdk.NewHttpSqsIntegration(jsii.String("purgeQueueIntegration"), &HttpSqsIntegrationProps{
Queue: *Queue,
Subtype: apigwv2.HttpIntegrationSubtype_SQS_PURGE_QUEUE,
}),
})
Initializer
ts
new HttpSqsIntegration(id: string, props: HttpSqsIntegrationProps)
python
HttpSqsIntegration(id: str, props: HttpSqsIntegrationProps)
java
new HttpSqsIntegration(String id, HttpSqsIntegrationProps props)
csharp
new HttpSqsIntegration(string id, HttpSqsIntegrationProps props)
go
NewHttpSqsIntegration(Id *string, Props HttpSqsIntegrationProps)
Methods
bind(options: HttpRouteIntegrationBindOptions): HttpRouteIntegrationConfigdef bind(self, options: HttpRouteIntegrationBindOptions) -> HttpRouteIntegrationConfigpublic HttpRouteIntegrationConfig bind(HttpRouteIntegrationBindOptions options)public HttpRouteIntegrationConfig Bind(HttpRouteIntegrationBindOptions options)func Bind(Options HttpRouteIntegrationBindOptions) HttpRouteIntegrationConfig#Bind this integration to the route.