Class LambdaRestApiProps
Inheritance
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class LambdaRestApiProps : Object, ILambdaRestApiProps, IRestApiProps, IResourceOptions, IRestApiBaseProps
Syntax (vb)
Public Class LambdaRestApiProps
Inherits Object
Implements ILambdaRestApiProps, IRestApiProps, IResourceOptions, IRestApiBaseProps
Remarks
ExampleMetadata: infused
Examples
Queue sourceQueue;
var fn = new Function(this, "MyFunc", new FunctionProps {
Handler = "index.handler",
Runtime = Runtime.NODEJS_LATEST,
Code = Code.FromInline("exports.handler = e => {}")
});
var restApi = new LambdaRestApi(this, "MyRestAPI", new LambdaRestApiProps { Handler = fn });
var apiTarget = new ApiGatewayTarget(restApi);
var pipe = new Pipe(this, "Pipe", new PipeProps {
Source = new SqsSource(sourceQueue),
Target = apiTarget
});
Synopsis
Constructors
LambdaRestApiProps() |
Properties
ApiKeySourceType | The source of the API key for metering requests according to a usage plan. |
BinaryMediaTypes | The list of binary media mime-types that are supported by the RestApi resource, such as "image/png" or "application/octet-stream". |
CloneFrom | The ID of the API Gateway RestApi resource that you want to clone. |
CloudWatchRole | Automatically configure an AWS CloudWatch role for API Gateway. |
CloudWatchRoleRemovalPolicy | The removal policy applied to the AWS CloudWatch role when this resource is removed from the application. |
DefaultCorsPreflightOptions | Adds a CORS preflight OPTIONS method to this resource and all child resources. |
DefaultIntegration | An integration to use as a default for all methods created within this API unless an integration is specified. |
DefaultMethodOptions | Method options to use as a default for all methods created within this API unless custom options are specified. |
Deploy | Indicates if a Deployment should be automatically created for this API, and recreated when the API model (resources, methods) changes. |
DeployOptions | Options for the API Gateway stage that will always point to the latest deployment when |
Description | A description of the RestApi construct. |
DisableExecuteApiEndpoint | Specifies whether clients can invoke the API using the default execute-api endpoint. |
DomainName | Configure a custom domain name and map it to this API. |
EndpointConfiguration | The EndpointConfiguration property type specifies the endpoint types of a REST API. |
EndpointExportName | Export name for the CfnOutput containing the API endpoint. |
EndpointTypes | A list of the endpoint types of the API. |
FailOnWarnings | Indicates whether to roll back the resource if a warning occurs while API Gateway is creating the RestApi resource. |
Handler | The default Lambda function that handles all requests from this API. |
IntegrationOptions | Specific Lambda integration options. |
MinCompressionSize | A Size(in bytes, kibibytes, mebibytes etc) that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (when undefined) on an API. |
MinimumCompressionSize | (deprecated) 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. |
Parameters | Custom header parameters for the request. |
Policy | A policy document that contains the permissions for this RestApi. |
Proxy | If true, route all requests to the Lambda Function. |
RestApiName | A name for the API Gateway RestApi resource. |
RetainDeployments | Retains old deployment resources when the API changes. |
Constructors
LambdaRestApiProps()
public LambdaRestApiProps()
Properties
ApiKeySourceType
The source of the API key for metering requests according to a usage plan.
public Nullable<ApiKeySourceType> ApiKeySourceType { get; set; }
Property Value
System.Nullable<ApiKeySourceType>
Remarks
Default: - Metering is disabled.
BinaryMediaTypes
The list of binary media mime-types that are supported by the RestApi resource, such as "image/png" or "application/octet-stream".
public string[] BinaryMediaTypes { get; set; }
Property Value
System.String[]
Remarks
Default: - RestApi supports only UTF-8-encoded text payloads.
CloneFrom
The ID of the API Gateway RestApi resource that you want to clone.
public IRestApi CloneFrom { get; set; }
Property Value
Remarks
Default: - None.
CloudWatchRole
Automatically configure an AWS CloudWatch role for API Gateway.
public Nullable<bool> CloudWatchRole { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: - false if @aws-cdk/aws-apigateway:disableCloudWatchRole
is enabled, true otherwise
CloudWatchRoleRemovalPolicy
The removal policy applied to the AWS CloudWatch role when this resource is removed from the application.
public Nullable<RemovalPolicy> CloudWatchRoleRemovalPolicy { get; set; }
Property Value
System.Nullable<RemovalPolicy>
Remarks
Requires cloudWatchRole
to be enabled.
Default: - RemovalPolicy.RETAIN
DefaultCorsPreflightOptions
Adds a CORS preflight OPTIONS method to this resource and all child resources.
public ICorsOptions DefaultCorsPreflightOptions { get; set; }
Property Value
Remarks
You can add CORS at the resource-level using addCorsPreflight
.
Default: - CORS is disabled
DefaultIntegration
An integration to use as a default for all methods created within this API unless an integration is specified.
public Integration DefaultIntegration { get; set; }
Property Value
Remarks
Default: - Inherited from parent.
DefaultMethodOptions
Method options to use as a default for all methods created within this API unless custom options are specified.
public IMethodOptions DefaultMethodOptions { get; set; }
Property Value
Remarks
Default: - Inherited from parent.
Deploy
Indicates if a Deployment should be automatically created for this API, and recreated when the API model (resources, methods) changes.
public Nullable<bool> Deploy { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Since API Gateway deployments are immutable, When this option is enabled (by default), an AWS::ApiGateway::Deployment resource will automatically created with a logical ID that hashes the API model (methods, resources and options). This means that when the model changes, the logical ID of this CloudFormation resource will change, and a new deployment will be created.
If this is set, latestDeployment
will refer to the Deployment
object
and deploymentStage
will refer to a Stage
that points to this
deployment. To customize the stage options, use the deployOptions
property.
A CloudFormation Output will also be defined with the root URL endpoint of this REST API.
Default: true
DeployOptions
Options for the API Gateway stage that will always point to the latest deployment when deploy
is enabled.
public IStageOptions DeployOptions { get; set; }
Property Value
Remarks
If deploy
is disabled,
this value cannot be set.
Default: - Based on defaults of StageOptions
.
Description
A description of the RestApi construct.
public string Description { get; set; }
Property Value
System.String
Remarks
Default: - 'Automatically created by the RestApi construct'
DisableExecuteApiEndpoint
Specifies whether clients can invoke the API using the default execute-api endpoint.
public Nullable<bool> DisableExecuteApiEndpoint { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
To require that clients use a custom domain name to invoke the API, disable the default endpoint.
Default: false
See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html
DomainName
Configure a custom domain name and map it to this API.
public IDomainNameOptions DomainName { get; set; }
Property Value
Remarks
Default: - no domain name is defined, use addDomainName
or directly define a DomainName
.
EndpointConfiguration
The EndpointConfiguration property type specifies the endpoint types of a REST API.
public IEndpointConfiguration EndpointConfiguration { get; set; }
Property Value
Remarks
Default: EndpointType.EDGE
EndpointExportName
Export name for the CfnOutput containing the API endpoint.
public string EndpointExportName { get; set; }
Property Value
System.String
Remarks
Default: - when no export name is given, output will be created without export
EndpointTypes
A list of the endpoint types of the API.
public EndpointType[] EndpointTypes { get; set; }
Property Value
Remarks
Use this property when creating an API.
Default: EndpointType.EDGE
FailOnWarnings
Indicates whether to roll back the resource if a warning occurs while API Gateway is creating the RestApi resource.
public Nullable<bool> FailOnWarnings { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false
Handler
The default Lambda function that handles all requests from this API.
public IFunction Handler { get; set; }
Property Value
Remarks
This handler will be used as a the default integration for all methods in
this API, unless specified otherwise in addMethod
.
IntegrationOptions
Specific Lambda integration options.
public ILambdaIntegrationOptions IntegrationOptions { get; set; }
Property Value
Remarks
Default: see defaults defined in LambdaIntegrationOptions
.
MinCompressionSize
A Size(in bytes, kibibytes, mebibytes etc) that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (when undefined) on an API.
public Size MinCompressionSize { get; set; }
Property Value
Remarks
When compression is enabled, compression or decompression is not applied on the payload if the payload size is smaller than this value. Setting it to zero allows compression for any payload size.
Default: - Compression is disabled.
MinimumCompressionSize
(deprecated) 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.
public Nullable<double> MinimumCompressionSize { get; set; }
Property Value
System.Nullable<System.Double>
Remarks
When compression is enabled, compression or decompression is not applied on the payload if the payload size is smaller than this value. Setting it to zero allows compression for any payload size.
Default: - Compression is disabled.
Stability: Deprecated
Parameters
Custom header parameters for the request.
public IDictionary<string, string> Parameters { get; set; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.String>
Remarks
Default: - No parameters.
See: https://docs.aws.amazon.com/cli/latest/reference/apigateway/import-rest-api.html
Policy
A policy document that contains the permissions for this RestApi.
public PolicyDocument Policy { get; set; }
Property Value
Remarks
Default: - No policy.
Proxy
If true, route all requests to the Lambda Function.
public Nullable<bool> Proxy { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
If set to false, you will need to explicitly define the API model using
addResource
and addMethod
(or addProxy
).
Default: true
RestApiName
A name for the API Gateway RestApi resource.
public string RestApiName { get; set; }
Property Value
System.String
Remarks
Default: - ID of the RestApi construct.
RetainDeployments
Retains old deployment resources when the API changes.
public Nullable<bool> RetainDeployments { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
This allows manually reverting stages to point to old deployments via the AWS Console.
Default: false