Skip to content
v2.274.0

ResourceProps Struct ​

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_apigateway as apigateway } from 'aws-cdk-lib';

declare const authorizer: apigateway.Authorizer;
declare const integration: apigateway.Integration;
declare const model: apigateway.Model;
declare const requestValidator: apigateway.RequestValidator;
declare const resource: apigateway.Resource;
const resourceProps: apigateway.ResourceProps = {
  parent: resource,
  pathPart: 'pathPart',

  // the properties below are optional
  defaultCorsPreflightOptions: {
    allowOrigins: ['allowOrigins'],

    // the properties below are optional
    allowCredentials: false,
    allowHeaders: ['allowHeaders'],
    allowMethods: ['allowMethods'],
    disableCache: false,
    exposeHeaders: ['exposeHeaders'],
    maxAge: cdk.Duration.minutes(30),
    statusCode: 123,
  },
  defaultIntegration: integration,
  defaultMethodOptions: {
    apiKeyRequired: false,
    authorizationScopes: ['authorizationScopes'],
    authorizationType: apigateway.AuthorizationType.NONE,
    authorizer: authorizer,
    methodResponses: [{
      statusCode: 'statusCode',

      // the properties below are optional
      responseModels: {
        responseModelsKey: model,
      },
      responseParameters: {
        responseParametersKey: false,
      },
    }],
    operationName: 'operationName',
    requestModels: {
      requestModelsKey: model,
    },
    requestParameters: {
      requestParametersKey: false,
    },
    requestValidator: requestValidator,
    requestValidatorOptions: {
      requestValidatorName: 'requestValidatorName',
      validateRequestBody: false,
      validateRequestParameters: false,
    },
  },
};

Properties ​

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

Default: CORS is disabled

You can add CORS at the resource-level using addCorsPreflight.

defaultIntegrationoptionalIntegrationdefault_integrationoptionalIntegrationdefaultIntegrationoptionalIntegrationDefaultIntegrationoptionalIntegrationDefaultIntegrationoptionalIntegration#
An integration to use as a default for all methods created within this API unless an integration is specified.

Default: Inherited from parent.

defaultMethodOptionsoptionalMethodOptionsdefault_method_optionsoptionalMethodOptionsdefaultMethodOptionsoptionalMethodOptionsDefaultMethodOptionsoptionalMethodOptionsDefaultMethodOptionsoptionalMethodOptions#
Method options to use as a default for all methods created within this API unless custom options are specified.

Default: Inherited from parent.

parentIResourceparentIResourceparentIResourceParentIResourceParentIResourcerequired#
The parent resource of this resource.

You can either pass another Resource object or a RestApi object here.

pathPartstringpath_partstrpathPartStringPathPartstringPathPart*stringrequired#
A path name for the resource.