Skip to content

Latest commit

 

History

History
229 lines (147 loc) · 18.8 KB

File metadata and controls

229 lines (147 loc) · 18.8 KB

API Reference

Classes

Name Description
HttpMethod No description
RestApi No description

Structs

Name Description
RestApiProps No description
RestApiResourceProps No description

class HttpMethod

Initializer

new HttpMethod(method: string)
  • method (string) No description

Properties

Name Type Description
method string HTTP Method.
static ANY HttpMethod HTTP ANY Method.
static DELETE HttpMethod HTTP DELETE Method.
static GET HttpMethod HTTP GET Method.
static HEAD HttpMethod HTTP HEAD Method.
static OPTIONS HttpMethod HTTP OPTIONS Method.
static PATCH HttpMethod HTTP PATH Method.
static POST HttpMethod HTTP POST Method.
static PUT HttpMethod HTTP PUT Method.

Methods

toString()

toString(): string

Returns:

  • string

class RestApi

Implements: IConstruct, IDependable Extends: Construct

Initializer

new RestApi(scope: Construct, id: string, props: RestApiProps)
  • scope (Construct) No description
  • id (string) No description
  • props (RestApiProps) No description
    • defaultCorsPreflightOptions (aws_apigateway.CorsOptions) Adds a CORS preflight OPTIONS method to this resource and all child resources. Default: CORS is disabled
    • defaultIntegration (aws_apigateway.Integration) An integration to use as a default for all methods created within this API unless an integration is specified. Default: Inherited from parent.
    • defaultMethodOptions (aws_apigateway.MethodOptions) Method options to use as a default for all methods created within this API unless custom options are specified. Default: Inherited from parent.
    • cloudWatchRole (boolean) Automatically configure an AWS CloudWatch role for API Gateway. Default: true
    • deploy (boolean) Indicates if a Deployment should be automatically created for this API, and recreated when the API model (resources, methods) changes. Default: true
    • deployOptions (aws_apigateway.StageOptions) Options for the API Gateway stage that will always point to the latest deployment when deploy is enabled. Default: Based on defaults of StageOptions.
    • disableExecuteApiEndpoint (boolean) Specifies whether clients can invoke the API using the default execute-api endpoint. Default: false
    • domainName (aws_apigateway.DomainNameOptions) Configure a custom domain name and map it to this API. Default: no domain name is defined, use addDomainName or directly define a DomainName.
    • endpointExportName (string) Export name for the CfnOutput containing the API endpoint. Default: when no export name is given, output will be created without export
    • endpointTypes (Array<aws_apigateway.EndpointType>) A list of the endpoint types of the API. Default: EndpointType.EDGE
    • failOnWarnings (boolean) Indicates whether to roll back the resource if a warning occurs while API Gateway is creating the RestApi resource. Default: false
    • parameters (Map<string, string>) Custom header parameters for the request. Default: No parameters.
    • policy (aws_iam.PolicyDocument) A policy document that contains the permissions for this RestApi. Default: No policy.
    • restApiName (string) A name for the API Gateway RestApi resource. Default: ID of the RestApi construct.
    • retainDeployments (boolean) Retains old deployment resources when the API changes. Default: false
    • apiKeySourceType (aws_apigateway.ApiKeySourceType) The source of the API key for metering requests according to a usage plan. Default: Metering is disabled.
    • binaryMediaTypes (Array) The list of binary media mime-types that are supported by the RestApi resource, such as "image/png" or "application/octet-stream". Default: RestApi supports only UTF-8-encoded text payloads.
    • cloneFrom (aws_apigateway.IRestApi) The ID of the API Gateway RestApi resource that you want to clone. Default: None.
    • description (string) A description of the purpose of this API Gateway RestApi resource. Default: No description.
    • endpointConfiguration (aws_apigateway.EndpointConfiguration) The EndpointConfiguration property type specifies the endpoint types of a REST API. Default: EndpointType.EDGE
    • minimumCompressionSize (number) A nullable integer that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (when undefined) on an API. Default: Compression is disabled.
    • resources (Array<RestApiResourceProps>) Define Rest API resources.
    • authorizationType (aws_apigateway.AuthorizationType) Specify globally AuthorizationType by aws-apigateway.AuthorizationType, default is NONE. Optional
    • authorizer (aws_apigateway.IAuthorizer) Specify globally Authorizer by aws-Authorizer, default is null. Optional
    • enableCors (boolean) Enable cors, default is true. Optional
    • restApi (aws_apigateway.RestApi) Custom RestApi. Optional

