Skip to content
v2.278.0

ProxyResourceProps 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 proxyResourceProps: apigateway.ProxyResourceProps = {
  parent: resource,

  // the properties below are optional
  anyMethod: false,
  autoConfigurePathParameter: false,
  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,
    },
  },
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_apigateway as apigateway

# authorizer: apigateway.Authorizer
# integration: apigateway.Integration
# model: apigateway.Model
# request_validator: apigateway.RequestValidator
# resource: apigateway.Resource

proxy_resource_props = apigateway.ProxyResourceProps(
    parent=resource,

    # the properties below are optional
    any_method=False,
    auto_configure_path_parameter=False,
    default_cors_preflight_options=apigateway.CorsOptions(
        allow_origins=["allowOrigins"],

        # the properties below are optional
        allow_credentials=False,
        allow_headers=["allowHeaders"],
        allow_methods=["allowMethods"],
        disable_cache=False,
        expose_headers=["exposeHeaders"],
        max_age=cdk.Duration.minutes(30),
        status_code=123
    ),
    default_integration=integration,
    default_method_options=apigateway.MethodOptions(
        api_key_required=False,
        authorization_scopes=["authorizationScopes"],
        authorization_type=apigateway.AuthorizationType.NONE,
        authorizer=authorizer,
        method_responses=[apigateway.MethodResponse(
            status_code="statusCode",

            # the properties below are optional
            response_models={
                "response_models_key": model
            },
            response_parameters={
                "response_parameters_key": False
            }
        )],
        operation_name="operationName",
        request_models={
            "request_models_key": model
        },
        request_parameters={
            "request_parameters_key": False
        },
        request_validator=request_validator,
        request_validator_options=apigateway.RequestValidatorOptions(
            request_validator_name="requestValidatorName",
            validate_request_body=False,
            validate_request_parameters=False
        )
    )
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.apigateway.*;

Authorizer authorizer;
Integration integration;
Model model;
RequestValidator requestValidator;
Resource resource;

ProxyResourceProps proxyResourceProps = ProxyResourceProps.builder()
        .parent(resource)

        // the properties below are optional
        .anyMethod(false)
        .autoConfigurePathParameter(false)
        .defaultCorsPreflightOptions(CorsOptions.builder()
                .allowOrigins(List.of("allowOrigins"))

                // the properties below are optional
                .allowCredentials(false)
                .allowHeaders(List.of("allowHeaders"))
                .allowMethods(List.of("allowMethods"))
                .disableCache(false)
                .exposeHeaders(List.of("exposeHeaders"))
                .maxAge(Duration.minutes(30))
                .statusCode(123)
                .build())
        .defaultIntegration(integration)
        .defaultMethodOptions(MethodOptions.builder()
                .apiKeyRequired(false)
                .authorizationScopes(List.of("authorizationScopes"))
                .authorizationType(AuthorizationType.NONE)
                .authorizer(authorizer)
                .methodResponses(List.of(MethodResponse.builder()
                        .statusCode("statusCode")

                        // the properties below are optional
                        .responseModels(Map.of(
                                "responseModelsKey", model))
                        .responseParameters(Map.of(
                                "responseParametersKey", false))
                        .build()))
                .operationName("operationName")
                .requestModels(Map.of(
                        "requestModelsKey", model))
                .requestParameters(Map.of(
                        "requestParametersKey", false))
                .requestValidator(requestValidator)
                .requestValidatorOptions(RequestValidatorOptions.builder()
                        .requestValidatorName("requestValidatorName")
                        .validateRequestBody(false)
                        .validateRequestParameters(false)
                        .build())
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.APIGateway;

Authorizer authorizer;
Integration integration;
Model model;
RequestValidator requestValidator;
Resource resource;

var proxyResourceProps = new ProxyResourceProps {
    Parent = resource,

    // the properties below are optional
    AnyMethod = false,
    AutoConfigurePathParameter = 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
        }
    }
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var authorizer Authorizer
var integration Integration
var model Model
var requestValidator RequestValidator
var resource Resource

proxyResourceProps := &ProxyResourceProps{
	Parent: resource,

	// the properties below are optional
	AnyMethod: jsii.Boolean(false),
	AutoConfigurePathParameter: jsii.Boolean(false),
	DefaultCorsPreflightOptions: &CorsOptions{
		AllowOrigins: []*string{
			jsii.String("allowOrigins"),
		},

		// the properties below are optional
		AllowCredentials: jsii.Boolean(false),
		AllowHeaders: []*string{
			jsii.String("allowHeaders"),
		},
		AllowMethods: []*string{
			jsii.String("allowMethods"),
		},
		DisableCache: jsii.Boolean(false),
		ExposeHeaders: []*string{
			jsii.String("exposeHeaders"),
		},
		MaxAge: cdk.Duration_Minutes(jsii.Number(30)),
		StatusCode: jsii.Number(123),
	},
	DefaultIntegration: integration,
	DefaultMethodOptions: &MethodOptions{
		ApiKeyRequired: jsii.Boolean(false),
		AuthorizationScopes: []*string{
			jsii.String("authorizationScopes"),
		},
		AuthorizationType: awscdk.Aws_apigateway.AuthorizationType_NONE,
		Authorizer: authorizer,
		MethodResponses: []MethodResponse{
			&MethodResponse{
				StatusCode: jsii.String("statusCode"),

				// the properties below are optional
				ResponseModels: map[string]IModel{
					"responseModelsKey": model,
				},
				ResponseParameters: map[string]*bool{
					"responseParametersKey": jsii.Boolean(false),
				},
			},
		},
		OperationName: jsii.String("operationName"),
		RequestModels: map[string]IModel{
			"requestModelsKey": model,
		},
		RequestParameters: map[string]*bool{
			"requestParametersKey": jsii.Boolean(false),
		},
		RequestValidator: requestValidator,
		RequestValidatorOptions: &RequestValidatorOptions{
			RequestValidatorName: jsii.String("requestValidatorName"),
			ValidateRequestBody: jsii.Boolean(false),
			ValidateRequestParameters: jsii.Boolean(false),
		},
	},
}

Properties ​

anyMethodoptionalbooleanany_methodoptionalboolanyMethodoptionalBooleanAnyMethodoptionalboolAnyMethodoptional*bool = true #
Adds an "ANY" method to this resource.

If set to false, you will have to explicitly add methods to this resource after it's created.

autoConfigurePathParameteroptionalbooleanauto_configure_path_parameteroptionalboolautoConfigurePathParameteroptionalBooleanAutoConfigurePathParameteroptionalboolAutoConfigurePathParameteroptional*bool = false #
Automatically configure path parameter mapping for the proxy resource.
notes

When enabled, this property automatically configures both the method request and integration request to properly handle the proxy path parameter:

  • Adds method.request.path.proxy: true to method request parameters
  • Adds integration.request.path.proxy: 'method.request.path.proxy' to integration request parameters

This matches the behavior of the AWS Console when creating proxy resources and eliminates the need to manually configure path parameters.

This is meant for integrations whose URI uses {proxy}, such as HTTP integrations. Lambda proxy (AWS_PROXY) integrations do not need it, as Lambda already receives the full request path. The mapping is added even when the integration URI has no {proxy}.

Mock integrations are left unchanged. When the proxy is added to the root resource, the method that is also added to the root has no {proxy} path parameter, so it is not configured.

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.

parentIResourceparentIResourceparentIResourceParentIResourceParentIResource required #
The parent resource of this resource.

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