Table of Contents

Class RestApiOptions

Namespace
Amazon.CDK.AWS.APIGateway
Assembly
Amazon.CDK.AWS.APIGateway.dll

(deprecated) Represents the props that all Rest APIs share.

public class RestApiOptions : IRestApiOptions, IRestApiBaseProps, IResourceOptions
Inheritance
RestApiOptions
Implements
Inherited Members

Examples

// The code below shows an example of how to instantiate this type.
             // The values are placeholders you should change.
             using Amazon.CDK.AWS.APIGateway;
             using Amazon.CDK.AWS.CertificateManager;
             using Amazon.CDK.AWS.IAM;
             using Amazon.CDK.AWS.S3;
             using Amazon.CDK;

             IAccessLogDestination accessLogDestination;
             AccessLogFormat accessLogFormat;
             Authorizer authorizer;
             Bucket bucket;
             Certificate certificate;
             Integration integration;
             Model model;
             PolicyDocument policyDocument;
             RequestValidator requestValidator;
             var restApiOptions = new RestApiOptions {
                 CloudWatchRole = false,
                 DefaultCorsPreflightOptions = new CorsOptions {
                     AllowOrigins = new [] { "allowOrigins" },

                     // the properties below are optional
                     AllowCredentials = false,
                     AllowHeaders = new [] { "allowHeaders" },
                     AllowMethods = new [] { "allowMethods" },
                     DisableCache = false,
                     ExposeHeaders = new [] { "exposeHeaders" },
                     MaxAge = Duration.Minutes(30),
                     StatusCode = 123
                 },
                 DefaultIntegration = integration,
                 DefaultMethodOptions = new MethodOptions {
                     ApiKeyRequired = false,
                     AuthorizationScopes = new [] { "authorizationScopes" },
                     AuthorizationType = AuthorizationType.NONE,
                     Authorizer = authorizer,
                     MethodResponses = new [] { new MethodResponse {
                         StatusCode = "statusCode",

                         // the properties below are optional
                         ResponseModels = new Dictionary<string, IModel> {
                             { "responseModelsKey", model }
                         },
                         ResponseParameters = new Dictionary<string, boolean> {
                             { "responseParametersKey", false }
                         }
                     } },
                     OperationName = "operationName",
                     RequestModels = new Dictionary<string, IModel> {
                         { "requestModelsKey", model }
                     },
                     RequestParameters = new Dictionary<string, boolean> {
                         { "requestParametersKey", false }
                     },
                     RequestValidator = requestValidator,
                     RequestValidatorOptions = new RequestValidatorOptions {
                         RequestValidatorName = "requestValidatorName",
                         ValidateRequestBody = false,
                         ValidateRequestParameters = false
                     }
                 },
                 Deploy = false,
                 DeployOptions = new StageOptions {
                     AccessLogDestination = accessLogDestination,
                     AccessLogFormat = accessLogFormat,
                     CacheClusterEnabled = false,
                     CacheClusterSize = "cacheClusterSize",
                     CacheDataEncrypted = false,
                     CacheTtl = Duration.Minutes(30),
                     CachingEnabled = false,
                     ClientCertificateId = "clientCertificateId",
                     DataTraceEnabled = false,
                     Description = "description",
                     DocumentationVersion = "documentationVersion",
                     LoggingLevel = MethodLoggingLevel.OFF,
                     MethodOptions = new Dictionary<string, MethodDeploymentOptions> {
                         { "methodOptionsKey", new MethodDeploymentOptions {
                             CacheDataEncrypted = false,
                             CacheTtl = Duration.Minutes(30),
                             CachingEnabled = false,
                             DataTraceEnabled = false,
                             LoggingLevel = MethodLoggingLevel.OFF,
                             MetricsEnabled = false,
                             ThrottlingBurstLimit = 123,
                             ThrottlingRateLimit = 123
                         } }
                     },
                     MetricsEnabled = false,
                     StageName = "stageName",
                     ThrottlingBurstLimit = 123,
                     ThrottlingRateLimit = 123,
                     TracingEnabled = false,
                     Variables = new Dictionary<string, string> {
                         { "variablesKey", "variables" }
                     }
                 },
                 DisableExecuteApiEndpoint = false,
                 DomainName = new DomainNameOptions {
                     Certificate = certificate,
                     DomainName = "domainName",

                     // the properties below are optional
                     BasePath = "basePath",
                     EndpointType = EndpointType.EDGE,
                     Mtls = new MTLSConfig {
                         Bucket = bucket,
                         Key = "key",

                         // the properties below are optional
                         Version = "version"
                     },
                     SecurityPolicy = SecurityPolicy.TLS_1_0
                 },
                 EndpointExportName = "endpointExportName",
                 EndpointTypes = new [] { EndpointType.EDGE },
                 FailOnWarnings = false,
                 Parameters = new Dictionary<string, string> {
                     { "parametersKey", "parameters" }
                 },
                 Policy = policyDocument,
                 RestApiName = "restApiName",
                 RetainDeployments = false
             };

Remarks

Stability: Deprecated

ExampleMetadata: fixture=_generated

Constructors

RestApiOptions()

public RestApiOptions()

Properties

CloudWatchRole

Automatically configure an AWS CloudWatch role for API Gateway.

public bool? CloudWatchRole { get; set; }

Property Value

bool?

Remarks

Default: true

DefaultCorsPreflightOptions

Adds a CORS preflight OPTIONS method to this resource and all child resources.

public ICorsOptions? DefaultCorsPreflightOptions { get; set; }

Property Value

ICorsOptions

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

Integration

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

IMethodOptions

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 bool? Deploy { get; set; }

Property Value

bool?

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

IStageOptions

Remarks

If deploy is disabled, this value cannot be set.

Default: - Based on defaults of StageOptions.

DisableExecuteApiEndpoint

Specifies whether clients can invoke the API using the default execute-api endpoint.

public bool? DisableExecuteApiEndpoint { get; set; }

Property Value

bool?

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

IDomainNameOptions

Remarks

Default: - no domain name is defined, use addDomainName or directly define a DomainName.

EndpointExportName

Export name for the CfnOutput containing the API endpoint.

public string? EndpointExportName { get; set; }

Property Value

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

EndpointType[]

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 bool? FailOnWarnings { get; set; }

Property Value

bool?

Remarks

Default: false

Parameters

Custom header parameters for the request.

public IDictionary<string, string>? Parameters { get; set; }

Property Value

IDictionary<string, string>

Remarks

Policy

A policy document that contains the permissions for this RestApi.

public PolicyDocument? Policy { get; set; }

Property Value

PolicyDocument

Remarks

Default: - No policy.

RestApiName

A name for the API Gateway RestApi resource.

public string? RestApiName { get; set; }

Property Value

string

Remarks

Default: - ID of the RestApi construct.

RetainDeployments

Retains old deployment resources when the API changes.

public bool? RetainDeployments { get; set; }

Property Value

bool?

Remarks

This allows manually reverting stages to point to old deployments via the AWS Console.

Default: false