Properties

Name Type Description
restApi aws_apigateway.RestApi
restApiId string
url string

Methods

addResource(resource)

addResource(resource: RestApiResourceProps): RestApi
  • resource (RestApiResourceProps) No description
    • httpMethod (HttpMethod) Specify HTTP Method.
    • path (string) Define Resource path.
    • authorizationType (aws_apigateway.AuthorizationType) Specify AuthorizationType by aws-apigateway.AuthorizationType. Default: AuthorizationType.NONE
    • authorizer (aws_apigateway.IAuthorizer) Specify Authorizer by aws-Authorizer. Default: undefined
    • integration (aws_apigateway.Integration) Specify integration. Default: undefined
    • lambdaFunction (aws_lambda.IFunction) Specify Lambda function to integration. Default: undefined
    • methodOptions (aws_apigateway.MethodOptions) Specify method options. Default: undefined
    • networkLoadBalancer (aws_elasticloadbalancingv2.INetworkLoadBalancer) Specify NLB with VPC Link to integration Only supported Network Load Balancer https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html#http-api-vs-rest.differences.management The VPCLink / VPCLinkProxy & NetworkLoadBalancer are Integration Helper You can define the path like example will automatically identify pathParameters & queryStringParameters to add "RequestParameters" mapping to your origin service example: /groups/{groupId}/users/{userId}?type={type}&enabled={enabled?} the "enabled" has "?", it's be optional. { Integration: { Options: { RequestParameters: { 'integration.request.path.groupId': 'method.request.path.groupId', 'integration.request.path.userId': 'method.request.path.userId', 'integration.request.querystring.type': 'method.request.querystring.type', 'integration.request.querystring.enabled': 'method.request.querystring.enabled', } } }, RequestParameter: { 'method.request.path.groupId': true, 'method.request.path.userId': true, 'method.request.querystring.type': true, 'method.request.querystring.enabled': false, } }. Optional
    • vpcLink (aws_apigateway.VpcLink) Specify VPC Link to integration. Optional
    • vpcLinkIntegrationOptions (aws_apigateway.IntegrationOptions) Speficy VPC Link integration options. Optional
    • vpcLinkProxy (aws_apigateway.VpcLink) Specify VPC Link Proxy to integration. Optional

Returns:

addResources(resources)

addResources(resources: Array<RestApiResourceProps>): RestApi

Returns:

struct RestApiProps

