class HttpRoute (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Apigatewayv2.HttpRoute |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsapigatewayv2#HttpRoute |
Java | software.amazon.awscdk.services.apigatewayv2.HttpRoute |
Python | aws_cdk.aws_apigatewayv2.HttpRoute |
TypeScript (source) | aws-cdk-lib » aws_apigatewayv2 » HttpRoute |
Implements
IConstruct
, IDependable
, IResource
, IHttp
, IRoute
Route class that creates the Route for API Gateway HTTP API.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_apigatewayv2 as apigatewayv2 } from 'aws-cdk-lib';
declare const httpApi: apigatewayv2.HttpApi;
declare const httpRouteAuthorizer: apigatewayv2.IHttpRouteAuthorizer;
declare const httpRouteIntegration: apigatewayv2.HttpRouteIntegration;
declare const httpRouteKey: apigatewayv2.HttpRouteKey;
const httpRoute = new apigatewayv2.HttpRoute(this, 'MyHttpRoute', {
httpApi: httpApi,
integration: httpRouteIntegration,
routeKey: httpRouteKey,
// the properties below are optional
authorizationScopes: ['authorizationScopes'],
authorizer: httpRouteAuthorizer,
});
Initializer
new HttpRoute(scope: Construct, id: string, props: HttpRouteProps)
Parameters
- scope
Construct
- id
string
- props
Http
Route Props
Construct Props
Name | Type | Description |
---|---|---|
http | IHttp | the API the route is associated with. |
integration | Http | The integration to be configured on this route. |
route | Http | The key to this route. |
authorization | string[] | The list of OIDC scopes to include in the authorization. |
authorizer? | IHttp | Authorizer for a WebSocket API or an HTTP API. |
httpApi
Type:
IHttp
the API the route is associated with.
integration
Type:
Http
The integration to be configured on this route.
routeKey
Type:
Http
The key to this route.
This is a combination of an HTTP method and an HTTP path.
authorizationScopes?
Type:
string[]
(optional, default: no additional authorization scopes)
The list of OIDC scopes to include in the authorization.
These scopes will be merged with the scopes from the attached authorizer
authorizer?
Type:
IHttp
(optional, default: No authorizer)
Authorizer for a WebSocket API or an HTTP API.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
http | IHttp | The HTTP API associated with this route. |
node | Node | The tree node. |
route | string | Returns the arn of the route. |
route | string | Id of the Route. |
stack | Stack | The stack in which this resource is defined. |
path? | string | Returns the path component of this HTTP route, undefined if the path is the catch-all route. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
httpApi
Type:
IHttp
The HTTP API associated with this route.
node
Type:
Node
The tree node.
routeArn
Type:
string
Returns the arn of the route.
routeId
Type:
string
Id of the Route.
stack
Type:
Stack
The stack in which this resource is defined.
path?
Type:
string
(optional)
Returns the path component of this HTTP route, undefined
if the path is the catch-all route.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
grant | Grant access to invoke the route. |
to | Returns a string representation of this construct. |
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
Invoke(grantee, options?)
grantpublic grantInvoke(grantee: IGrantable, options?: GrantInvokeOptions): Grant
Parameters
- grantee
IGrantable
- options
Grant
Invoke Options
Returns
Grant access to invoke the route.
This method requires that the authorizer of the route is undefined or is
an HttpIamAuthorizer
.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.