class ApiGateway
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Events.Targets.ApiGateway |
Java | software.amazon.awscdk.services.events.targets.ApiGateway |
Python | aws_cdk.aws_events_targets.ApiGateway |
TypeScript (source) | @aws-cdk/aws-events-targets » ApiGateway |
Implements
IRule
Use an API Gateway REST APIs as a target for Amazon EventBridge rules.
Example
import * as api from '@aws-cdk/aws-apigateway';
import * as lambda from '@aws-cdk/aws-lambda';
const rule = new events.Rule(this, 'Rule', {
schedule: events.Schedule.rate(cdk.Duration.minutes(1)),
});
const fn = new lambda.Function( this, 'MyFunc', {
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromInline( 'exports.handler = e => {}' ),
} );
const restApi = new api.LambdaRestApi( this, 'MyRestAPI', { handler: fn } );
const dlq = new sqs.Queue(this, 'DeadLetterQueue');
rule.addTarget(
new targets.ApiGateway( restApi, {
path: '/*/test',
method: 'GET',
stage: 'prod',
pathParameterValues: ['path-value'],
headerParameters: {
Header1: 'header1',
},
queryStringParameters: {
QueryParam1: 'query-param-1',
},
deadLetterQueue: dlq
} ),
)
Initializer
new ApiGateway(restApi: RestApi, props?: ApiGatewayProps)
Parameters
- restApi
Rest
Api - props
Api
Gateway Props
Properties
Name | Type | Description |
---|---|---|
rest | Rest |
restApi
Type:
Rest
Methods
Name | Description |
---|---|
bind(rule, _id?) | Returns a RuleTarget that can be used to trigger this API Gateway REST APIs as a result from an EventBridge event. |
bind(rule, _id?)
public bind(rule: IRule, _id?: string): RuleTargetConfig
Parameters
- rule
IRule
- _id
string
Returns
Returns a RuleTarget that can be used to trigger this API Gateway REST APIs as a result from an EventBridge event.