Name Type Description
resources Array<RestApiResourceProps> Define Rest API resources.
apiKeySourceType? aws_apigateway.ApiKeySourceType The source of the API key for metering requests according to a usage plan.
Default: Metering is disabled.
authorizationType? aws_apigateway.AuthorizationType Specify globally AuthorizationType by aws-apigateway.AuthorizationType, default is NONE.
Optional
authorizer? aws_apigateway.IAuthorizer Specify globally Authorizer by aws-Authorizer, default is null.
Optional
binaryMediaTypes? Array The list of binary media mime-types that are supported by the RestApi resource, such as "image/png" or "application/octet-stream".
Default: RestApi supports only UTF-8-encoded text payloads.
cloneFrom? aws_apigateway.IRestApi The ID of the API Gateway RestApi resource that you want to clone.
Default: None.
cloudWatchRole? boolean Automatically configure an AWS CloudWatch role for API Gateway.
Default: true
defaultCorsPreflightOptions? aws_apigateway.CorsOptions Adds a CORS preflight OPTIONS method to this resource and all child resources.
Default: CORS is disabled
defaultIntegration? aws_apigateway.Integration An integration to use as a default for all methods created within this API unless an integration is specified.
Default: Inherited from parent.
defaultMethodOptions? aws_apigateway.MethodOptions Method options to use as a default for all methods created within this API unless custom options are specified.
Default: Inherited from parent.
deploy? boolean Indicates if a Deployment should be automatically created for this API, and recreated when the API model (resources, methods) changes.
Default: true
deployOptions? aws_apigateway.StageOptions Options for the API Gateway stage that will always point to the latest deployment when deploy is enabled.
Default: Based on defaults of StageOptions.
description? string A description of the purpose of this API Gateway RestApi resource.
Default: No description.
disableExecuteApiEndpoint? boolean Specifies whether clients can invoke the API using the default execute-api endpoint.
Default: false
domainName? aws_apigateway.DomainNameOptions Configure a custom domain name and map it to this API.
Default: no domain name is defined, use addDomainName or directly define a DomainName.
enableCors? boolean Enable cors, default is true.
Optional
endpointConfiguration? aws_apigateway.EndpointConfiguration The EndpointConfiguration property type specifies the endpoint types of a REST API.
Default: EndpointType.EDGE
endpointExportName? string Export name for the CfnOutput containing the API endpoint.
Default: when no export name is given, output will be created without export
endpointTypes? Array<aws_apigateway.EndpointType> A list of the endpoint types of the API.
Default: EndpointType.EDGE
failOnWarnings? boolean Indicates whether to roll back the resource if a warning occurs while API Gateway is creating the RestApi resource.
Default: false
minimumCompressionSize? number A nullable integer that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (when undefined) on an API.
Default: Compression is disabled.
parameters? Map<string, string> Custom header parameters for the request.
Default: No parameters.
policy? aws_iam.PolicyDocument A policy document that contains the permissions for this RestApi.
Default: No policy.
restApi? aws_apigateway.RestApi Custom RestApi.
Optional
restApiName? string A name for the API Gateway RestApi resource.
Default: ID of the RestApi construct.
retainDeployments? boolean Retains old deployment resources when the API changes.
Default: false

struct RestApiResourceProps

Name Type Description
httpMethod HttpMethod Specify HTTP Method.
path string Define Resource path.
authorizationType? aws_apigateway.AuthorizationType Specify AuthorizationType by aws-apigateway.AuthorizationType.
Default: AuthorizationType.NONE
authorizer? aws_apigateway.IAuthorizer Specify Authorizer by aws-Authorizer.
Default: undefined
integration? aws_apigateway.Integration Specify integration.
Default: undefined
lambdaFunction? aws_lambda.IFunction Specify Lambda function to integration.
Default: undefined
methodOptions? aws_apigateway.MethodOptions Specify method options.
Default: undefined
networkLoadBalancer? aws_elasticloadbalancingv2.INetworkLoadBalancer Specify NLB with VPC Link to integration Only supported Network Load Balancer https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html#http-api-vs-rest.differences.management The VPCLink / VPCLinkProxy & NetworkLoadBalancer are Integration Helper You can define the path like example will automatically identify pathParameters & queryStringParameters to add "RequestParameters" mapping to your origin service example: /groups/{groupId}/users/{userId}?type={type}&enabled={enabled?} the "enabled" has "?", it's be optional. { Integration: { Options: { RequestParameters: { 'integration.request.path.groupId': 'method.request.path.groupId', 'integration.request.path.userId': 'method.request.path.userId', 'integration.request.querystring.type': 'method.request.querystring.type', 'integration.request.querystring.enabled': 'method.request.querystring.enabled', } } }, RequestParameter: { 'method.request.path.groupId': true, 'method.request.path.userId': true, 'method.request.querystring.type': true, 'method.request.querystring.enabled': false, } }.
Optional
vpcLink? aws_apigateway.VpcLink Specify VPC Link to integration.
Optional
vpcLinkIntegrationOptions? aws_apigateway.IntegrationOptions Speficy VPC Link integration options.
Optional
vpcLinkProxy? aws_apigateway.VpcLink Specify VPC Link Proxy to integration.
Optional