agent-claw: automated task changes

This commit is contained in:
daniel
2026-05-06 18:55:16 -05:00
parent 38905bb1e9
commit 732b00fb66
8494 changed files with 2018127 additions and 4 deletions

View File

@@ -0,0 +1,13 @@
{
"targets": {
"java": {
"package": "software.amazon.awscdk.services.apigateway"
},
"dotnet": {
"namespace": "Amazon.CDK.AWS.APIGateway"
},
"python": {
"module": "aws_cdk.aws_apigateway"
}
}
}

1787
cdk/node_modules/aws-cdk-lib/aws-apigateway/README.md generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,42 @@
{
"resources": {
"ApiKey": {
"grants": {
"read": {
"actions": [
"apigateway:GET"
],
"docSummary": "Permits the IAM principal all read operations through this key"
},
"write": {
"actions": [
"apigateway:POST",
"apigateway:PUT",
"apigateway:PATCH",
"apigateway:DELETE"
],
"docSummary": "Permits the IAM principal all write operations through this key"
},
"readWrite": {
"actions": [
"apigateway:GET",
"apigateway:POST",
"apigateway:PUT",
"apigateway:PATCH",
"apigateway:DELETE"
],
"docSummary": "Permits the IAM principal all read and write operations through this key"
}
}
},
"Method": {
"grants": {
"execute": {
"actions": [
"execute-api:Invoke"
]
}
}
}
}
}

View File

@@ -0,0 +1 @@
export * from './lib';

1
cdk/node_modules/aws-cdk-lib/aws-apigateway/index.js generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,493 @@
import type { IStageRef } from './apigateway.generated';
import type * as firehose from '../../aws-kinesisfirehose';
import type { ILogGroupRef } from '../../interfaces/generated/aws-logs-interfaces.generated';
/**
* Access log destination for a RestApi Stage.
*/
export interface IAccessLogDestination {
/**
* Binds this destination to the RestApi Stage.
*/
bind(stage: IStageRef): AccessLogDestinationConfig;
}
/**
* Options when binding a log destination to a RestApi Stage.
*/
export interface AccessLogDestinationConfig {
/**
* The Amazon Resource Name (ARN) of the destination resource
*/
readonly destinationArn: string;
}
/**
* Use CloudWatch Logs as a custom access log destination for API Gateway.
*/
export declare class LogGroupLogDestination implements IAccessLogDestination {
private readonly logGroup;
constructor(logGroup: ILogGroupRef);
/**
* Binds this destination to the CloudWatch Logs.
*/
bind(_stage: IStageRef): AccessLogDestinationConfig;
}
/**
* Use a Firehose delivery stream as a custom access log destination for API Gateway.
*/
export declare class FirehoseLogDestination implements IAccessLogDestination {
private readonly stream;
constructor(stream: firehose.CfnDeliveryStream);
/**
* Binds this destination to the Firehose delivery stream.
*/
bind(stage: IStageRef): AccessLogDestinationConfig;
}
/**
* $context variables that can be used to customize access log pattern.
*/
export declare class AccessLogField {
/**
* The API callers AWS account ID.
* @deprecated Use `contextCallerAccountId` or `contextOwnerAccountId` instead
*/
static contextAccountId(): string;
/**
* The API callers AWS account ID.
*/
static contextCallerAccountId(): string;
/**
* The API owner's AWS account ID.
*/
static contextOwnerAccountId(): string;
/**
* The identifier API Gateway assigns to your API.
*/
static contextApiId(): string;
/**
* A property of the claims returned from the Amazon Cognito user pool after the method caller is successfully authenticated.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-integrate-with-cognito.html
*
* @param property A property key of the claims.
*/
static contextAuthorizerClaims(property: string): string;
/**
* The principal user identification associated with the token sent by the client and returned
* from an API Gateway Lambda authorizer (formerly known as a custom authorizer).
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
*/
static contextAuthorizerPrincipalId(): string;
/**
* The stringified value of the specified key-value pair of the `context` map returned from an API Gateway Lambda authorizer function.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
* @param property key of the context map.
*/
static contextAuthorizer(property: string): string;
/**
* The AWS endpoint's request ID.
*/
static contextAwsEndpointRequestId(): string;
/**
* The full domain name used to invoke the API. This should be the same as the incoming `Host` header.
*/
static contextDomainName(): string;
/**
* The first label of the `$context.domainName`. This is often used as a caller/customer identifier.
*/
static contextDomainPrefix(): string;
/**
* A string containing an API Gateway error message.
*/
static contextErrorMessage(): string;
/**
* The quoted value of $context.error.message, namely "$context.error.message".
*/
static contextErrorMessageString(): string;
/**
* A type of GatewayResponse. This variable can only be used for simple variable substitution in a GatewayResponse body-mapping template,
* which is not processed by the Velocity Template Language engine, and in access logging.
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-logging.html
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/customize-gateway-responses.html
*/
static contextErrorResponseType(): string;
/**
* A string containing a detailed validation error message.
*/
static contextErrorValidationErrorString(): string;
/**
* The extended ID that API Gateway assigns to the API request, which contains more useful information for debugging/troubleshooting.
*/
static contextExtendedRequestId(): string;
/**
* The HTTP method used. Valid values include: `DELETE`, `GET`, `HEAD`, `OPTIONS`, `PATCH`, `POST`, and `PUT`.
*/
static contextHttpMethod(): string;
/**
* The AWS account ID associated with the request.
*/
static contextIdentityAccountId(): string;
/**
* For API methods that require an API key, this variable is the API key associated with the method request.
* For methods that don't require an API key, this variable is
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html
*/
static contextIdentityApiKey(): string;
/**
* The API key ID associated with an API request that requires an API key.
*/
static contextIdentityApiKeyId(): string;
/**
* The principal identifier of the caller making the request.
*/
static contextIdentityCaller(): string;
/**
* The Amazon Cognito authentication provider used by the caller making the request.
* Available only if the request was signed with Amazon Cognito credentials.
* @see https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-identity.html
*/
static contextIdentityCognitoAuthenticationProvider(): string;
/**
* The Amazon Cognito authentication type of the caller making the request.
* Available only if the request was signed with Amazon Cognito credentials.
*/
static contextIdentityCognitoAuthenticationType(): string;
/**
* The Amazon Cognito identity ID of the caller making the request. Available only if the request was signed with Amazon Cognito credentials.
*/
static contextIdentityCognitoIdentityId(): string;
/**
* The Amazon Cognito identity pool ID of the caller making the request.
* Available only if the request was signed with Amazon Cognito credentials.
*/
static contextIdentityCognitoIdentityPoolId(): string;
/**
* The AWS organization ID.
*/
static contextIdentityPrincipalOrgId(): string;
/**
* The source IP address of the TCP connection making the request to API Gateway.
* Warning: You should not trust this value if there is any chance that the `X-Forwarded-For` header could be forged.
*/
static contextIdentitySourceIp(): string;
/**
* The PEM-encoded client certificate that the client presented during mutual TLS authentication.
* Present when a client accesses an API by using a custom domain name that has mutual TLS enabled.
* Present only in access logs if mutual TLS authentication fails.
*/
static contextIdentityClientCertPem(): string;
/**
* The distinguished name of the subject of the certificate that a client presents.
* Present when a client accesses an API by using a custom domain name that has mutual TLS enabled.
* Present only in access logs if mutual TLS authentication fails.
*/
static contextIdentityClientCertSubjectDN(): string;
/**
* The distinguished name of the issuer of the certificate that a client presents.
* Present when a client accesses an API by using a custom domain name that has mutual TLS enabled.
* Present only in access logs if mutual TLS authentication fails.
*/
static contextIdentityClientCertIssunerDN(): string;
/**
* The serial number of the certificate.
* Present when a client accesses an API by using a custom domain name that has mutual TLS enabled.
* Present only in access logs if mutual TLS authentication fails.
*/
static contextIdentityClientCertSerialNumber(): string;
/**
* The date before which the certificate is invalid.
* Present when a client accesses an API by using a custom domain name that has mutual TLS enabled.
* Present only in access logs if mutual TLS authentication fails.
*/
static contextIdentityClientCertValidityNotBefore(): string;
/**
* The date after which the certificate is invalid.
* Present when a client accesses an API by using a custom domain name that has mutual TLS enabled.
* Present only in access logs if mutual TLS authentication fails.
*/
static contextIdentityClientCertValidityNotAfter(): string;
/**
* The principal identifier of the user making the request. Used in Lambda authorizers.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html
*/
static contextIdentityUser(): string;
/**
* The User-Agent header of the API caller.
*/
static contextIdentityUserAgent(): string;
/**
* The Amazon Resource Name (ARN) of the effective user identified after authentication.
* @see https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html
*/
static contextIdentityUserArn(): string;
/**
* The request path.
* For example, for a non-proxy request URL of https://{rest-api-id.execute-api.{region}.amazonaws.com/{stage}/root/child,
* this value is /{stage}/root/child.
*/
static contextPath(): string;
/**
* The request protocol, for example, HTTP/1.1.
*/
static contextProtocol(): string;
/**
* The ID that API Gateway assigns to the API request.
*/
static contextRequestId(): string;
/**
* The request header override.
* If this parameter is defined, it contains the headers to be used instead of the HTTP Headers that are defined in the Integration Request pane.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-override-request-response-parameters.html
*/
static contextRequestOverrideHeader(headerName: string): string;
/**
* The request path override. If this parameter is defined,
* it contains the request path to be used instead of the URL Path Parameters that are defined in the Integration Request pane.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-override-request-response-parameters.html
*/
static contextRequestOverridePath(pathName: string): string;
/**
* The request query string override.
* If this parameter is defined, it contains the request query strings to be used instead
* of the URL Query String Parameters that are defined in the Integration Request pane.
*/
static contextRequestOverrideQuerystring(querystringName: string): string;
/**
* The response header override.
* If this parameter is defined, it contains the header to be returned instead of the Response header
* that is defined as the Default mapping in the Integration Response pane.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-override-request-response-parameters.html
*/
static contextResponseOverrideHeader(headerName: string): string;
/**
* The response status code override.
* If this parameter is defined, it contains the status code to be returned instead of the Method response status
* that is defined as the Default mapping in the Integration Response pane.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-override-request-response-parameters.html
*/
static contextResponseOverrideStatus(): string;
/**
* The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm).
*/
static contextRequestTime(): string;
/**
* The Epoch-formatted request time.
*/
static contextRequestTimeEpoch(): string;
/**
* The identifier that API Gateway assigns to your resource.
*/
static contextResourceId(): string;
/**
* The path to your resource.
* For example, for the non-proxy request URI of `https://{rest-api-id.execute-api.{region}.amazonaws.com/{stage}/root/child`,
* The $context.resourcePath value is `/root/child`.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-step-by-step.html
*/
static contextResourcePath(): string;
/**
* The deployment stage of the API request (for example, `Beta` or `Prod`).
*/
static contextStage(): string;
/**
* The response received from AWS WAF: `WAF_ALLOW` or `WAF_BLOCK`. Will not be set if the stage is not associated with a web ACL.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-control-access-aws-waf.html
*/
static contextWafResponseCode(): string;
/**
* The complete ARN of the web ACL that is used to decide whether to allow or block the request.
* Will not be set if the stage is not associated with a web ACL.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-control-access-aws-waf.html
*/
static contextWebaclArn(): string;
/**
* The trace ID for the X-Ray trace.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-enabling-xray.html
*/
static contextXrayTraceId(): string;
/**
* The authorizer latency in ms.
*/
static contextAuthorizerIntegrationLatency(): string;
/**
* The integration latency in ms.
*/
static contextIntegrationLatency(): string;
/**
* For Lambda proxy integration, this parameter represents the status code returned from AWS Lambda,
* not from the backend Lambda function.
*/
static contextIntegrationStatus(): string;
/**
* The response latency in ms.
*/
static contextResponseLatency(): string;
/**
* The response payload length.
*/
static contextResponseLength(): string;
/**
* The method response status.
*/
static contextStatus(): string;
/**
* The authorization error message.
*/
static contextAuthorizeError(): string;
/**
* The authorization latency in ms.
*/
static contextAuthorizeLatency(): string;
/**
* The status code returned from an authorization attempt.
*/
static contextAuthorizeStatus(): string;
/**
* The error message returned from an authorizer.
*/
static contextAuthorizerError(): string;
/**
* The status code returned from a Lambda authorizer.
*/
static contextAuthorizerIntegrationStatus(): string;
/**
* The authorizer latency in ms.
*/
static contextAuthorizerLatency(): string;
/**
* The AWS endpoint's request ID.
*/
static contextAuthorizerRequestId(): string;
/**
* The status code returned from an authorizer.
*/
static contextAuthorizerStatus(): string;
/**
* The error message returned from an authentication attempt.
*/
static contextAuthenticateError(): string;
/**
* The authentication latency in ms.
*/
static contextAuthenticateLatency(): string;
/**
* The status code returned from an authentication attempt.
*/
static contextAuthenticateStatus(): string;
/**
* The path for an API mapping that an incoming request matched.
* Applicable when a client uses a custom domain name to access an API. For example if a client sends a request to
* https://api.example.com/v1/orders/1234, and the request matches the API mapping with the path v1/orders, the value is v1/orders.
* @see https://docs.aws.amazon.com/en_jp/apigateway/latest/developerguide/rest-api-mappings.html
*/
static contextCustomDomainBasePathMatched(): string;
/**
* A string that contains an integration error message.
*/
static contextIntegrationErrorMessage(): string;
/**
* The error message returned from AWS WAF.
*/
static contextWafError(): string;
/**
* The AWS WAF latency in ms.
*/
static contextWafLatency(): string;
/**
* The status code returned from AWS WAF.
*/
static contextWafStatus(): string;
/**
* The event type: CONNECT, MESSAGE, or DISCONNECT.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/websocket-api-logging.html
*/
static contextEventType(): string;
/**
* The selected route key.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/websocket-api-logging.html
*/
static contextRouteKey(): string;
/**
* A unique ID for the connection that can be used to make a callback to the client.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/websocket-api-logging.html
*/
static contextConnectionId(): string;
}
/**
* Properties for controlling items output in JSON standard format
*/
export interface JsonWithStandardFieldProps {
/**
* If this flag is enabled, the source IP of request will be output to the log
*/
readonly ip: boolean;
/**
* If this flag is enabled, the principal identifier of the caller will be output to the log
*/
readonly caller: boolean;
/**
* If this flag is enabled, the principal identifier of the user will be output to the log
*/
readonly user: boolean;
/**
* If this flag is enabled, the CLF-formatted request time((dd/MMM/yyyy:HH:mm:ss +-hhmm) will be output to the log
*/
readonly requestTime: boolean;
/**
* If this flag is enabled, the http method will be output to the log
*/
readonly httpMethod: boolean;
/**
* If this flag is enabled, the path to your resource will be output to the log
*/
readonly resourcePath: boolean;
/**
* If this flag is enabled, the method response status will be output to the log
*/
readonly status: boolean;
/**
* If this flag is enabled, the request protocol will be output to the log
*/
readonly protocol: boolean;
/**
* If this flag is enabled, the response payload length will be output to the log
*/
readonly responseLength: boolean;
}
/**
* factory methods for access log format.
*/
export declare class AccessLogFormat {
/**
* Custom log format.
* You can create any log format string. You can easily get the $ context variable by using the methods of AccessLogField.
* @example
*
* apigateway.AccessLogFormat.custom(JSON.stringify({
* requestId: apigateway.AccessLogField.contextRequestId(),
* sourceIp: apigateway.AccessLogField.contextIdentitySourceIp(),
* method: apigateway.AccessLogField.contextHttpMethod(),
* userContext: {
* sub: apigateway.AccessLogField.contextAuthorizerClaims('sub'),
* email: apigateway.AccessLogField.contextAuthorizerClaims('email')
* }
* }))
*/
static custom(format: string): AccessLogFormat;
/**
* Generate Common Log Format.
*/
static clf(): AccessLogFormat;
/**
* Access log will be produced in the JSON format with a set of fields most useful in the access log. All fields are turned on by default with the
* option to turn off specific fields.
*/
static jsonWithStandardFields(fields?: JsonWithStandardFieldProps): AccessLogFormat;
/**
* A API Gateway custom access log format
*/
private readonly format;
constructor(format: string);
/**
* Output a format string to be used with CloudFormation.
*/
toString(): string;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,139 @@
import type { Construct } from 'constructs';
import type { IRestApiRef } from './apigateway.generated';
import type * as s3 from '../../aws-s3';
import * as s3_assets from '../../aws-s3-assets';
/**
* Represents an OpenAPI definition asset.
*/
export declare abstract class ApiDefinition {
/**
* Creates an API definition from a specification file in an S3 bucket
*/
static fromBucket(bucket: s3.IBucket, key: string, objectVersion?: string): S3ApiDefinition;
/**
* Create an API definition from an inline object. The inline object must follow the
* schema of OpenAPI 2.0 or OpenAPI 3.0
*
* @example
*
* apigateway.ApiDefinition.fromInline({
* openapi: '3.0.2',
* paths: {
* '/pets': {
* get: {
* 'responses': {
* 200: {
* content: {
* 'application/json': {
* schema: {
* $ref: '#/components/schemas/Empty',
* },
* },
* },
* },
* },
* 'x-amazon-apigateway-integration': {
* responses: {
* default: {
* statusCode: '200',
* },
* },
* requestTemplates: {
* 'application/json': '{"statusCode": 200}',
* },
* passthroughBehavior: 'when_no_match',
* type: 'mock',
* },
* },
* },
* },
* components: {
* schemas: {
* Empty: {
* title: 'Empty Schema',
* type: 'object',
* },
* },
* },
* });
*/
static fromInline(definition: any): InlineApiDefinition;
/**
* Loads the API specification from a local disk asset.
*/
static fromAsset(file: string, options?: s3_assets.AssetOptions): AssetApiDefinition;
/**
* Called when the specification is initialized to allow this object to bind
* to the stack, add resources and have fun.
*
* @param scope The binding scope. Don't be smart about trying to down-cast or
* assume it's initialized. You may just use it as a construct scope.
*/
abstract bind(scope: Construct): ApiDefinitionConfig;
/**
* Called after the CFN RestApi resource has been created to allow the Api
* Definition to bind to it. Specifically it's required to allow assets to add
* metadata for tooling like SAM CLI to be able to find their origins.
*/
bindAfterCreate(_scope: Construct, _restApi: IRestApiRef): void;
}
/**
* S3 location of the API definition file
*/
export interface ApiDefinitionS3Location {
/** The S3 bucket */
readonly bucket: string;
/** The S3 key */
readonly key: string;
/**
* An optional version
* @default - latest version
*/
readonly version?: string;
}
/**
* Post-Binding Configuration for a CDK construct
*/
export interface ApiDefinitionConfig {
/**
* The location of the specification in S3 (mutually exclusive with `inlineDefinition`).
*
* @default - API definition is not an S3 location
*/
readonly s3Location?: ApiDefinitionS3Location;
/**
* Inline specification (mutually exclusive with `s3Location`).
*
* @default - API definition is not defined inline
*/
readonly inlineDefinition?: any;
}
/**
* OpenAPI specification from an S3 archive.
*/
export declare class S3ApiDefinition extends ApiDefinition {
private key;
private objectVersion?;
private bucketName;
constructor(bucket: s3.IBucketRef, key: string, objectVersion?: string | undefined);
bind(_scope: Construct): ApiDefinitionConfig;
}
/**
* OpenAPI specification from an inline JSON object.
*/
export declare class InlineApiDefinition extends ApiDefinition {
private definition;
constructor(definition: any);
bind(_scope: Construct): ApiDefinitionConfig;
}
/**
* OpenAPI specification from a local file.
*/
export declare class AssetApiDefinition extends ApiDefinition {
private readonly path;
private readonly options;
private asset?;
constructor(path: string, options?: s3_assets.AssetOptions);
bind(scope: Construct): ApiDefinitionConfig;
bindAfterCreate(scope: Construct, restApi: IRestApiRef): void;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AssetApiDefinition=exports.InlineApiDefinition=exports.S3ApiDefinition=exports.ApiDefinition=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var constructs_1=()=>{var tmp=require("constructs");return constructs_1=()=>tmp,tmp},s3_assets=()=>{var tmp=require("../../aws-s3-assets");return s3_assets=()=>tmp,tmp},errors_1=()=>{var tmp=require("../../core/lib/errors");return errors_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp},cxapi=()=>{var tmp=require("../../cx-api");return cxapi=()=>tmp,tmp};class ApiDefinition{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.ApiDefinition",version:"2.252.0"};static fromBucket(bucket,key,objectVersion){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_s3_IBucket(bucket)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromBucket),error}return new S3ApiDefinition(bucket,key,objectVersion)}static fromInline(definition){return new InlineApiDefinition(definition)}static fromAsset(file,options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_s3_assets_AssetOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromAsset),error}return new AssetApiDefinition(file,options)}bindAfterCreate(_scope,_restApi){try{jsiiDeprecationWarnings().aws_cdk_lib_interfaces_aws_apigateway_IRestApiRef(_restApi)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bindAfterCreate),error}}}exports.ApiDefinition=ApiDefinition;class S3ApiDefinition extends ApiDefinition{key;objectVersion;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.S3ApiDefinition",version:"2.252.0"};bucketName;constructor(bucket,key,objectVersion){super(),this.key=key,this.objectVersion=objectVersion;try{jsiiDeprecationWarnings().aws_cdk_lib_interfaces_aws_s3_IBucketRef(bucket)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,S3ApiDefinition),error}if(!bucket.bucketRef.bucketName)throw new(errors_1()).ValidationError((0,literal_string_1().lit)`BucketNameUndefinedProvidedBucket`,"bucketName is undefined for the provided bucket",bucket);this.bucketName=bucket.bucketRef.bucketName}bind(_scope){return{s3Location:{bucket:this.bucketName,key:this.key,version:this.objectVersion}}}}exports.S3ApiDefinition=S3ApiDefinition;class InlineApiDefinition extends ApiDefinition{definition;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.InlineApiDefinition",version:"2.252.0"};constructor(definition){if(super(),this.definition=definition,typeof definition!="object")throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`ShouldBeDefinitionShouldType`,"definition should be of type object");if(Object.keys(definition).length===0)throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`JsonDefinitionCannotEmpty`,"JSON definition cannot be empty")}bind(_scope){return{inlineDefinition:this.definition}}}exports.InlineApiDefinition=InlineApiDefinition;class AssetApiDefinition extends ApiDefinition{path;options;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.AssetApiDefinition",version:"2.252.0"};asset;constructor(path,options={}){super(),this.path=path,this.options=options;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_s3_assets_AssetOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,AssetApiDefinition),error}}bind(scope){if(this.asset===void 0&&(this.asset=new(s3_assets()).Asset(scope,"APIDefinition",{path:this.path,...this.options})),this.asset.isZipArchive)throw new(errors_1()).ValidationError((0,literal_string_1().lit)`AssetCannotZipFileDirectory`,`Asset cannot be a .zip file or a directory (${this.path})`,scope);return{s3Location:{bucket:this.asset.s3BucketName,key:this.asset.s3ObjectKey}}}bindAfterCreate(scope,restApi){try{jsiiDeprecationWarnings().aws_cdk_lib_interfaces_aws_apigateway_IRestApiRef(restApi)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bindAfterCreate),error}if(!scope.node.tryGetContext(cxapi().ASSET_RESOURCE_METADATA_ENABLED_CONTEXT))return;if(!this.asset)throw new(errors_1()).ValidationError((0,literal_string_1().lit)`BindResourceCalledBind`,"bindToResource() must be called after bind()",scope);const child=constructs_1().Node.of(restApi).defaultChild;child.addMetadata(cxapi().ASSET_RESOURCE_METADATA_PATH_KEY,this.asset.assetPath),child.addMetadata(cxapi().ASSET_RESOURCE_METADATA_PROPERTY_KEY,"BodyS3Location")}}exports.AssetApiDefinition=AssetApiDefinition;

View File

@@ -0,0 +1,182 @@
import type { Construct } from 'constructs';
import { ApiKeyGrants } from './apigateway-grants.generated';
import type { ApiKeyReference, IApiKeyRef } from './apigateway.generated';
import type { ResourceOptions } from './resource';
import type { IRestApi } from './restapi';
import type { IStage } from './stage';
import type { QuotaSettings, ThrottleSettings, UsagePlanPerApiStage } from './usage-plan';
import type * as iam from '../../aws-iam';
import type { IResource as IResourceBase } from '../../core';
import { Resource } from '../../core';
/**
* API keys are alphanumeric string values that you distribute to
* app developer customers to grant access to your API
*/
export interface IApiKey extends IResourceBase, IApiKeyRef {
/**
* The API key ID.
* @attribute
*/
readonly keyId: string;
/**
* The API key ARN.
*/
readonly keyArn: string;
}
/**
* The options for creating an API Key.
*/
export interface ApiKeyOptions extends ResourceOptions {
/**
* A name for the API key. If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the API key name.
* @link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-name
* @default automically generated name
*/
readonly apiKeyName?: string;
/**
* The value of the API key. Must be at least 20 characters long.
* @link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-value
* @default none
*/
readonly value?: string;
/**
* A description of the purpose of the API key.
* @link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-description
* @default none
*/
readonly description?: string;
}
/**
* ApiKey Properties.
*/
export interface ApiKeyProps extends ApiKeyOptions {
/**
* A list of resources this api key is associated with.
* @default none
* @deprecated - use `stages` instead
*/
readonly resources?: IRestApi[];
/**
* A list of Stages this api key is associated with.
*
* @default - the api key is not associated with any stages
*/
readonly stages?: IStage[];
/**
* An AWS Marketplace customer identifier to use when integrating with the AWS SaaS Marketplace.
* @link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-customerid
* @default none
*/
readonly customerId?: string;
/**
* Indicates whether the API key can be used by clients.
* @link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-enabled
* @default true
*/
readonly enabled?: boolean;
/**
* Specifies whether the key identifier is distinct from the created API key value.
* @link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-generatedistinctid
* @default false
*/
readonly generateDistinctId?: boolean;
}
/**
* Base implementation that is common to the various implementations of IApiKey
*/
declare abstract class ApiKeyBase extends Resource implements IApiKey {
abstract readonly keyId: string;
abstract readonly keyArn: string;
/**
* Collection of grant methods for an ApiKey
*/
readonly grants: ApiKeyGrants;
/**
* Permits the IAM principal all read operations through this key
*
* The use of this method is discouraged. Please use `grants.read()` instead.
*
* [disable-awslint:no-grants]
*
* @param grantee The principal to grant access to
*/
grantRead(grantee: iam.IGrantable): iam.Grant;
/**
* Permits the IAM principal all write operations through this key
*
* The use of this method is discouraged. Please use `grants.write()` instead.
*
* [disable-awslint:no-grants]
*
* @param grantee The principal to grant access to
*/
grantWrite(grantee: iam.IGrantable): iam.Grant;
/**
* Permits the IAM principal all read and write operations through this key
*
* The use of this method is discouraged. Please use `grants.readWrite()` instead.
*
* [disable-awslint:no-grants]
*
* @param grantee The principal to grant access to
*/
grantReadWrite(grantee: iam.IGrantable): iam.Grant;
get apiKeyRef(): ApiKeyReference;
}
/**
* An API Gateway ApiKey.
*
* An ApiKey can be distributed to API clients that are executing requests
* for Method resources that require an Api Key.
*/
export declare class ApiKey extends ApiKeyBase {
/**
* Uniquely identifies this class.
*/
static readonly PROPERTY_INJECTION_ID: string;
/**
* Import an ApiKey by its Id
*/
static fromApiKeyId(scope: Construct, id: string, apiKeyId: string): IApiKey;
readonly keyId: string;
readonly keyArn: string;
constructor(scope: Construct, id: string, props?: ApiKeyProps);
private renderStageKeys;
}
/**
* RateLimitedApiKey properties.
*/
export interface RateLimitedApiKeyProps extends ApiKeyProps {
/**
* API Stages to be associated with the RateLimitedApiKey.
* If you already prepared UsagePlan resource explicitly, you should use `stages` property.
* If you prefer to prepare UsagePlan resource implicitly via RateLimitedApiKey,
* or you should specify throttle settings at each stage individually, you should use `apiStages` property.
*
* @default none
*/
readonly apiStages?: UsagePlanPerApiStage[];
/**
* Number of requests clients can make in a given time period.
* @default none
*/
readonly quota?: QuotaSettings;
/**
* Overall throttle settings for the API.
* @default none
*/
readonly throttle?: ThrottleSettings;
}
/**
* An API Gateway ApiKey, for which a rate limiting configuration can be specified.
*
* @resource AWS::ApiGateway::ApiKey
*/
export declare class RateLimitedApiKey extends ApiKeyBase {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
readonly keyId: string;
readonly keyArn: string;
constructor(scope: Construct, id: string, props?: RateLimitedApiKeyProps);
}
export {};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,242 @@
export interface MetricWithDims<D> {
readonly namespace: string;
readonly metricName: string;
readonly statistic: string;
readonly dimensionsMap: D;
}
export declare class ApiGatewayMetrics {
static _4XxErrorSum(this: void, dimensions: {
ApiName: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Stage: string;
}>;
static _4XxErrorSum(this: void, dimensions: {
ApiName: string;
}): MetricWithDims<{
ApiName: string;
}>;
static _4XxErrorSum(this: void, dimensions: {
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}>;
static _4XxErrorSum(this: void, dimensions: {
ApiId: string;
Stage: string;
}): MetricWithDims<{
ApiId: string;
Stage: string;
}>;
static _5XxErrorSum(this: void, dimensions: {
ApiName: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Stage: string;
}>;
static _5XxErrorSum(this: void, dimensions: {
ApiName: string;
}): MetricWithDims<{
ApiName: string;
}>;
static _5XxErrorSum(this: void, dimensions: {
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}>;
static _5XxErrorSum(this: void, dimensions: {
ApiId: string;
Stage: string;
}): MetricWithDims<{
ApiId: string;
Stage: string;
}>;
static cacheHitCountSum(this: void, dimensions: {
ApiName: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Stage: string;
}>;
static cacheHitCountSum(this: void, dimensions: {
ApiName: string;
}): MetricWithDims<{
ApiName: string;
}>;
static cacheHitCountSum(this: void, dimensions: {
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}>;
static cacheHitCountSum(this: void, dimensions: {
ApiId: string;
Stage: string;
}): MetricWithDims<{
ApiId: string;
Stage: string;
}>;
static cacheMissCountSum(this: void, dimensions: {
ApiName: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Stage: string;
}>;
static cacheMissCountSum(this: void, dimensions: {
ApiName: string;
}): MetricWithDims<{
ApiName: string;
}>;
static cacheMissCountSum(this: void, dimensions: {
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}>;
static cacheMissCountSum(this: void, dimensions: {
ApiId: string;
Stage: string;
}): MetricWithDims<{
ApiId: string;
Stage: string;
}>;
static countSum(this: void, dimensions: {
ApiName: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Stage: string;
}>;
static countSum(this: void, dimensions: {
ApiName: string;
}): MetricWithDims<{
ApiName: string;
}>;
static countSum(this: void, dimensions: {
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}>;
static countSum(this: void, dimensions: {
ApiId: string;
}): MetricWithDims<{
ApiId: string;
}>;
static countSum(this: void, dimensions: {
ApiId: string;
Stage: string;
}): MetricWithDims<{
ApiId: string;
Stage: string;
}>;
static integrationLatencyAverage(this: void, dimensions: {
ApiName: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Stage: string;
}>;
static integrationLatencyAverage(this: void, dimensions: {
ApiName: string;
}): MetricWithDims<{
ApiName: string;
}>;
static integrationLatencyAverage(this: void, dimensions: {
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}>;
static integrationLatencyAverage(this: void, dimensions: {
ApiId: string;
}): MetricWithDims<{
ApiId: string;
}>;
static integrationLatencyAverage(this: void, dimensions: {
ApiId: string;
Stage: string;
Route: string;
}): MetricWithDims<{
ApiId: string;
Stage: string;
Route: string;
}>;
static integrationLatencyAverage(this: void, dimensions: {
ApiId: string;
Stage: string;
}): MetricWithDims<{
ApiId: string;
Stage: string;
}>;
static latencyAverage(this: void, dimensions: {
ApiName: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Stage: string;
}>;
static latencyAverage(this: void, dimensions: {
ApiName: string;
}): MetricWithDims<{
ApiName: string;
}>;
static latencyAverage(this: void, dimensions: {
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}): MetricWithDims<{
ApiName: string;
Method: string;
Resource: string;
Stage: string;
}>;
static latencyAverage(this: void, dimensions: {
ApiId: string;
}): MetricWithDims<{
ApiId: string;
}>;
static latencyAverage(this: void, dimensions: {
ApiId: string;
Stage: string;
}): MetricWithDims<{
ApiId: string;
Stage: string;
}>;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApiGatewayMetrics=void 0;class ApiGatewayMetrics{static _4XxErrorSum(dimensions){return{namespace:"AWS/ApiGateway",metricName:"4XXError",dimensionsMap:dimensions,statistic:"Sum"}}static _5XxErrorSum(dimensions){return{namespace:"AWS/ApiGateway",metricName:"5XXError",dimensionsMap:dimensions,statistic:"Sum"}}static cacheHitCountSum(dimensions){return{namespace:"AWS/ApiGateway",metricName:"CacheHitCount",dimensionsMap:dimensions,statistic:"Sum"}}static cacheMissCountSum(dimensions){return{namespace:"AWS/ApiGateway",metricName:"CacheMissCount",dimensionsMap:dimensions,statistic:"Sum"}}static countSum(dimensions){return{namespace:"AWS/ApiGateway",metricName:"Count",dimensionsMap:dimensions,statistic:"Sum"}}static integrationLatencyAverage(dimensions){return{namespace:"AWS/ApiGateway",metricName:"IntegrationLatency",dimensionsMap:dimensions,statistic:"Average"}}static latencyAverage(dimensions){return{namespace:"AWS/ApiGateway",metricName:"Latency",dimensionsMap:dimensions,statistic:"Average"}}}exports.ApiGatewayMetrics=ApiGatewayMetrics;

View File

@@ -0,0 +1,30 @@
import * as apigateway from "./apigateway.generated";
import * as iam from "../../aws-iam";
import * as cdk from "../../core/lib";
/**
* Collection of grant methods for a IApiKeyRef
*/
export declare class ApiKeyGrants {
/**
* Creates grants for ApiKeyGrants
*/
static fromApiKey(resource: apigateway.IApiKeyRef): ApiKeyGrants;
protected readonly resource: apigateway.IApiKeyRef;
private constructor();
/**
* Grant the given identity custom permissions
*/
actions(grantee: iam.IGrantable, actions: Array<string>, options?: cdk.PermissionsOptions): iam.Grant;
/**
* Permits the IAM principal all read operations through this key
*/
read(grantee: iam.IGrantable): iam.Grant;
/**
* Permits the IAM principal all write operations through this key
*/
write(grantee: iam.IGrantable): iam.Grant;
/**
* Permits the IAM principal all read and write operations through this key
*/
readWrite(grantee: iam.IGrantable): iam.Grant;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApiKeyGrants=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var apigateway=()=>{var tmp=require("./apigateway.generated");return apigateway=()=>tmp,tmp},iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp};class ApiKeyGrants{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.ApiKeyGrants",version:"2.252.0"};static fromApiKey(resource){try{jsiiDeprecationWarnings().aws_cdk_lib_interfaces_aws_apigateway_IApiKeyRef(resource)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromApiKey),error}return new ApiKeyGrants({resource})}resource;constructor(props){this.resource=props.resource}actions(grantee,actions,options={}){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IGrantable(grantee),jsiiDeprecationWarnings().aws_cdk_lib_PermissionsOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.actions),error}return iam().Grant.addToPrincipal({actions,grantee,resourceArns:options.resourceArns??[apigateway().CfnApiKey.arnForApiKey(this.resource)]})}read(grantee){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IGrantable(grantee)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.read),error}const actions=["apigateway:GET"];return this.actions(grantee,actions,{})}write(grantee){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IGrantable(grantee)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.write),error}const actions=["apigateway:POST","apigateway:PUT","apigateway:PATCH","apigateway:DELETE"];return this.actions(grantee,actions,{})}readWrite(grantee){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IGrantable(grantee)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.readWrite),error}const actions=["apigateway:GET","apigateway:POST","apigateway:PUT","apigateway:PATCH","apigateway:DELETE"];return this.actions(grantee,actions,{})}}exports.ApiKeyGrants=ApiKeyGrants;

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,36 @@
import type { Construct } from 'constructs';
import { AuthorizationType } from './method';
import type { IRestApi } from './restapi';
import type { ResourceProps } from '../../core';
import { Resource } from '../../core';
/**
* Base class for all custom authorizers
*/
export declare abstract class Authorizer extends Resource implements IAuthorizer {
/**
* Return whether the given object is an Authorizer.
*/
static isAuthorizer(x: any): x is Authorizer;
abstract readonly authorizerId: string;
readonly authorizationType?: AuthorizationType;
constructor(scope: Construct, id: string, props?: ResourceProps);
/**
* Called when the authorizer is used from a specific REST API.
* @internal
*/
abstract _attachToApi(restApi: IRestApi): void;
}
/**
* Represents an API Gateway authorizer.
*/
export interface IAuthorizer {
/**
* The authorizer ID.
* @attribute
*/
readonly authorizerId: string;
/**
* The authorization type of this authorizer.
*/
readonly authorizationType?: AuthorizationType;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Authorizer=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var method_1=()=>{var tmp=require("./method");return method_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp};const AUTHORIZER_SYMBOL=Symbol.for("@aws-cdk/aws-apigateway.Authorizer");class Authorizer extends core_1().Resource{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.Authorizer",version:"2.252.0"};static isAuthorizer(x){return x!==null&&typeof x=="object"&&AUTHORIZER_SYMBOL in x}authorizationType=method_1().AuthorizationType.CUSTOM;constructor(scope,id,props){super(scope,id,props);try{jsiiDeprecationWarnings().aws_cdk_lib_ResourceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Authorizer),error}Object.defineProperty(this,AUTHORIZER_SYMBOL,{value:!0})}}exports.Authorizer=Authorizer;

View File

@@ -0,0 +1,73 @@
import type { Construct } from 'constructs';
import type * as cognito from '../../../aws-cognito';
import type { Duration } from '../../../core';
import type { IAuthorizer } from '../authorizer';
import { Authorizer } from '../authorizer';
import { AuthorizationType } from '../method';
import type { IRestApi } from '../restapi';
/**
* Properties for CognitoUserPoolsAuthorizer
*/
export interface CognitoUserPoolsAuthorizerProps {
/**
* An optional human friendly name for the authorizer. Note that, this is not the primary identifier of the authorizer.
*
* @default - the unique construct ID
*/
readonly authorizerName?: string;
/**
* The user pools to associate with this authorizer.
*/
readonly cognitoUserPools: cognito.IUserPool[];
/**
* How long APIGateway should cache the results. Max 1 hour.
* Disable caching by setting this to 0.
*
* @default Duration.minutes(5)
*/
readonly resultsCacheTtl?: Duration;
/**
* The request header mapping expression for the bearer token. This is typically passed as part of the header, in which case
* this should be `method.request.header.Authorizer` where `Authorizer` is the header containing the bearer token.
*
* @see https://docs.aws.amazon.com/apigateway/latest/api/API_CreateAuthorizer.html#apigw-CreateAuthorizer-request-identitySource
* @default `IdentitySource.header('Authorization')`
*/
readonly identitySource?: string;
}
/**
* Cognito user pools based custom authorizer
*
* @resource AWS::ApiGateway::Authorizer
*/
export declare class CognitoUserPoolsAuthorizer extends Authorizer implements IAuthorizer {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
/**
* The id of the authorizer.
* @attribute
*/
readonly authorizerId: string;
/**
* The ARN of the authorizer to be used in permission policies, such as IAM and resource-based grants.
* @attribute
*/
readonly authorizerArn: string;
/**
* The authorization type of this authorizer.
*/
readonly authorizationType?: AuthorizationType;
private restApiId?;
private readonly authorizerProps;
constructor(scope: Construct, id: string, props: CognitoUserPoolsAuthorizerProps);
/**
* Attaches this authorizer to a specific REST API.
* @internal
*/
_attachToApi(restApi: IRestApi): void;
/**
* Returns a token that resolves to the Rest Api Id at the time of synthesis.
* Throws an error, during token resolution, if no RestApi is attached to this authorizer.
*/
private lazyRestApiId;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,37 @@
/**
* Represents an identity source.
*
* The source can be specified either as a literal value (e.g: `Auth`) which
* cannot be blank, or as an unresolved string token.
*/
export declare class IdentitySource {
/**
* Provides a properly formatted header identity source.
* @param headerName the name of the header the `IdentitySource` will represent.
*
* @returns a header identity source.
*/
static header(headerName: string): string;
/**
* Provides a properly formatted query string identity source.
* @param queryString the name of the query string the `IdentitySource` will represent.
*
* @returns a query string identity source.
*/
static queryString(queryString: string): string;
/**
* Provides a properly formatted API Gateway stage variable identity source.
* @param stageVariable the name of the stage variable the `IdentitySource` will represent.
*
* @returns an API Gateway stage variable identity source.
*/
static stageVariable(stageVariable: string): string;
/**
* Provides a properly formatted request context identity source.
* @param context the name of the context variable the `IdentitySource` will represent.
*
* @returns a request context identity source.
*/
static context(context: string): string;
private static toString;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IdentitySource=void 0;const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var errors_1=()=>{var tmp=require("../../../core/lib/errors");return errors_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp};class IdentitySource{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.IdentitySource",version:"2.252.0"};static header(headerName){return IdentitySource.toString(headerName,"method.request.header")}static queryString(queryString){return IdentitySource.toString(queryString,"method.request.querystring")}static stageVariable(stageVariable){return IdentitySource.toString(stageVariable,"stageVariables")}static context(context){return IdentitySource.toString(context,"context")}static toString(source,type){if(!source.trim())throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`MustBeIdentitysourcesNonEmptyString`,"IdentitySources must be a non-empty string.");return`${type}.${source}`}}exports.IdentitySource=IdentitySource;

View File

@@ -0,0 +1,3 @@
export * from './lambda';
export * from './identity-source';
export * from './cognito';

View File

@@ -0,0 +1 @@
"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__exportStar=exports&&exports.__exportStar||function(m,exports2){for(var p in m)p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p)&&__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:!0});var _noFold;exports.TokenAuthorizer=void 0,Object.defineProperty(exports,_noFold="TokenAuthorizer",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lambda").TokenAuthorizer;return Object.defineProperty(exports,_noFold="TokenAuthorizer",{enumerable:!0,configurable:!0,value}),value}}),exports.RequestAuthorizer=void 0,Object.defineProperty(exports,_noFold="RequestAuthorizer",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lambda").RequestAuthorizer;return Object.defineProperty(exports,_noFold="RequestAuthorizer",{enumerable:!0,configurable:!0,value}),value}}),exports.IdentitySource=void 0,Object.defineProperty(exports,_noFold="IdentitySource",{enumerable:!0,configurable:!0,get:()=>{var value=require("./identity-source").IdentitySource;return Object.defineProperty(exports,_noFold="IdentitySource",{enumerable:!0,configurable:!0,value}),value}}),exports.CognitoUserPoolsAuthorizer=void 0,Object.defineProperty(exports,_noFold="CognitoUserPoolsAuthorizer",{enumerable:!0,configurable:!0,get:()=>{var value=require("./cognito").CognitoUserPoolsAuthorizer;return Object.defineProperty(exports,_noFold="CognitoUserPoolsAuthorizer",{enumerable:!0,configurable:!0,value}),value}});

View File

@@ -0,0 +1,155 @@
import type { Construct } from 'constructs';
import * as iam from '../../../aws-iam';
import * as lambda from '../../../aws-lambda';
import { Duration } from '../../../core';
import type { CfnAuthorizerProps } from '../apigateway.generated';
import type { IAuthorizer } from '../authorizer';
import { Authorizer } from '../authorizer';
import type { IRestApi } from '../restapi';
/**
* Base properties for all lambda authorizers
*/
export interface LambdaAuthorizerProps {
/**
* An optional human friendly name for the authorizer. Note that, this is not the primary identifier of the authorizer.
*
* @default - the unique construct ID
*/
readonly authorizerName?: string;
/**
* The handler for the authorizer lambda function.
*
* The handler must follow a very specific protocol on the input it receives
* and the output it needs to produce. API Gateway has documented the
* handler's [input specification](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-input.html)
* and [output specification](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html).
*/
readonly handler: lambda.IFunction;
/**
* How long APIGateway should cache the results. Max 1 hour.
* Disable caching by setting this to 0.
*
* @default - Duration.minutes(5)
*/
readonly resultsCacheTtl?: Duration;
/**
* An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer. The IAM role must be
* assumable by 'apigateway.amazonaws.com'.
*
* @default - A resource policy is added to the Lambda function allowing apigateway.amazonaws.com to invoke the function.
*/
readonly assumeRole?: iam.IRole;
}
declare abstract class LambdaAuthorizer extends Authorizer implements IAuthorizer {
/**
* The id of the authorizer.
* @attribute
*/
abstract readonly authorizerId: string;
/**
* The ARN of the authorizer to be used in permission policies, such as IAM and resource-based grants.
*/
abstract readonly authorizerArn: string;
/**
* The Lambda function handler that this authorizer uses.
*/
protected readonly handler: lambda.IFunction;
/**
* The IAM role that the API Gateway service assumes while invoking the Lambda function.
*/
protected readonly role?: iam.IRole;
protected restApiId?: string;
protected abstract readonly authorizerProps: CfnAuthorizerProps;
protected constructor(scope: Construct, id: string, props: LambdaAuthorizerProps);
/**
* Attaches this authorizer to a specific REST API.
* @internal
*/
_attachToApi(restApi: IRestApi): void;
/**
* Sets up the permissions necessary for the API Gateway service to invoke the Lambda function.
*/
protected setupPermissions(): void;
/**
* Add Default Permission Role for handler
*/
private addDefaultPermissionRole;
/**
* Add Lambda Invoke Permission for Lambda Authorizer's role
*/
private addLambdaInvokePermission;
/**
* Returns a token that resolves to the Rest Api Id at the time of synthesis.
* Throws an error, during token resolution, if no RestApi is attached to this authorizer.
*/
protected lazyRestApiId(): string;
}
/**
* Properties for TokenAuthorizer
*/
export interface TokenAuthorizerProps extends LambdaAuthorizerProps {
/**
* An optional regex to be matched against the authorization token. When matched the authorizer lambda is invoked,
* otherwise a 401 Unauthorized is returned to the client.
*
* @default - no regex filter will be applied.
*/
readonly validationRegex?: string;
/**
* The request header mapping expression for the bearer token. This is typically passed as part of the header, in which case
* this should be `method.request.header.Authorizer` where `Authorizer` is the header containing the bearer token.
*
* @see https://docs.aws.amazon.com/apigateway/latest/api/API_CreateAuthorizer.html#apigw-CreateAuthorizer-request-identitySource
* @default `IdentitySource.header('Authorization')`
*/
readonly identitySource?: string;
}
/**
* Token based lambda authorizer that recognizes the caller's identity as a bearer token,
* such as a JSON Web Token (JWT) or an OAuth token.
* Based on the token, authorization is performed by a lambda function.
*
* @resource AWS::ApiGateway::Authorizer
*/
export declare class TokenAuthorizer extends LambdaAuthorizer {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
readonly authorizerId: string;
readonly authorizerArn: string;
protected readonly authorizerProps: CfnAuthorizerProps;
constructor(scope: Construct, id: string, props: TokenAuthorizerProps);
}
/**
* Properties for RequestAuthorizer
*/
export interface RequestAuthorizerProps extends LambdaAuthorizerProps {
/**
* An array of request header mapping expressions for identities. Supported parameter types are
* Header, Query String, Stage Variable, and Context. For instance, extracting an authorization
* token from a header would use the identity source `IdentitySource.header('Authorization')`.
*
* Note: API Gateway uses the specified identity sources as the request authorizer caching key. When caching is
* enabled, API Gateway calls the authorizer's Lambda function only after successfully verifying that all the
* specified identity sources are present at runtime. If a specified identify source is missing, null, or empty,
* API Gateway returns a 401 Unauthorized response without calling the authorizer Lambda function.
*
* @see https://docs.aws.amazon.com/apigateway/latest/api/API_CreateAuthorizer.html#apigw-CreateAuthorizer-request-identitySource
*/
readonly identitySources: string[];
}
/**
* Request-based lambda authorizer that recognizes the caller's identity via request parameters,
* such as headers, paths, query strings, stage variables, or context variables.
* Based on the request, authorization is performed by a lambda function.
*
* @resource AWS::ApiGateway::Authorizer
*/
export declare class RequestAuthorizer extends LambdaAuthorizer {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
readonly authorizerId: string;
readonly authorizerArn: string;
protected readonly authorizerProps: CfnAuthorizerProps;
constructor(scope: Construct, id: string, props: RequestAuthorizerProps);
}
export {};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,50 @@
import type { Construct } from 'constructs';
import type { IDomainNameRef, IRestApiRef } from './apigateway.generated';
import type { Stage } from './stage';
import { Resource } from '../../core';
export interface BasePathMappingOptions {
/**
* The base path name that callers of the API must provide in the URL after
* the domain name (e.g. `example.com/base-path`). If you specify this
* property, it can't be an empty string.
*
* @default - map requests from the domain root (e.g. `example.com`). If this
* is undefined, no additional mappings will be allowed on this domain name.
*/
readonly basePath?: string;
/**
* The Deployment stage of API
* [disable-awslint:ref-via-interface]
* @default - map to deploymentStage of restApi otherwise stage needs to pass in URL
*/
readonly stage?: Stage;
/**
* Whether to attach the base path mapping to a stage.
* Use this property to create a base path mapping without attaching it to the Rest API default stage.
* This property is ignored if `stage` is provided.
* @default - true
*/
readonly attachToStage?: boolean;
}
export interface BasePathMappingProps extends BasePathMappingOptions {
/**
* The DomainName to associate with this base path mapping.
*/
readonly domainName: IDomainNameRef;
/**
* The RestApi resource to target.
*/
readonly restApi: IRestApiRef;
}
/**
* This resource creates a base path that clients who call your API must use in
* the invocation URL.
*
* Unless you're importing a domain with `DomainName.fromDomainNameAttributes()`,
* you can use `DomainName.addBasePathMapping()` to define mappings.
*/
export declare class BasePathMapping extends Resource {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
constructor(scope: Construct, id: string, props: BasePathMappingProps);
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,102 @@
import type { Duration } from '../../core';
export interface CorsOptions {
/**
* Specifies the response status code returned from the OPTIONS method.
*
* @default 204
*/
readonly statusCode?: number;
/**
* Specifies the list of origins that are allowed to make requests to this
* resource. If you wish to allow all origins, specify `Cors.ALL_ORIGINS` or
* `[ * ]`.
*
* Responses will include the `Access-Control-Allow-Origin` response header.
* If specific origins are specified (not `Cors.ALL_ORIGINS`), the `Vary: Origin`
* response header will also be included.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
*/
readonly allowOrigins: string[];
/**
* The Access-Control-Allow-Headers response header is used in response to a
* preflight request which includes the Access-Control-Request-Headers to
* indicate which HTTP headers can be used during the actual request.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
* @default Cors.DEFAULT_HEADERS
*/
readonly allowHeaders?: string[];
/**
* The Access-Control-Allow-Methods response header specifies the method or
* methods allowed when accessing the resource in response to a preflight request.
*
* If `ANY` is specified, it will be expanded to `Cors.ALL_METHODS`.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
* @default Cors.ALL_METHODS
*/
readonly allowMethods?: string[];
/**
* The Access-Control-Allow-Credentials response header tells browsers whether
* to expose the response to frontend JavaScript code when the request's
* credentials mode (Request.credentials) is "include".
*
* When a request's credentials mode (Request.credentials) is "include",
* browsers will only expose the response to frontend JavaScript code if the
* Access-Control-Allow-Credentials value is true.
*
* Credentials are cookies, authorization headers or TLS client certificates.
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
* @default false
*/
readonly allowCredentials?: boolean;
/**
* The Access-Control-Max-Age response header indicates how long the results of
* a preflight request (that is the information contained in the
* Access-Control-Allow-Methods and Access-Control-Allow-Headers headers)
* can be cached.
*
* To disable caching altogether use `disableCache: true`.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
* @default - browser-specific (see reference)
*/
readonly maxAge?: Duration;
/**
* Sets Access-Control-Max-Age to -1, which means that caching is disabled.
* This option cannot be used with `maxAge`.
*
* @default - cache is enabled
*/
readonly disableCache?: boolean;
/**
* The Access-Control-Expose-Headers response header indicates which headers
* can be exposed as part of the response by listing their names.
*
* If you want clients to be able to access other headers, you have to list
* them using the Access-Control-Expose-Headers header.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
*
* @default - only the 6 CORS-safelisted response headers are exposed:
* Cache-Control, Content-Language, Content-Type, Expires, Last-Modified,
* Pragma
*/
readonly exposeHeaders?: string[];
}
export declare class Cors {
/**
* All HTTP methods.
*/
static readonly ALL_METHODS: string[];
/**
* All origins.
*/
static readonly ALL_ORIGINS: string[];
/**
* The set of default headers allowed for CORS and useful for API Gateway.
*/
static readonly DEFAULT_HEADERS: string[];
private constructor();
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cors=void 0;const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var util_1=()=>{var tmp=require("./util");return util_1=()=>tmp,tmp};class Cors{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.Cors",version:"2.252.0"};static ALL_METHODS=util_1().ALL_METHODS;static ALL_ORIGINS=["*"];static DEFAULT_HEADERS=["Content-Type","X-Amz-Date","Authorization","X-Api-Key","X-Amz-Security-Token","X-Amz-User-Agent"];constructor(){}}exports.Cors=Cors;

View File

@@ -0,0 +1,103 @@
import type { Construct } from 'constructs';
import type { Method } from './method';
import type { IRestApi } from './restapi';
import { Resource } from '../../core';
export interface DeploymentProps {
/**
* The Rest API to deploy.
*/
readonly api: IRestApi;
/**
* A description of the purpose of the API Gateway deployment.
*
* @default - No description.
*/
readonly description?: string;
/**
* When an API Gateway model is updated, a new deployment will automatically be created.
* If this is true, the old API Gateway Deployment resource will not be deleted.
* This will allow manually reverting back to a previous deployment in case for example
*
* @default false
*/
readonly retainDeployments?: boolean;
/**
* The name of the stage the API Gateway deployment deploys to.
*
* @default - No stage name. If the `stageName` property is set but a stage with the
* corresponding name does not exist, a new stage resource will be created with the
* provided stage name.
*/
readonly stageName?: string;
}
/**
* A Deployment of a REST API.
*
* An immutable representation of a RestApi resource that can be called by users
* using Stages. A deployment must be associated with a Stage for it to be
* callable over the Internet.
*
* Normally, you don't need to define deployments manually. The RestApi
* construct manages a Deployment resource that represents the latest model. It
* can be accessed through `restApi.latestDeployment` (unless `deploy: false` is
* set when defining the `RestApi`).
*
* If you manually define this resource, you will need to know that since
* deployments are immutable, as long as the resource's logical ID doesn't
* change, the deployment will represent the snapshot in time in which the
* resource was created. This means that if you modify the RestApi model (i.e.
* add methods or resources), these changes will not be reflected unless a new
* deployment resource is created.
*
* To achieve this behavior, the method `addToLogicalId(data)` can be used to
* augment the logical ID generated for the deployment resource such that it
* will include arbitrary data. This is done automatically for the
* `restApi.latestDeployment` deployment.
*
* Furthermore, since a deployment does not reference any of the REST API
* resources and methods, CloudFormation will likely provision it before these
* resources are created, which means that it will represent a "half-baked"
* model. Use the `node.addDependency(dep)` method to circumvent that. This is done
* automatically for the `restApi.latestDeployment` deployment.
*/
export declare class Deployment extends Resource {
/**
* Uniquely identifies this class.
*/
static readonly PROPERTY_INJECTION_ID: string;
/** @attribute */
readonly deploymentId: string;
readonly api: IRestApi;
/**
* The stage of the API gateway deployment.
*/
readonly stageName?: string;
private readonly resource;
constructor(scope: Construct, id: string, props: DeploymentProps);
/**
* Adds a component to the hash that determines this Deployment resource's
* logical ID.
*
* This should be called by constructs of the API Gateway model that want to
* invalidate the deployment when their settings change. The component will
* be resolved during synthesis so tokens are welcome.
*/
addToLogicalId(data: any): void;
/**
* Quoting from CloudFormation's docs:
*
* If you create an AWS::ApiGateway::RestApi resource and its methods (using
* AWS::ApiGateway::Method) in the same template as your deployment, the
* deployment must depend on the RestApi's methods. To create a dependency,
* add a DependsOn attribute to the deployment. If you don't, AWS
* CloudFormation creates the deployment right after it creates the RestApi
* resource that doesn't contain any methods, and AWS CloudFormation
* encounters the following error: The REST API doesn't contain any methods.
*
* @param method The method to add as a dependency of the deployment
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-deployment.html
* @see https://github.com/aws/aws-cdk/pull/6165
* @internal
*/
_addMethodDependency(method: Method): void;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,268 @@
import type { Construct } from 'constructs';
import type { DomainNameReference, IDomainNameRef, IRestApiRef, IStageRef } from './apigateway.generated';
import type { BasePathMappingOptions } from './base-path-mapping';
import { BasePathMapping } from './base-path-mapping';
import type { IRestApi } from './restapi';
import { EndpointType } from './restapi';
import type { IBucket } from '../../aws-s3';
import type { IResource } from '../../core';
import { Resource } from '../../core';
import type { ICertificateRef } from '../../interfaces/generated/aws-certificatemanager-interfaces.generated';
/**
* Options for creating an api mapping
*/
export interface ApiMappingOptions {
/**
* The api path name that callers of the API must provide in the URL after
* the domain name (e.g. `example.com/base-path`). If you specify this
* property, it can't be an empty string.
*
* If this is undefined, a mapping will be added for the empty path. Any request
* that does not match a mapping will get sent to the API that has been mapped
* to the empty path.
*
* @default - map requests from the domain root (e.g. `example.com`).
*/
readonly basePath?: string;
}
/**
* The minimum version of the SSL protocol that you want API Gateway to use for HTTPS connections.
*/
export declare enum SecurityPolicy {
/** Cipher suite TLS 1.0 */
TLS_1_0 = "TLS_1_0",
/** Cipher suite TLS 1.2 */
TLS_1_2 = "TLS_1_2",
/**
* Cipher suite TLS 1.3 for regional/private endpoints
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-custom-domain-tls-version.html
*/
TLS13_1_3_2025_09 = "SecurityPolicy_TLS13_1_3_2025_09",
/**
* Cipher suite TLS 1.3 (FIPS compliant) for regional/private endpoints
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-custom-domain-tls-version.html
*/
TLS13_1_3_FIPS_2025_09 = "SecurityPolicy_TLS13_1_3_FIPS_2025_09",
/**
* Cipher suite TLS 1.3 and TLS 1.2 with post-quantum cryptography for regional/private endpoints
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-custom-domain-tls-version.html
*/
TLS13_1_2_PQ_2025_09 = "SecurityPolicy_TLS13_1_2_PQ_2025_09",
/**
* Cipher suite TLS 1.3 and TLS 1.2 with Perfect Forward Secrecy and post-quantum cryptography for regional/private endpoints
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-custom-domain-tls-version.html
*/
TLS13_1_2_PFS_PQ_2025_09 = "SecurityPolicy_TLS13_1_2_PFS_PQ_2025_09",
/**
* Cipher suite TLS 1.3 for edge-optimized endpoints
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-custom-domain-tls-version.html
*/
TLS13_2025_EDGE = "SecurityPolicy_TLS13_2025_EDGE",
/**
* Cipher suite TLS 1.2 with Perfect Forward Secrecy for edge-optimized endpoints
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-custom-domain-tls-version.html
*/
TLS12_PFS_2025_EDGE = "SecurityPolicy_TLS12_PFS_2025_EDGE",
/**
* Cipher suite TLS 1.2 for edge-optimized endpoints (legacy)
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-custom-domain-tls-version.html
*/
TLS12_2018_EDGE = "SecurityPolicy_TLS12_2018_EDGE"
}
/**
* The endpoint access mode for the domain name.
*
* When using enhanced security policies (those starting with `SecurityPolicy_`),
* you must set the endpoint access mode to either `STRICT` or `BASIC`.
* Use `STRICT` for production workloads requiring the highest security.
* Use `BASIC` for migration scenarios or certain application architectures.
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-security-policies.html#apigateway-security-policies-endpoint-access-mode
*/
export declare enum EndpointAccessMode {
/**
* Strict mode - only accepts connections from clients using the specified security policy.
* Recommended for production workloads.
*/
STRICT = "STRICT",
/**
* Basic mode - one of the two valid endpoint access modes for enhanced security policies.
* Suitable for migration scenarios or certain application architectures.
* Note: legacy security policies (TLS_1_0, TLS_1_2) do not use this attribute.
*/
BASIC = "BASIC"
}
export interface DomainNameOptions {
/**
* The custom domain name for your API. Uppercase letters are not supported.
*/
readonly domainName: string;
/**
* The reference to an AWS-managed certificate for use by the edge-optimized
* endpoint for the domain name. For "EDGE" domain names, the certificate
* needs to be in the US East (N. Virginia) region.
*/
readonly certificate: ICertificateRef;
/**
* The type of endpoint for this DomainName.
* @default REGIONAL
*/
readonly endpointType?: EndpointType;
/**
* The Transport Layer Security (TLS) version + cipher suite for this domain name.
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html
* @default SecurityPolicy.TLS_1_2
*/
readonly securityPolicy?: SecurityPolicy;
/**
* The endpoint access mode for this domain name.
*
* When using enhanced security policies (those starting with `SecurityPolicy_`),
* you must specify this property. STRICT is recommended for production workloads,
* but BASIC may be needed during migration or for certain application architectures.
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-security-policies.html#apigateway-security-policies-endpoint-access-mode
* @default - No endpoint access mode is configured. Required for enhanced security policies.
*/
readonly endpointAccessMode?: EndpointAccessMode;
/**
* The mutual TLS authentication configuration for a custom domain name.
* @default - mTLS is not configured.
*/
readonly mtls?: MTLSConfig;
/**
* The base path name that callers of the API must provide in the URL after
* the domain name (e.g. `example.com/base-path`). If you specify this
* property, it can't be an empty string.
*
* @default - map requests from the domain root (e.g. `example.com`).
*/
readonly basePath?: string;
}
export interface DomainNameProps extends DomainNameOptions {
/**
* If specified, all requests to this domain will be mapped to the production
* deployment of this API. If you wish to map this domain to multiple APIs
* with different base paths, use `addBasePathMapping` or `addApiMapping`.
*
* @default - you will have to call `addBasePathMapping` to map this domain to
* API endpoints.
*/
readonly mapping?: IRestApi;
}
export interface IDomainName extends IResource, IDomainNameRef {
/**
* The domain name (e.g. `example.com`)
*
* @attribute DomainName
*/
readonly domainName: string;
/**
* The Route53 alias target to use in order to connect a record set to this domain through an alias.
*
* @attribute DistributionDomainName,RegionalDomainName
*/
readonly domainNameAliasDomainName: string;
/**
* The Route53 hosted zone ID to use in order to connect a record set to this domain through an alias.
*
* @attribute DistributionHostedZoneId,RegionalHostedZoneId
*/
readonly domainNameAliasHostedZoneId: string;
}
export declare class DomainName extends Resource implements IDomainName {
/**
* Uniquely identifies this class.
*/
static readonly PROPERTY_INJECTION_ID: string;
/**
* Imports an existing domain name.
*/
static fromDomainNameAttributes(scope: Construct, id: string, attrs: DomainNameAttributes): IDomainName;
/** Policies that only support non-edge (regional/private) endpoints */
private static readonly NON_EDGE_ONLY_POLICIES;
/** Policies that only support edge endpoints */
private static readonly EDGE_ONLY_POLICIES;
/** @jsii suppress JSII5019 For historic reasons */
readonly domainName: string;
readonly domainNameRef: DomainNameReference;
readonly domainNameAliasDomainName: string;
readonly domainNameAliasHostedZoneId: string;
private readonly basePaths;
private readonly securityPolicy?;
private readonly endpointType;
constructor(scope: Construct, id: string, props: DomainNameProps);
private validateBasePath;
private isMultiLevel;
/**
* Maps this domain to an API endpoint.
*
* This uses the BasePathMapping from ApiGateway v1 which does not support multi-level paths.
*
* If you need to create a mapping for a multi-level path use `addApiMapping` instead.
*
* @param targetApi That target API endpoint, requests will be mapped to the deployment stage.
* @param options Options for mapping to base path with or without a stage
*/
addBasePathMapping(targetApi: IRestApiRef, options?: BasePathMappingOptions): BasePathMapping;
/**
* Maps this domain to an API endpoint.
*
* This uses the ApiMapping from ApiGatewayV2 which supports multi-level paths, but
* also only supports:
* - SecurityPolicy TLS 1.2 or higher for multi-level base paths (TLS 1.0 is not supported for multi-level paths)
* - EndpointType.REGIONAL
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-mappings.html
* @param targetStage the target API stage.
* @param options Options for mapping to a stage
*/
addApiMapping(targetStage: IStageRef, options?: ApiMappingOptions): void;
private configureMTLS;
/**
* Checks if the given security policy is an enhanced security policy.
* Enhanced security policies start with 'SecurityPolicy_' prefix.
*
* Note: When the security policy is a CDK token (e.g., CfnParameter, cross-stack reference),
* this method returns false to defer validation to CloudFormation deployment time.
*/
private isEnhancedSecurityPolicy;
/**
* Validates that the security policy is compatible with the endpoint type.
* Some policies are only supported for specific endpoint types.
*/
private validateSecurityPolicyEndpointType;
}
export interface DomainNameAttributes {
/**
* The domain name (e.g. `example.com`)
*/
readonly domainName: string;
/**
* The Route53 alias target to use in order to connect a record set to this domain through an alias.
*/
readonly domainNameAliasTarget: string;
/**
* The Route53 hosted zone ID to use in order to connect a record set to this domain through an alias.
*/
readonly domainNameAliasHostedZoneId: string;
}
/**
* The mTLS authentication configuration for a custom domain name.
*/
export interface MTLSConfig {
/**
* The bucket that the trust store is hosted in.
*/
readonly bucket: IBucket;
/**
* The key in S3 to look at for the trust store.
*/
readonly key: string;
/**
* The version of the S3 object that contains your truststore.
* To specify a version, you must have versioning enabled for the S3 bucket.
* @default - latest version
*/
readonly version?: string;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,165 @@
import type { Construct } from 'constructs';
import type { GatewayResponseReference, IGatewayResponseRef } from './apigateway.generated';
import type { IRestApi } from './restapi';
import type { IResource } from '../../core';
import { Resource } from '../../core';
/**
* Represents gateway response resource.
*/
export interface IGatewayResponse extends IResource, IGatewayResponseRef {
}
/**
* Properties for a new gateway response.
*/
export interface GatewayResponseProps extends GatewayResponseOptions {
/**
* Rest api resource to target.
*/
readonly restApi: IRestApi;
}
/**
* Options to add gateway response.
*/
export interface GatewayResponseOptions {
/**
* Response type to associate with gateway response.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/supported-gateway-response-types.html
*/
readonly type: ResponseType;
/**
* Http status code for response.
* @default - standard http status code for the response type.
*/
readonly statusCode?: string;
/**
* Custom headers parameters for response.
* @default - no headers
*/
readonly responseHeaders?: {
[key: string]: string;
};
/**
* Custom templates to get mapped as response.
* @default - Response from api will be returned without applying any transformation.
*/
readonly templates?: {
[key: string]: string;
};
}
/**
* Configure the response received by clients, produced from the API Gateway backend.
*
* @resource AWS::ApiGateway::GatewayResponse
*/
export declare class GatewayResponse extends Resource implements IGatewayResponse {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
/**
* Reference an existing GatewayResponse given a gateway response ID.
*/
static fromGatewayResponseId(scope: Construct, id: string, gatewayResponseId: string): IGatewayResponse;
readonly gatewayResponseRef: GatewayResponseReference;
constructor(scope: Construct, id: string, props: GatewayResponseProps);
private buildResponseParameters;
}
/**
* Supported types of gateway responses.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/supported-gateway-response-types.html
*/
export declare class ResponseType {
/**
* The gateway response for authorization failure.
*/
static readonly ACCESS_DENIED: ResponseType;
/**
* The gateway response for an invalid API configuration.
*/
static readonly API_CONFIGURATION_ERROR: ResponseType;
/**
* The gateway response when a custom or Amazon Cognito authorizer failed to authenticate the caller.
*/
static readonly AUTHORIZER_FAILURE: ResponseType;
/**
* The gateway response for failing to connect to a custom or Amazon Cognito authorizer.
*/
static readonly AUTHORIZER_CONFIGURATION_ERROR: ResponseType;
/**
* The gateway response when the request parameter cannot be validated according to an enabled request validator.
*/
static readonly BAD_REQUEST_PARAMETERS: ResponseType;
/**
* The gateway response when the request body cannot be validated according to an enabled request validator.
*/
static readonly BAD_REQUEST_BODY: ResponseType;
/**
* The default gateway response for an unspecified response type with the status code of 4XX.
*/
static readonly DEFAULT_4XX: ResponseType;
/**
* The default gateway response for an unspecified response type with a status code of 5XX.
*/
static readonly DEFAULT_5XX: ResponseType;
/**
* The gateway response for an AWS authentication token expired error.
*/
static readonly EXPIRED_TOKEN: ResponseType;
/**
* The gateway response for an invalid AWS signature error.
*/
static readonly INVALID_SIGNATURE: ResponseType;
/**
* The gateway response for an integration failed error.
*/
static readonly INTEGRATION_FAILURE: ResponseType;
/**
* The gateway response for an integration timed out error.
*/
static readonly INTEGRATION_TIMEOUT: ResponseType;
/**
* The gateway response for an invalid API key submitted for a method requiring an API key.
*/
static readonly INVALID_API_KEY: ResponseType;
/**
* The gateway response for a missing authentication token error,
* including the cases when the client attempts to invoke an unsupported API method or resource.
*/
static readonly MISSING_AUTHENTICATION_TOKEN: ResponseType;
/**
* The gateway response for the usage plan quota exceeded error.
*/
static readonly QUOTA_EXCEEDED: ResponseType;
/**
* The gateway response for the request too large error.
*/
static readonly REQUEST_TOO_LARGE: ResponseType;
/**
* The gateway response when API Gateway cannot find the specified resource
* after an API request passes authentication and authorization.
*/
static readonly RESOURCE_NOT_FOUND: ResponseType;
/**
* The gateway response when usage plan, method, stage, or account level throttling limits exceeded.
*/
static readonly THROTTLED: ResponseType;
/**
* The gateway response when the custom or Amazon Cognito authorizer failed to authenticate the caller.
*/
static readonly UNAUTHORIZED: ResponseType;
/**
* The gateway response when a payload is of an unsupported media type, if strict passthrough behavior is enabled.
*/
static readonly UNSUPPORTED_MEDIA_TYPE: ResponseType;
/**
* The gateway response when a request is blocked by AWS WAF.
*/
static readonly WAF_FILTERED: ResponseType;
/** A custom response type to support future cases. */
static of(type: string): ResponseType;
/**
* Valid value of response type.
*
* @jsii suppress JSII5019 For historic reasons
*/
readonly responseType: string;
private constructor();
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,26 @@
export * from './restapi';
export * from './resource';
export * from './method';
export * from './integration';
export * from './deployment';
export * from './stage';
export * from './integrations';
export * from './lambda-api';
export * from './api-key';
export * from './usage-plan';
export * from './vpc-link';
export * from './methodresponse';
export * from './model';
export * from './requestvalidator';
export * from './authorizer';
export * from './json-schema';
export * from './domain-name';
export * from './base-path-mapping';
export * from './cors';
export * from './authorizers';
export * from './access-log';
export * from './api-definition';
export * from './gateway-response';
export * from './stepfunctions-api';
export * from './apigateway.generated';
export * from './apigateway-grants.generated';

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,334 @@
import type { Method } from './method';
import type { IVpcLink } from './vpc-link';
import type * as iam from '../../aws-iam';
import type { Duration } from '../../core';
/**
* The response transfer mode of the integration
*/
export declare enum ResponseTransferMode {
/**
* API Gateway waits to receive the complete response before beginning transmission.
*/
BUFFERED = "BUFFERED",
/**
* API Gateway streams the response back to you as it is received from the integration.
*
* This is only supported for AWS_PROXY and HTTP_PROXY integration types.
*/
STREAM = "STREAM"
}
export interface IntegrationOptions {
/**
* A list of request parameters whose values are to be cached. It determines
* request parameters that will make it into the cache key.
*/
readonly cacheKeyParameters?: string[];
/**
* An API-specific tag group of related cached parameters.
*/
readonly cacheNamespace?: string;
/**
* Specifies how to handle request payload content type conversions.
*
* @default none if this property isn't defined, the request payload is passed
* through from the method request to the integration request without
* modification, provided that the `passthroughBehaviors` property is
* configured to support payload pass-through.
*/
readonly contentHandling?: ContentHandling;
/**
* An IAM role that API Gateway assumes.
*
* Mutually exclusive with `credentialsPassThrough`.
*
* @default A role is not assumed
*/
readonly credentialsRole?: iam.IRole;
/**
* Requires that the caller's identity be passed through from the request.
*
* @default Caller identity is not passed through
*/
readonly credentialsPassthrough?: boolean;
/**
* Specifies the pass-through behavior for incoming requests based on the
* Content-Type header in the request, and the available mapping templates
* specified as the requestTemplates property on the Integration resource.
* There are three valid values: WHEN_NO_MATCH, WHEN_NO_TEMPLATES, and
* NEVER.
*/
readonly passthroughBehavior?: PassthroughBehavior;
/**
* The request parameters that API Gateway sends with the backend request.
* Specify request parameters as key-value pairs (string-to-string
* mappings), with a destination as the key and a source as the value.
*
* Specify the destination by using the following pattern
* integration.request.location.name, where location is querystring, path,
* or header, and name is a valid, unique parameter name.
*
* The source must be an existing method request parameter or a static
* value. You must enclose static values in single quotation marks and
* pre-encode these values based on their destination in the request.
*/
readonly requestParameters?: {
[dest: string]: string;
};
/**
* A map of Apache Velocity templates that are applied on the request
* payload. The template that API Gateway uses is based on the value of the
* Content-Type header that's sent by the client. The content type value is
* the key, and the template is the value (specified as a string), such as
* the following snippet:
*
* ```
* { "application/json": "{ \"statusCode\": 200 }" }
* ```
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
*/
readonly requestTemplates?: {
[contentType: string]: string;
};
/**
* The maximum amount of time an integration will run before it returns without a response.
*
* By default, the value must be between 50 milliseconds and 29 seconds.
* The upper bound can be increased for regional and private Rest APIs only,
* via a quota increase request for your account.
* This increase might require a reduction in your account-level throttle quota limit.
*
* See {@link https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html Amazon API Gateway quotas} for more details.
*
* @default Duration.seconds(29)
*/
readonly timeout?: Duration;
/**
* The response that API Gateway provides after a method's backend completes
* processing a request. API Gateway intercepts the response from the
* backend so that you can control how API Gateway surfaces backend
* responses. For example, you can map the backend status codes to codes
* that you define.
*/
readonly integrationResponses?: IntegrationResponse[];
/**
* The type of network connection to the integration endpoint.
* @default - ConnectionType.VPC_LINK if `vpcLink` property is configured; ConnectionType.Internet otherwise.
*/
readonly connectionType?: ConnectionType;
/**
* The VpcLink used for the integration.
* Required if connectionType is VPC_LINK
*/
readonly vpcLink?: IVpcLink;
/**
* The response transfer mode for the integration.
*
* To enable response streaming, set this value to `ResponseTransferMode.STREAM`.
*
* @default ResponseTransferMode.BUFFERED
*/
readonly responseTransferMode?: ResponseTransferMode;
}
export interface IntegrationProps {
/**
* Specifies an API method integration type.
*/
readonly type: IntegrationType;
/**
* The Uniform Resource Identifier (URI) for the integration.
*
* - If you specify HTTP for the `type` property, specify the API endpoint URL.
* - If you specify MOCK for the `type` property, don't specify this property.
* - If you specify AWS for the `type` property, specify an AWS service that
* follows this form: `arn:partition:apigateway:region:subdomain.service|service:path|action/service_api.`
* For example, a Lambda function URI follows this form:
* arn:partition:apigateway:region:lambda:path/path. The path is usually in the
* form /2015-03-31/functions/LambdaFunctionARN/invocations.
*
* @see https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#uri
*/
readonly uri?: any;
/**
* The integration's HTTP method type.
* Required unless you use a MOCK integration.
*/
readonly integrationHttpMethod?: string;
/**
* Integration options.
*/
readonly options?: IntegrationOptions;
}
/**
* Result of binding an Integration to a Method.
*/
export interface IntegrationConfig {
/**
* Integration options.
* @default - no integration options
*/
readonly options?: IntegrationOptions;
/**
* Specifies an API method integration type.
*/
readonly type: IntegrationType;
/**
* The Uniform Resource Identifier (URI) for the integration.
* @see https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#uri
* @default - no URI. Usually applies to MOCK integration
*/
readonly uri?: string;
/**
* The integration's HTTP method type.
* Required unless you use a MOCK integration.
*
* @default - no integration method specified.
*/
readonly integrationHttpMethod?: string;
/**
* This value is included in computing the Deployment's fingerprint. When the fingerprint
* changes, a new deployment is triggered.
* This property should contain values associated with the Integration that upon changing
* should trigger a fresh the Deployment needs to be refreshed.
* @default undefined deployments are not triggered for any change to this integration.
*/
readonly deploymentToken?: string;
}
/**
* Base class for backend integrations for an API Gateway method.
*
* Use one of the concrete classes such as `MockIntegration`, `AwsIntegration`, `LambdaIntegration`
* or implement on your own by specifying the set of props.
*/
export declare class Integration {
private readonly props;
constructor(props: IntegrationProps);
/**
* Can be overridden by subclasses to allow the integration to interact with the method
* being integrated, access the REST API object, method ARNs, etc.
*/
bind(method: Method): IntegrationConfig;
}
export declare enum ContentHandling {
/**
* Converts a request payload from a base64-encoded string to a binary blob.
*/
CONVERT_TO_BINARY = "CONVERT_TO_BINARY",
/**
* Converts a request payload from a binary blob to a base64-encoded string.
*/
CONVERT_TO_TEXT = "CONVERT_TO_TEXT"
}
export declare enum IntegrationType {
/**
* For integrating the API method request with an AWS service action,
* including the Lambda function-invoking action. With the Lambda
* function-invoking action, this is referred to as the Lambda custom
* integration. With any other AWS service action, this is known as AWS
* integration.
*/
AWS = "AWS",
/**
* For integrating the API method request with the Lambda function-invoking
* action with the client request passed through as-is. This integration is
* also referred to as the Lambda proxy integration
*/
AWS_PROXY = "AWS_PROXY",
/**
* For integrating the API method request with an HTTP endpoint, including a
* private HTTP endpoint within a VPC. This integration is also referred to
* as the HTTP custom integration.
*/
HTTP = "HTTP",
/**
* For integrating the API method request with an HTTP endpoint, including a
* private HTTP endpoint within a VPC, with the client request passed
* through as-is. This is also referred to as the HTTP proxy integration
*/
HTTP_PROXY = "HTTP_PROXY",
/**
* For integrating the API method request with API Gateway as a "loop-back"
* endpoint without invoking any backend.
*/
MOCK = "MOCK"
}
export declare enum PassthroughBehavior {
/**
* Passes the request body for unmapped content types through to the
* integration back end without transformation.
*/
WHEN_NO_MATCH = "WHEN_NO_MATCH",
/**
* Rejects unmapped content types with an HTTP 415 'Unsupported Media Type'
* response
*/
NEVER = "NEVER",
/**
* Allows pass-through when the integration has NO content types mapped to
* templates. However if there is at least one content type defined,
* unmapped content types will be rejected with the same 415 response.
*/
WHEN_NO_TEMPLATES = "WHEN_NO_TEMPLATES"
}
export declare enum ConnectionType {
/**
* For connections through the public routable internet
*/
INTERNET = "INTERNET",
/**
* For private connections between API Gateway and a network load balancer in a VPC
*/
VPC_LINK = "VPC_LINK"
}
export interface IntegrationResponse {
/**
* Specifies the regular expression (regex) pattern used to choose an integration response based on the response from
* the back end. For example, if the success response returns nothing and the error response returns some string, you
* could use the ``.+`` regex to match error response. However, make sure that the error response does not contain any
* newline (``\n``) character in such cases. If the back end is an AWS Lambda function, the AWS Lambda function error
* header is matched. For all other HTTP and AWS back ends, the HTTP status code is matched.
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-integration-settings-integration-response.html
*/
readonly selectionPattern?: string;
/**
* The status code that API Gateway uses to map the integration response to
* a MethodResponse status code.
*/
readonly statusCode: string;
/**
* Specifies how to handle request payload content type conversions.
*
* @default none the request payload is passed through from the method
* request to the integration request without modification.
*/
readonly contentHandling?: ContentHandling;
/**
* The response parameters from the backend response that API Gateway sends
* to the method response.
*
* Use the destination as the key and the source as the value:
*
* - The destination must be an existing response parameter in the
* MethodResponse property.
* - The source must be an existing method request parameter or a static
* value. You must enclose static values in single quotation marks and
* pre-encode these values based on the destination specified in the
* request.
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html
*/
readonly responseParameters?: {
[destination: string]: string;
};
/**
* The templates that are used to transform the integration response body.
* Specify templates as key-value pairs, with a content type as the key and
* a template as the value.
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
*/
readonly responseTemplates?: {
[contentType: string]: string;
};
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,73 @@
import type { IntegrationConfig, IntegrationOptions } from '../integration';
import { Integration } from '../integration';
import type { Method } from '../method';
export interface AwsIntegrationProps {
/**
* Use AWS_PROXY integration.
*
* @default false
*/
readonly proxy?: boolean;
/**
* The name of the integrated AWS service (e.g. `s3`)
*/
readonly service: string;
/**
* A designated subdomain supported by certain AWS service for fast
* host-name lookup.
*/
readonly subdomain?: string;
/**
* The path to use for path-base APIs.
*
* For example, for S3 GET, you can set path to `bucket/key`.
* For lambda, you can set path to `2015-03-31/functions/${function-arn}/invocations`
*
* Mutually exclusive with the `action` options.
*/
readonly path?: string;
/**
* The AWS action to perform in the integration.
*
* Use `actionParams` to specify key-value params for the action.
*
* Mutually exclusive with `path`.
*/
readonly action?: string;
/**
* Parameters for the action.
*
* `action` must be set, and `path` must be undefined.
* The action params will be URL encoded.
*/
readonly actionParameters?: {
[key: string]: string;
};
/**
* The integration's HTTP method type.
*
* @default POST
*/
readonly integrationHttpMethod?: string;
/**
* Integration options, such as content handling, request/response mapping, etc.
*/
readonly options?: IntegrationOptions;
/**
* The region of the integrated AWS service.
*
* @default - same region as the stack
*/
readonly region?: string;
}
/**
* This type of integration lets an API expose AWS service actions. It is
* intended for calling all AWS service actions, but is not recommended for
* calling a Lambda function, because the Lambda custom integration is a legacy
* technology.
*/
export declare class AwsIntegration extends Integration {
private scope?;
constructor(props: AwsIntegrationProps);
bind(method: Method): IntegrationConfig;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AwsIntegration=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var cdk=()=>{var tmp=require("../../../core");return cdk=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},errors_1=()=>{var tmp=require("../../../core/lib/errors");return errors_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp},integration_1=()=>{var tmp=require("../integration");return integration_1=()=>tmp,tmp},util_1=()=>{var tmp=require("../util");return util_1=()=>tmp,tmp};class AwsIntegration extends integration_1().Integration{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.AwsIntegration",version:"2.252.0"};scope;constructor(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_AwsIntegrationProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,AwsIntegration),error}const backend=props.subdomain?`${props.subdomain}.${props.service}`:props.service,type=props.proxy?integration_1().IntegrationType.AWS_PROXY:integration_1().IntegrationType.AWS,{apiType,apiValue}=(0,util_1().parseAwsApiCall)(props.path,props.action,props.actionParameters);super({type,integrationHttpMethod:props.integrationHttpMethod||"POST",uri:cdk().Lazy.string({produce:()=>{if(!this.scope)throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`MustBeAwsintegrationUsed`,"AwsIntegration must be used in API");return cdk().Stack.of(this.scope).formatArn({service:"apigateway",account:backend,resource:apiType,arnFormat:core_1().ArnFormat.SLASH_RESOURCE_NAME,resourceName:apiValue,region:props.region})}}),options:props.options})}bind(method){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_Method(method)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}const bindResult=super.bind(method);return this.scope=method,bindResult}}exports.AwsIntegration=AwsIntegration;

View File

@@ -0,0 +1,38 @@
import type { IntegrationOptions } from '../integration';
import { Integration } from '../integration';
export interface HttpIntegrationProps {
/**
* Determines whether to use proxy integration or custom integration.
*
* @default true
*/
readonly proxy?: boolean;
/**
* HTTP method to use when invoking the backend URL.
* @default GET
*/
readonly httpMethod?: string;
/**
* Integration options, such as request/resopnse mapping, content handling,
* etc.
*
* @default defaults based on `IntegrationOptions` defaults
*/
readonly options?: IntegrationOptions;
}
/**
* You can integrate an API method with an HTTP endpoint using the HTTP proxy
* integration or the HTTP custom integration,.
*
* With the proxy integration, the setup is simple. You only need to set the
* HTTP method and the HTTP endpoint URI, according to the backend requirements,
* if you are not concerned with content encoding or caching.
*
* With the custom integration, the setup is more involved. In addition to the
* proxy integration setup steps, you need to specify how the incoming request
* data is mapped to the integration request and how the resulting integration
* response data is mapped to the method response.
*/
export declare class HttpIntegration extends Integration {
constructor(url: string, props?: HttpIntegrationProps);
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpIntegration=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var integration_1=()=>{var tmp=require("../integration");return integration_1=()=>tmp,tmp};class HttpIntegration extends integration_1().Integration{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.HttpIntegration",version:"2.252.0"};constructor(url,props={}){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_HttpIntegrationProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,HttpIntegration),error}const proxy=props.proxy??!0,method=props.httpMethod||"GET";super({type:proxy?integration_1().IntegrationType.HTTP_PROXY:integration_1().IntegrationType.HTTP,integrationHttpMethod:method,uri:url,options:props.options})}}exports.HttpIntegration=HttpIntegration;

View File

@@ -0,0 +1,7 @@
export * from './aws';
export * from './lambda';
export * from './http';
export * from './mock';
export * from './stepfunctions';
export * from './sagemaker';
export * from './request-context';

View File

@@ -0,0 +1 @@
"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__exportStar=exports&&exports.__exportStar||function(m,exports2){for(var p in m)p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p)&&__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:!0});var _noFold;exports.AwsIntegration=void 0,Object.defineProperty(exports,_noFold="AwsIntegration",{enumerable:!0,configurable:!0,get:()=>{var value=require("./aws").AwsIntegration;return Object.defineProperty(exports,_noFold="AwsIntegration",{enumerable:!0,configurable:!0,value}),value}}),exports.LambdaIntegration=void 0,Object.defineProperty(exports,_noFold="LambdaIntegration",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lambda").LambdaIntegration;return Object.defineProperty(exports,_noFold="LambdaIntegration",{enumerable:!0,configurable:!0,value}),value}}),exports.HttpIntegration=void 0,Object.defineProperty(exports,_noFold="HttpIntegration",{enumerable:!0,configurable:!0,get:()=>{var value=require("./http").HttpIntegration;return Object.defineProperty(exports,_noFold="HttpIntegration",{enumerable:!0,configurable:!0,value}),value}}),exports.MockIntegration=void 0,Object.defineProperty(exports,_noFold="MockIntegration",{enumerable:!0,configurable:!0,get:()=>{var value=require("./mock").MockIntegration;return Object.defineProperty(exports,_noFold="MockIntegration",{enumerable:!0,configurable:!0,value}),value}}),exports.StepFunctionsIntegration=void 0,Object.defineProperty(exports,_noFold="StepFunctionsIntegration",{enumerable:!0,configurable:!0,get:()=>{var value=require("./stepfunctions").StepFunctionsIntegration;return Object.defineProperty(exports,_noFold="StepFunctionsIntegration",{enumerable:!0,configurable:!0,value}),value}}),exports.SagemakerIntegration=void 0,Object.defineProperty(exports,_noFold="SagemakerIntegration",{enumerable:!0,configurable:!0,get:()=>{var value=require("./sagemaker").SagemakerIntegration;return Object.defineProperty(exports,_noFold="SagemakerIntegration",{enumerable:!0,configurable:!0,value}),value}});

View File

@@ -0,0 +1,56 @@
import { AwsIntegration } from './aws';
import * as lambda from '../../../aws-lambda';
import type { IntegrationConfig, IntegrationOptions } from '../integration';
import type { Method } from '../method';
export interface LambdaIntegrationOptions extends IntegrationOptions {
/**
* Use proxy integration or normal (request/response mapping) integration.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-output-format
*
* @default true
*/
readonly proxy?: boolean;
/**
* Allow invoking method from AWS Console UI (for testing purposes).
*
* This will add another permission to the AWS Lambda resource policy which
* will allow the `test-invoke-stage` stage to invoke this handler. If this
* is set to `false`, the function will only be usable from the deployment
* endpoint.
*
* Note that this property is ignored when `scopePermissionToMethod` is `false`.
*
* @default true
*/
readonly allowTestInvoke?: boolean;
/**
* Scope the permission for invoking the AWS Lambda down to the specific method
* associated with this integration.
*
* If this is set to `false`, the permission will allow invoking the AWS Lambda
* from any method. This is useful for reducing the AWS Lambda policy size
* for cases where the same AWS Lambda function is reused for many integrations.
*
* Note that this will always allow test invocations.
*
* @default true
*/
readonly scopePermissionToMethod?: boolean;
}
/**
* Integrates an AWS Lambda function to an API Gateway method.
*
* @example
*
* declare const resource: apigateway.Resource;
* declare const handler: lambda.Function;
* resource.addMethod('GET', new apigateway.LambdaIntegration(handler));
*
*/
export declare class LambdaIntegration extends AwsIntegration {
private readonly handler;
private readonly enableTest;
private readonly scopePermissionToMethod;
constructor(handler: lambda.IFunction, options?: LambdaIntegrationOptions);
bind(method: Method): IntegrationConfig;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LambdaIntegration=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var aws_1=()=>{var tmp=require("./aws");return aws_1=()=>tmp,tmp},iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},lambda=()=>{var tmp=require("../../../aws-lambda");return lambda=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},integration_1=()=>{var tmp=require("../integration");return integration_1=()=>tmp,tmp};class LambdaIntegration extends aws_1().AwsIntegration{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.LambdaIntegration",version:"2.252.0"};handler;enableTest;scopePermissionToMethod;constructor(handler,options={}){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_IFunction(handler),jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_LambdaIntegrationOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,LambdaIntegration),error}const proxy=options.proxy??!0,path=options.responseTransferMode===integration_1().ResponseTransferMode.STREAM?`2021-11-15/functions/${handler.functionArn}/response-streaming-invocations`:`2015-03-31/functions/${handler.functionArn}/invocations`;super({proxy,service:"lambda",path,options}),this.handler=handler,this.enableTest=options.allowTestInvoke??!0,this.scopePermissionToMethod=options.scopePermissionToMethod??!0}bind(method){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_Method(method)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}const bindResult=super.bind(method),principal=new(iam()).ServicePrincipal("apigateway.amazonaws.com");if(this.scopePermissionToMethod){const desc=`${core_1().Names.nodeUniqueId(method.api.node)}.${method.httpMethod}.${method.resource.path.replace(/\//g,".")}`;this.handler.addPermission(`ApiPermission.${desc}`,{principal,scope:method,sourceArn:core_1().Lazy.string({produce:()=>method.methodArn})}),this.enableTest&&this.handler.addPermission(`ApiPermission.Test.${desc}`,{principal,scope:method,sourceArn:method.testMethodArn})}else{const apiScopedPermissionId=`ApiPermission.ApiScoped.${core_1().Names.nodeUniqueId(this.handler.node)}.${core_1().Names.nodeUniqueId(method.api.node)}`;method.api.node.findAll().find(c=>c instanceof lambda().CfnPermission&&c.node.id===apiScopedPermissionId)||this.handler.addPermission(apiScopedPermissionId,{principal,scope:method.api,sourceArn:core_1().Lazy.string({produce:()=>method.api.arnForExecuteApi()})}),this.enableTest||core_1().Annotations.of(method).addWarningV2("@aws-cdk/aws-apigateway:allowTestInvoke","Value 'false' for 'allowTestInvoke' in LambdaIntegration is ignored since 'scopePermissionToMethod' is 'false'")}let functionName;this.handler instanceof lambda().Function?functionName=this.handler.node.defaultChild.functionName:functionName=this.handler.functionName;let deploymentToken;return core_1().Token.isUnresolved(functionName)||(deploymentToken=JSON.stringify({functionName})),{...bindResult,deploymentToken}}}exports.LambdaIntegration=LambdaIntegration;

View File

@@ -0,0 +1,17 @@
import type { IntegrationOptions } from '../integration';
import { Integration } from '../integration';
/**
* This type of integration lets API Gateway return a response without sending
* the request further to the backend. This is useful for API testing because it
* can be used to test the integration set up without incurring charges for
* using the backend and to enable collaborative development of an API. In
* collaborative development, a team can isolate their development effort by
* setting up simulations of API components owned by other teams by using the
* MOCK integrations. It is also used to return CORS-related headers to ensure
* that the API method permits CORS access. In fact, the API Gateway console
* integrates the OPTIONS method to support CORS with a mock integration.
* Gateway responses are other examples of mock integrations.
*/
export declare class MockIntegration extends Integration {
constructor(options?: IntegrationOptions);
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MockIntegration=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var integration_1=()=>{var tmp=require("../integration");return integration_1=()=>tmp,tmp};class MockIntegration extends integration_1().Integration{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.MockIntegration",version:"2.252.0"};constructor(options){super({type:integration_1().IntegrationType.MOCK,options});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_IntegrationOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,MockIntegration),error}}}exports.MockIntegration=MockIntegration;

View File

@@ -0,0 +1,144 @@
/**
* Configure what must be included in the `requestContext`
*
* More details can be found at mapping templates documentation.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
*/
export interface RequestContext {
/**
* Represents the information of $context.identity.accountId
*
* Whether the AWS account of the API owner should be included in the request context
* @default false
*/
readonly accountId?: boolean;
/**
* Represents the information of $context.apiId
*
* Whether the identifier API Gateway assigns to your API should be included in the request context.
* @default false
*/
readonly apiId?: boolean;
/**
* Represents the information of $context.identity.apiKey
*
* Whether the API key associated with the request should be included in request context.
* @default false
*/
readonly apiKey?: boolean;
/**
* Represents the information of $context.authorizer.principalId
*
* Whether the principal user identifier associated with the token sent by the client and returned
* from an API Gateway Lambda authorizer should be included in the request context.
* @default false
*/
readonly authorizerPrincipalId?: boolean;
/**
* Represents the information of $context.identity.caller
*
* Whether the principal identifier of the caller that signed the request should be included in the request context.
* Supported for resources that use IAM authorization.
* @default false
*/
readonly caller?: boolean;
/**
* Represents the information of $context.identity.cognitoAuthenticationProvider
*
* Whether the list of the Amazon Cognito authentication providers used by the caller making the request should be included in the request context.
* Available only if the request was signed with Amazon Cognito credentials.
* @default false
*/
readonly cognitoAuthenticationProvider?: boolean;
/**
* Represents the information of $context.identity.cognitoAuthenticationType
*
* Whether the Amazon Cognito authentication type of the caller making the request should be included in the request context.
* Available only if the request was signed with Amazon Cognito credentials.
* Possible values include authenticated for authenticated identities and unauthenticated for unauthenticated identities.
* @default false
*/
readonly cognitoAuthenticationType?: boolean;
/**
* Represents the information of $context.identity.cognitoIdentityId
*
* Whether the Amazon Cognito identity ID of the caller making the request should be included in the request context.
* Available only if the request was signed with Amazon Cognito credentials.
* @default false
*/
readonly cognitoIdentityId?: boolean;
/**
* Represents the information of $context.identity.cognitoIdentityPoolId
*
* Whether the Amazon Cognito identity pool ID of the caller making the request should be included in the request context.
* Available only if the request was signed with Amazon Cognito credentials.
* @default false
*/
readonly cognitoIdentityPoolId?: boolean;
/**
* Represents the information of $context.httpMethod
*
* Whether the HTTP method used should be included in the request context.
* Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.
* @default false
*/
readonly httpMethod?: boolean;
/**
* Represents the information of $context.stage
*
* Whether the deployment stage of the API request should be included in the request context.
* @default false
*/
readonly stage?: boolean;
/**
* Represents the information of $context.identity.sourceIp
*
* Whether the source IP address of the immediate TCP connection making the request
* to API Gateway endpoint should be included in the request context.
* @default false
*/
readonly sourceIp?: boolean;
/**
* Represents the information of $context.identity.user
*
* Whether the principal identifier of the user that will be authorized should be included in the request context.
* Supported for resources that use IAM authorization.
* @default false
*/
readonly user?: boolean;
/**
* Represents the information of $context.identity.userAgent
*
* Whether the User-Agent header of the API caller should be included in the request context.
* @default false
*/
readonly userAgent?: boolean;
/**
* Represents the information of $context.identity.userArn
*
* Whether the Amazon Resource Name (ARN) of the effective user identified after authentication should be included in the request context.
* @default false
*/
readonly userArn?: boolean;
/**
* Represents the information of $context.requestId
*
* Whether the ID for the request should be included in the request context.
* @default false
*/
readonly requestId?: boolean;
/**
* Represents the information of $context.resourceId
*
* Whether the identifier that API Gateway assigns to your resource should be included in the request context.
* @default false
*/
readonly resourceId?: boolean;
/**
* Represents the information of $context.resourcePath
*
* Whether the path to the resource should be included in the request context.
* @default false
*/
readonly resourcePath?: boolean;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});

View File

@@ -0,0 +1,24 @@
import { AwsIntegration } from './aws';
import type { IEndpoint } from '../../../aws-sagemaker';
import type { IntegrationConfig, IntegrationOptions } from '../integration';
import type { Method } from '../method';
/**
* Options for SageMakerIntegration
*/
export interface SagemakerIntegrationOptions extends IntegrationOptions {
}
/**
* Integrates an AWS Sagemaker Endpoint to an API Gateway method
*
* @example
*
* declare const resource: apigateway.Resource;
* declare const endpoint: sagemaker.IEndpoint;
* resource.addMethod('POST', new apigateway.SagemakerIntegration(endpoint));
*
*/
export declare class SagemakerIntegration extends AwsIntegration {
private readonly endpoint;
constructor(endpoint: IEndpoint, options?: SagemakerIntegrationOptions);
bind(method: Method): IntegrationConfig;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SagemakerIntegration=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var aws_1=()=>{var tmp=require("./aws");return aws_1=()=>tmp,tmp},iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp};class SagemakerIntegration extends aws_1().AwsIntegration{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.SagemakerIntegration",version:"2.252.0"};endpoint;constructor(endpoint,options={}){super({service:"runtime.sagemaker",path:`endpoints/${endpoint.endpointName}/invocations`,options:{credentialsRole:options.credentialsRole,integrationResponses:[{statusCode:"200"}],...options}});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_sagemaker_IEndpoint(endpoint),jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_SagemakerIntegrationOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,SagemakerIntegration),error}this.endpoint=endpoint}bind(method){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_Method(method)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}const bindResult=super.bind(method),credentialsRole=bindResult.options?.credentialsRole??new(iam()).Role(method,"SagemakerRole",{assumedBy:new(iam()).ServicePrincipal("apigateway.amazonaws.com"),description:"Generated by CDK::ApiGateway::SagemakerIntegration"});return this.endpoint.grantInvoke(credentialsRole),method.addMethodResponse({statusCode:"200"}),{...bindResult,options:{...bindResult.options,credentialsRole}}}}exports.SagemakerIntegration=SagemakerIntegration;

View File

@@ -0,0 +1,102 @@
import type { RequestContext } from '.';
import { AwsIntegration } from './aws';
import * as sfn from '../../../aws-stepfunctions';
import type { IntegrationOptions } from '../integration';
/**
* Options when configuring Step Functions synchronous integration with Rest API
*/
export interface StepFunctionsExecutionIntegrationOptions extends IntegrationOptions {
/**
* Which details of the incoming request must be passed onto the underlying state machine,
* such as, account id, user identity, request id, etc. The execution input will include a new key `requestContext`:
*
* {
* "body": {},
* "requestContext": {
* "key": "value"
* }
* }
*
* @default - all parameters within request context will be set as false
*/
readonly requestContext?: RequestContext;
/**
* Check if querystring is to be included inside the execution input. The execution input will include a new key `queryString`:
*
* {
* "body": {},
* "querystring": {
* "key": "value"
* }
* }
*
* @default true
*/
readonly querystring?: boolean;
/**
* Check if path is to be included inside the execution input. The execution input will include a new key `path`:
*
* {
* "body": {},
* "path": {
* "resourceName": "resourceValue"
* }
* }
*
* @default true
*/
readonly path?: boolean;
/**
* Check if header is to be included inside the execution input. The execution input will include a new key `headers`:
*
* {
* "body": {},
* "headers": {
* "header1": "value",
* "header2": "value"
* }
* }
* @default false
*/
readonly headers?: boolean;
/**
* If the whole authorizer object, including custom context values should be in the execution input. The execution input will include a new key `authorizer`:
*
* {
* "body": {},
* "authorizer": {
* "key": "value"
* }
* }
*
* @default false
*/
readonly authorizer?: boolean;
/**
* Whether to add default response models with 200, 400, and 500 status codes to the method.
*
* @default true
*/
readonly useDefaultMethodResponses?: boolean;
}
/**
* Options to integrate with various StepFunction API
*/
export declare class StepFunctionsIntegration {
/**
* Integrates a Synchronous Express State Machine from AWS Step Functions to an API Gateway method.
*
* @example
*
* const stateMachine = new stepfunctions.StateMachine(this, 'MyStateMachine', {
* stateMachineType: stepfunctions.StateMachineType.EXPRESS,
* definition: stepfunctions.Chain.start(new stepfunctions.Pass(this, 'Pass')),
* });
*
* const api = new apigateway.RestApi(this, 'Api', {
* restApiName: 'MyApi',
* });
* api.root.addMethod('GET', apigateway.StepFunctionsIntegration.startExecution(stateMachine));
*/
static startExecution(stateMachine: sfn.IStateMachine, options?: StepFunctionsExecutionIntegrationOptions): AwsIntegration;
}

View File

@@ -0,0 +1,6 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StepFunctionsIntegration=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var fs=()=>{var tmp=require("fs");return fs=()=>tmp,tmp},path=()=>{var tmp=require("path");return path=()=>tmp,tmp},aws_1=()=>{var tmp=require("./aws");return aws_1=()=>tmp,tmp},iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},sfn=()=>{var tmp=require("../../../aws-stepfunctions");return sfn=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},errors_1=()=>{var tmp=require("../../../core/lib/errors");return errors_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp},integration_1=()=>{var tmp=require("../integration");return integration_1=()=>tmp,tmp},model_1=()=>{var tmp=require("../model");return model_1=()=>tmp,tmp};class StepFunctionsIntegration{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.StepFunctionsIntegration",version:"2.252.0"};static startExecution(stateMachine,options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_IStateMachine(stateMachine),jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_StepFunctionsExecutionIntegrationOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.startExecution),error}return new StepFunctionsExecutionIntegration(stateMachine,options)}}exports.StepFunctionsIntegration=StepFunctionsIntegration;class StepFunctionsExecutionIntegration extends aws_1().AwsIntegration{stateMachine;useDefaultMethodResponses;constructor(stateMachine,options={}){super({service:"states",action:"StartSyncExecution",options:{credentialsRole:options.credentialsRole,integrationResponses:options.integrationResponses??integrationResponse(),passthroughBehavior:integration_1().PassthroughBehavior.NEVER,requestTemplates:requestTemplates(stateMachine,options),...options}}),this.stateMachine=stateMachine,this.useDefaultMethodResponses=options.useDefaultMethodResponses??!0}bind(method){const bindResult=super.bind(method),credentialsRole=bindResult.options?.credentialsRole??new(iam()).Role(method,"StartSyncExecutionRole",{assumedBy:new(iam()).ServicePrincipal("apigateway.amazonaws.com")});this.stateMachine.grantStartSyncExecution(credentialsRole);let stateMachineName;if(this.stateMachine instanceof sfn().StateMachine){if(this.stateMachine.stateMachineType!==sfn().StateMachineType.EXPRESS)throw new(errors_1()).ValidationError((0,literal_string_1().lit)`MustBeStateMachineType`,'State Machine must be of type "EXPRESS". Please use StateMachineType.EXPRESS as the stateMachineType',method);stateMachineName=this.stateMachine.node.defaultChild.stateMachineName}else stateMachineName=`StateMachine-${this.stateMachine.stack.node.addr}`;let deploymentToken;if(stateMachineName!==void 0&&!core_1().Token.isUnresolved(stateMachineName)&&(deploymentToken=JSON.stringify({stateMachineName})),this.useDefaultMethodResponses)for(const methodResponse of METHOD_RESPONSES)method.addMethodResponse(methodResponse);return{...bindResult,options:{...bindResult.options,credentialsRole},deploymentToken}}}function integrationResponse(){const errorResponse=[{selectionPattern:"4\\d{2}",statusCode:"400",responseTemplates:{"application/json":`{
"error": "Bad request!"
}`}},{selectionPattern:"5\\d{2}",statusCode:"500",responseTemplates:{"application/json":`{
"error": "$input.path('$.error')"
}`}}];return[{statusCode:"200",responseTemplates:{"application/json":["#set($inputRoot = $input.path('$'))",`#if($input.path('$.status').toString().equals("FAILED"))`,"#set($context.responseOverride.status = 500)","{",`"error": "$input.path('$.error')",`,`"cause": "$input.path('$.cause')"`,"}","#else","$input.path('$.output')","#end"].join(`
`)}},...errorResponse]}function requestTemplates(stateMachine,options){return{"application/json":templateString(stateMachine,options)}}function templateString(stateMachine,options){let templateStr,requestContextStr="";const includeHeader=options.headers??!1,includeQueryString=options.querystring??!0,includePath=options.path??!0,includeAuthorizer=options.authorizer??!1;return options.requestContext&&Object.keys(options.requestContext).length>0&&(requestContextStr=requestContext(options.requestContext)),templateStr=fs().readFileSync(path().join(__dirname,"stepfunctions.vtl"),{encoding:"utf-8"}),templateStr=templateStr.replace("%STATEMACHINE%",stateMachine.stateMachineArn),templateStr=templateStr.replace("%INCLUDE_HEADERS%",String(includeHeader)),templateStr=templateStr.replace("%INCLUDE_QUERYSTRING%",String(includeQueryString)),templateStr=templateStr.replace("%INCLUDE_PATH%",String(includePath)),templateStr=templateStr.replace("%INCLUDE_AUTHORIZER%",String(includeAuthorizer)),templateStr=templateStr.replace("%REQUESTCONTEXT%",requestContextStr),templateStr}function requestContext(requestContextObj){const context={accountId:requestContextObj?.accountId?"$context.identity.accountId":void 0,apiId:requestContextObj?.apiId?"$context.apiId":void 0,apiKey:requestContextObj?.apiKey?"$context.identity.apiKey":void 0,authorizerPrincipalId:requestContextObj?.authorizerPrincipalId?"$context.authorizer.principalId":void 0,caller:requestContextObj?.caller?"$context.identity.caller":void 0,cognitoAuthenticationProvider:requestContextObj?.cognitoAuthenticationProvider?"$context.identity.cognitoAuthenticationProvider":void 0,cognitoAuthenticationType:requestContextObj?.cognitoAuthenticationType?"$context.identity.cognitoAuthenticationType":void 0,cognitoIdentityId:requestContextObj?.cognitoIdentityId?"$context.identity.cognitoIdentityId":void 0,cognitoIdentityPoolId:requestContextObj?.cognitoIdentityPoolId?"$context.identity.cognitoIdentityPoolId":void 0,httpMethod:requestContextObj?.httpMethod?"$context.httpMethod":void 0,stage:requestContextObj?.stage?"$context.stage":void 0,sourceIp:requestContextObj?.sourceIp?"$context.identity.sourceIp":void 0,user:requestContextObj?.user?"$context.identity.user":void 0,userAgent:requestContextObj?.userAgent?"$context.identity.userAgent":void 0,userArn:requestContextObj?.userArn?"$context.identity.userArn":void 0,requestId:requestContextObj?.requestId?"$context.requestId":void 0,resourceId:requestContextObj?.resourceId?"$context.resourceId":void 0,resourcePath:requestContextObj?.resourcePath?"$context.resourcePath":void 0};return JSON.stringify(context).split('"').join("@@")}const METHOD_RESPONSES=[{statusCode:"200",responseModels:{"application/json":model_1().Model.EMPTY_MODEL}},{statusCode:"400",responseModels:{"application/json":model_1().Model.ERROR_MODEL}},{statusCode:"500",responseModels:{"application/json":model_1().Model.ERROR_MODEL}}];

View File

@@ -0,0 +1,75 @@
## Velocity Template used for API Gateway request mapping template
##
## This template forwards the request body, header, path, and querystring
## to the execution input of the state machine.
##
## "@@" is used here as a placeholder for '"' to avoid using escape characters.
#set($inputString = '')
#set($includeHeaders = %INCLUDE_HEADERS%)
#set($includeQueryString = %INCLUDE_QUERYSTRING%)
#set($includePath = %INCLUDE_PATH%)
#set($includeAuthorizer = %INCLUDE_AUTHORIZER%)
#set($allParams = $input.params())
{
"stateMachineArn": "%STATEMACHINE%",
#set($inputString = "$inputString,@@body@@: $input.body")
#if ($includeHeaders)
#set($inputString = "$inputString, @@header@@:{")
#foreach($paramName in $allParams.header.keySet())
#set($inputString = "$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.header.get($paramName))@@")
#if($foreach.hasNext)
#set($inputString = "$inputString,")
#end
#end
#set($inputString = "$inputString }")
#end
#if ($includeQueryString)
#set($inputString = "$inputString, @@querystring@@:{")
#foreach($paramName in $allParams.querystring.keySet())
#set($inputString = "$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.querystring.get($paramName))@@")
#if($foreach.hasNext)
#set($inputString = "$inputString,")
#end
#end
#set($inputString = "$inputString }")
#end
#if ($includePath)
#set($inputString = "$inputString, @@path@@:{")
#foreach($paramName in $allParams.path.keySet())
#set($inputString = "$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.path.get($paramName))@@")
#if($foreach.hasNext)
#set($inputString = "$inputString,")
#end
#end
#set($inputString = "$inputString }")
#end
#if ($includeAuthorizer)
#set($inputString = "$inputString, @@authorizer@@:{")
#foreach($paramName in $context.authorizer.keySet())
#set($inputString = "$inputString @@$paramName@@: @@$util.escapeJavaScript($context.authorizer.get($paramName))@@")
#if($foreach.hasNext)
#set($inputString = "$inputString,")
#end
#end
#set($inputString = "$inputString }")
#end
#set($requestContext = "%REQUESTCONTEXT%")
## Check if the request context should be included as part of the execution input
#if($requestContext && !$requestContext.empty)
#set($inputString = "$inputString,")
#set($inputString = "$inputString @@requestContext@@: $requestContext")
#end
#set($inputString = "$inputString}")
#set($inputString = $inputString.replaceAll("@@",'"'))
#set($len = $inputString.length() - 1)
"input": "{$util.escapeJavaScript($inputString.substring(1,$len)).replaceAll("\\'","'")}"
}

View File

@@ -0,0 +1,75 @@
export declare enum JsonSchemaVersion {
/**
* In API Gateway models are defined using the JSON schema draft 4.
* @see https://tools.ietf.org/html/draft-zyp-json-schema-04
*/
DRAFT4 = "http://json-schema.org/draft-04/schema#",
DRAFT7 = "http://json-schema.org/draft-07/schema#"
}
export declare enum JsonSchemaType {
NULL = "null",
BOOLEAN = "boolean",
OBJECT = "object",
ARRAY = "array",
NUMBER = "number",
INTEGER = "integer",
STRING = "string"
}
/**
* Represents a JSON schema definition of the structure of a
* REST API model. Copied from npm module jsonschema.
*
* @see http://json-schema.org/
* @see https://github.com/tdegrunt/jsonschema
*/
export interface JsonSchema {
readonly schema?: JsonSchemaVersion;
readonly id?: string;
readonly ref?: string;
readonly type?: JsonSchemaType | JsonSchemaType[];
readonly title?: string;
readonly description?: string;
readonly enum?: any[];
/**
* The default value if you use an enum.
*
* @default - not set
*/
readonly default?: any;
readonly format?: string;
readonly definitions?: {
[name: string]: JsonSchema;
};
readonly multipleOf?: number;
readonly maximum?: number;
readonly exclusiveMaximum?: boolean;
readonly minimum?: number;
readonly exclusiveMinimum?: boolean;
readonly maxLength?: number;
readonly minLength?: number;
readonly pattern?: string;
readonly items?: JsonSchema | JsonSchema[];
readonly additionalItems?: JsonSchema | boolean;
readonly maxItems?: number;
readonly minItems?: number;
readonly uniqueItems?: boolean;
readonly contains?: JsonSchema | JsonSchema[];
readonly maxProperties?: number;
readonly minProperties?: number;
readonly required?: string[];
readonly properties?: {
[name: string]: JsonSchema;
};
readonly additionalProperties?: JsonSchema | boolean;
readonly patternProperties?: {
[name: string]: JsonSchema;
};
readonly dependencies?: {
[name: string]: JsonSchema | string[];
};
readonly propertyNames?: JsonSchema;
readonly allOf?: JsonSchema[];
readonly anyOf?: JsonSchema[];
readonly oneOf?: JsonSchema[];
readonly not?: JsonSchema;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.JsonSchemaType=exports.JsonSchemaVersion=void 0;var JsonSchemaVersion;(function(JsonSchemaVersion2){JsonSchemaVersion2.DRAFT4="http://json-schema.org/draft-04/schema#",JsonSchemaVersion2.DRAFT7="http://json-schema.org/draft-07/schema#"})(JsonSchemaVersion||(exports.JsonSchemaVersion=JsonSchemaVersion={}));var JsonSchemaType;(function(JsonSchemaType2){JsonSchemaType2.NULL="null",JsonSchemaType2.BOOLEAN="boolean",JsonSchemaType2.OBJECT="object",JsonSchemaType2.ARRAY="array",JsonSchemaType2.NUMBER="number",JsonSchemaType2.INTEGER="integer",JsonSchemaType2.STRING="string"})(JsonSchemaType||(exports.JsonSchemaType=JsonSchemaType={}));

View File

@@ -0,0 +1,43 @@
import type { Construct } from 'constructs';
import type { LambdaIntegrationOptions } from './integrations';
import type { RestApiProps } from './restapi';
import { RestApi } from './restapi';
import type * as lambda from '../../aws-lambda';
export interface LambdaRestApiProps extends RestApiProps {
/**
* The default Lambda function that handles all requests from this API.
*
* This handler will be used as a the default integration for all methods in
* this API, unless specified otherwise in `addMethod`.
*/
readonly handler: lambda.IFunction;
/**
* Specific Lambda integration options.
*
* @default see defaults defined in `LambdaIntegrationOptions`.
*/
readonly integrationOptions?: LambdaIntegrationOptions;
/**
* If true, route all requests to the Lambda Function
*
* If set to false, you will need to explicitly define the API model using
* `addResource` and `addMethod` (or `addProxy`).
*
* @default true
*/
readonly proxy?: boolean;
}
/**
* Defines an API Gateway REST API with AWS Lambda proxy integration.
*
* Use the `proxy` property to define a greedy proxy ("{proxy+}") and "ANY"
* method from the specified path. If not defined, you will need to explicity
* add resources and methods to the API.
*/
export declare class LambdaRestApi extends RestApi {
/**
* Uniquely identifies this class.
*/
static readonly PROPERTY_INJECTION_ID: string;
constructor(scope: Construct, id: string, props: LambdaRestApiProps);
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,277 @@
import { Construct } from 'constructs';
import type { IStageRef } from './apigateway.generated';
import type { IAuthorizer } from './authorizer';
import type { Integration } from './integration';
import type { MethodResponse } from './methodresponse';
import type { IModel } from './model';
import type { IRequestValidator, RequestValidatorOptions } from './requestvalidator';
import type { IResource } from './resource';
import type { IRestApi, RestApi } from './restapi';
import * as cloudwatch from '../../aws-cloudwatch';
import * as iam from '../../aws-iam';
import { Resource } from '../../core';
export interface MethodOptions {
/**
* A friendly operation name for the method. For example, you can assign the
* OperationName of ListPets for the GET /pets method.
*/
readonly operationName?: string;
/**
* Method authorization.
* If the value is set of `Custom`, an `authorizer` must also be specified.
*
* If you're using one of the authorizers that are available via the `Authorizer` class, such as `Authorizer#token()`,
* it is recommended that this option not be specified. The authorizer will take care of setting the correct authorization type.
* However, specifying an authorization type using this property that conflicts with what is expected by the `Authorizer`
* will result in an error.
*
* @default - open access unless `authorizer` is specified
*/
readonly authorizationType?: AuthorizationType;
/**
* If `authorizationType` is `Custom`, this specifies the ID of the method
* authorizer resource.
* If specified, the value of `authorizationType` must be set to `Custom`
*/
readonly authorizer?: IAuthorizer;
/**
* Indicates whether the method requires clients to submit a valid API key.
* @default false
*/
readonly apiKeyRequired?: boolean;
/**
* The responses that can be sent to the client who calls the method.
* @default None
*
* This property is not required, but if these are not supplied for a Lambda
* proxy integration, the Lambda function must return a value of the correct format,
* for the integration response to be correctly mapped to a response to the client.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-settings-method-response.html
*/
readonly methodResponses?: MethodResponse[];
/**
* The request parameters that API Gateway accepts. Specify request parameters
* as key-value pairs (string-to-Boolean mapping), with a source as the key and
* a Boolean as the value. The Boolean specifies whether a parameter is required.
* A source must match the format method.request.location.name, where the location
* is querystring, path, or header, and name is a valid, unique parameter name.
* @default None
*/
readonly requestParameters?: {
[param: string]: boolean;
};
/**
* The models which describe data structure of request payload. When
* combined with `requestValidator` or `requestValidatorOptions`, the service
* will validate the API request payload before it reaches the API's Integration (including proxies).
* Specify `requestModels` as key-value pairs, with a content type
* (e.g. `'application/json'`) as the key and an API Gateway Model as the value.
*
* @example
*
* declare const api: apigateway.RestApi;
* declare const userLambda: lambda.Function;
*
* const userModel: apigateway.Model = api.addModel('UserModel', {
* schema: {
* type: apigateway.JsonSchemaType.OBJECT,
* properties: {
* userId: {
* type: apigateway.JsonSchemaType.STRING
* },
* name: {
* type: apigateway.JsonSchemaType.STRING
* }
* },
* required: ['userId']
* }
* });
* api.root.addResource('user').addMethod('POST',
* new apigateway.LambdaIntegration(userLambda), {
* requestModels: {
* 'application/json': userModel
* }
* }
* );
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-settings-method-request.html#setup-method-request-model
*/
readonly requestModels?: {
[param: string]: IModel;
};
/**
* The ID of the associated request validator.
* Only one of `requestValidator` or `requestValidatorOptions` must be specified.
* Works together with `requestModels` or `requestParameters` to validate
* the request before it reaches integration like Lambda Proxy Integration.
* @default - No default validator
*/
readonly requestValidator?: IRequestValidator;
/**
* A list of authorization scopes configured on the method. The scopes are used with
* a COGNITO_USER_POOLS authorizer to authorize the method invocation.
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-method.html#cfn-apigateway-method-authorizationscopes
* @default - no authorization scopes
*/
readonly authorizationScopes?: string[];
/**
* Request validator options to create new validator
* Only one of `requestValidator` or `requestValidatorOptions` must be specified.
* Works together with `requestModels` or `requestParameters` to validate
* the request before it reaches integration like Lambda Proxy Integration.
* @default - No default validator
*/
readonly requestValidatorOptions?: RequestValidatorOptions;
}
export interface MethodProps {
/**
* The resource this method is associated with. For root resource methods,
* specify the `RestApi` object.
*/
readonly resource: IResource;
/**
* The HTTP method ("GET", "POST", "PUT", ...) that clients use to call this method.
*/
readonly httpMethod: string;
/**
* The backend system that the method calls when it receives a request.
*
* @default - a new `MockIntegration`.
*/
readonly integration?: Integration;
/**
* Method options.
*
* @default - No options.
*/
readonly options?: MethodOptions;
}
export declare class Method extends Resource {
/**
* Uniquely identifies this class.
*/
static readonly PROPERTY_INJECTION_ID: string;
/** @attribute */
readonly methodId: string;
readonly httpMethod: string;
readonly resource: IResource;
/**
* The API Gateway RestApi associated with this method.
*/
readonly api: IRestApi;
private readonly methodResponses;
constructor(scope: Construct, id: string, props: MethodProps);
/**
* Returns an execute-api ARN for this method:
*
* arn:aws:execute-api:{region}:{account}:{restApiId}/{stage}/{method}/{path}
*
* NOTE: {stage} will refer to the `restApi.deploymentStage`, which will
* automatically set if auto-deploy is enabled, or can be explicitly assigned.
* When not configured, {stage} will be set to '*', as a shorthand for 'all stages'.
*
* @attribute
*/
get methodArn(): string;
/**
* Returns an execute-api ARN for this method's "test-invoke-stage" stage.
* This stage is used by the AWS Console UI when testing the method.
*/
get testMethodArn(): string;
/**
* Add a method response to this method
*
* You should only add one method reponse for every status code. The API allows it
* for historical reasons, but will add a warning if this happens. If you do, your Method
* will nondeterministically use one of the responses, and ignore the rest.
*/
addMethodResponse(methodResponse: MethodResponse): void;
/**
* Get API Gateway Method's authorization type
* @param options API Gateway Method's options to use
* @param defaultMethodOptions API Gateway resource's default Method's options to use
* @param authorizer Authorizer used for API Gateway Method
* @returns API Gateway Method's authorizer type
*/
private getMethodAuthorizationType;
private renderIntegration;
private renderMethodResponses;
private renderRequestModels;
private requestValidatorId;
/**
* Returns the given named metric for this API method
*/
metric(metricName: string, stage: IStageRef, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of client-side errors captured in a given period.
*
* @default - sum over 5 minutes
*/
metricClientError(stage: IStageRef, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of server-side errors captured in a given period.
*
* @default - sum over 5 minutes
*/
metricServerError(stage: IStageRef, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of requests served from the API cache in a given period.
*
* @default - sum over 5 minutes
*/
metricCacheHitCount(stage: IStageRef, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of requests served from the backend in a given period,
* when API caching is enabled.
*
* @default - sum over 5 minutes
*/
metricCacheMissCount(stage: IStageRef, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the total number API requests in a given period.
*
* @default - sample count over 5 minutes
*/
metricCount(stage: IStageRef, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the time between when API Gateway relays a request to the backend
* and when it receives a response from the backend.
*
* @default - average over 5 minutes.
*/
metricIntegrationLatency(stage: IStageRef, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* The time between when API Gateway receives a request from a client
* and when it returns a response to the client.
* The latency includes the integration latency and other API Gateway overhead.
*
* @default - average over 5 minutes.
*/
metricLatency(stage: IStageRef, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Grants an IAM principal permission to invoke this method.
* [disable-awslint:no-grants]
*
* @param grantee the principal
*/
grantExecute(grantee: iam.IGrantable): iam.Grant;
private cannedMetric;
}
export declare enum AuthorizationType {
/**
* Open access.
*/
NONE = "NONE",
/**
* Use AWS IAM permissions.
*/
IAM = "AWS_IAM",
/**
* Use a custom authorizer.
*/
CUSTOM = "CUSTOM",
/**
* Use an AWS Cognito user pool.
*/
COGNITO = "COGNITO_USER_POOLS"
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,28 @@
import type { IModel } from './model';
export interface MethodResponse {
/**
* The method response's status code, which you map to an IntegrationResponse.
* Required.
*/
readonly statusCode: string;
/**
* Response parameters that API Gateway sends to the client that called a method.
* Specify response parameters as key-value pairs (string-to-Boolean maps), with
* a destination as the key and a Boolean as the value. Specify the destination
* using the following pattern: method.response.header.name, where the name is a
* valid, unique header name. The Boolean specifies whether a parameter is required.
* @default None
*/
readonly responseParameters?: {
[destination: string]: boolean;
};
/**
* The resources used for the response's content type. Specify response models as
* key-value pairs (string-to-string maps), with a content type as the key and a Model
* resource name as the value.
* @default None
*/
readonly responseModels?: {
[contentType: string]: IModel;
};
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});

View File

@@ -0,0 +1,105 @@
import type { Construct } from 'constructs';
import type * as jsonSchema from './json-schema';
import type { IRestApi } from './restapi';
import { Resource } from '../../core';
export interface IModel {
/**
* Returns the model name, such as 'myModel'
*
* @attribute
*/
readonly modelId: string;
}
export interface ModelOptions {
/**
* The content type for the model. You can also force a
* content type in the request or response model mapping.
*
* @default 'application/json'
*/
readonly contentType?: string;
/**
* A description that identifies this model.
* @default None
*/
readonly description?: string;
/**
* A name for the model.
*
* Important
* If you specify a name, you cannot perform updates that
* require replacement of this resource. You can perform
* updates that require no or some interruption. If you
* must replace the resource, specify a new name.
*
* @default <auto> If you don't specify a name,
* AWS CloudFormation generates a unique physical ID and
* uses that ID for the model name. For more information,
* see Name Type.
*/
readonly modelName?: string;
/**
* The schema to use to transform data to one or more output formats.
* Specify null ({}) if you don't want to specify a schema.
*/
readonly schema: jsonSchema.JsonSchema;
}
export interface ModelProps extends ModelOptions {
/**
* The rest API that this model is part of.
*
* The reason we need the RestApi object itself and not just the ID is because the model
* is being tracked by the top-level RestApi object for the purpose of calculating its
* hash to determine the ID of the deployment. This allows us to automatically update
* the deployment when the model of the REST API changes.
*/
readonly restApi: IRestApi;
}
export declare class Model extends Resource implements IModel {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
/**
* Represents a reference to a REST API's Error model, which is available
* as part of the model collection by default. This can be used for mapping
* error JSON responses from an integration to a client, where a simple
* generic message field is sufficient to map and return an error payload.
*
* Definition
* {
* "$schema" : "http://json-schema.org/draft-04/schema#",
* "title" : "Error Schema",
* "type" : "object",
* "properties" : {
* "message" : { "type" : "string" }
* }
* }
*/
static readonly ERROR_MODEL: IModel;
/**
* Represents a reference to a REST API's Empty model, which is available
* as part of the model collection by default. This can be used for mapping
* JSON responses from an integration to what is returned to a client,
* where strong typing is not required. In the absence of any defined
* model, the Empty model will be used to return the response payload
* unmapped.
*
* Definition
* {
* "$schema" : "http://json-schema.org/draft-04/schema#",
* "title" : "Empty Schema",
* "type" : "object"
* }
*
* @see https://docs.amazonaws.cn/en_us/apigateway/latest/developerguide/models-mappings.html#models-mappings-models
*/
static readonly EMPTY_MODEL: IModel;
static fromModelName(scope: Construct, id: string, modelName: string): IModel;
/**
* Returns the model name, such as 'myModel'
*
* @attribute
*/
get modelId(): string;
private readonly resource;
constructor(scope: Construct, id: string, props: ModelProps);
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,58 @@
import type { Construct } from 'constructs';
import type { IRequestValidatorRef, RequestValidatorReference } from './apigateway.generated';
import type { IRestApi } from './restapi';
import type { IResource } from '../../core';
import { Resource } from '../../core';
export interface IRequestValidator extends IResource, IRequestValidatorRef {
/**
* ID of the request validator, such as abc123
*
* @attribute
*/
readonly requestValidatorId: string;
}
export interface RequestValidatorOptions {
/**
* The name of this request validator.
*
* @default None
*/
readonly requestValidatorName?: string;
/**
* Indicates whether to validate the request body according to
* the configured schema for the targeted API and method.
*
* @default false
*/
readonly validateRequestBody?: boolean;
/**
* Indicates whether to validate request parameters.
*
* @default false
*/
readonly validateRequestParameters?: boolean;
}
export interface RequestValidatorProps extends RequestValidatorOptions {
/**
* The rest API that this model is part of.
*
* The reason we need the RestApi object itself and not just the ID is because the model
* is being tracked by the top-level RestApi object for the purpose of calculating its
* hash to determine the ID of the deployment. This allows us to automatically update
* the deployment when the model of the REST API changes.
*/
readonly restApi: IRestApi;
}
export declare class RequestValidator extends Resource implements IRequestValidator {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
static fromRequestValidatorId(scope: Construct, id: string, requestValidatorId: string): IRequestValidator;
/**
* ID of the request validator, such as abc123
*
* @attribute
*/
readonly requestValidatorId: string;
constructor(scope: Construct, id: string, props: RequestValidatorProps);
get requestValidatorRef(): RequestValidatorReference;
}

View File

@@ -0,0 +1 @@
"use strict";var __esDecorate=exports&&exports.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(f!==void 0&&typeof f!="function")throw new TypeError("Function expected");return f}for(var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),_,done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]=p==="access"?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!="object")throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&(kind==="field"?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0},__runInitializers=exports&&exports.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RequestValidator=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var apigateway_generated_1=()=>{var tmp=require("./apigateway.generated");return apigateway_generated_1=()=>tmp,tmp},restapi_1=()=>{var tmp=require("./restapi");return restapi_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},metadata_resource_1=()=>{var tmp=require("../../core/lib/metadata-resource");return metadata_resource_1=()=>tmp,tmp},prop_injectable_1=()=>{var tmp=require("../../core/lib/prop-injectable");return prop_injectable_1=()=>tmp,tmp};let RequestValidator=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=core_1().Resource;var RequestValidator2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),RequestValidator2=_classThis=_classDescriptor.value,_metadata&&Object.defineProperty(_classThis,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.RequestValidator",version:"2.252.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-apigateway.RequestValidator";static fromRequestValidatorId(scope,id,requestValidatorId){class Import extends core_1().Resource{requestValidatorRef={requestValidatorId};requestValidatorId=requestValidatorId}return new Import(scope,id)}requestValidatorId;constructor(scope,id,props){super(scope,id,{physicalName:props.requestValidatorName});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_RequestValidatorProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,RequestValidator2),error}(0,metadata_resource_1().addConstructMetadata)(this,props);const validatorProps={name:this.physicalName,restApiId:props.restApi.restApiId,validateRequestBody:props.validateRequestBody,validateRequestParameters:props.validateRequestParameters},resource=new(apigateway_generated_1()).CfnRequestValidator(this,"Resource",validatorProps);this.requestValidatorId=resource.ref;const deployment=props.restApi instanceof restapi_1().RestApi?props.restApi.latestDeployment:void 0;deployment&&(deployment.node.addDependency(resource),deployment.addToLogicalId({validator:validatorProps}))}get requestValidatorRef(){return{requestValidatorId:this.requestValidatorId}}static{__runInitializers(_classThis,_classExtraInitializers)}};return RequestValidator2=_classThis})();exports.RequestValidator=RequestValidator;

View File

@@ -0,0 +1,223 @@
import type { Construct } from 'constructs';
import type { IResourceRef, ResourceReference } from './apigateway.generated';
import type { CorsOptions } from './cors';
import type { Integration } from './integration';
import type { MethodOptions } from './method';
import { Method } from './method';
import type { IRestApi, RestApi } from './restapi';
import type { IResource as IResourceBase } from '../../core';
import { Resource as ResourceConstruct } from '../../core';
export interface IResource extends IResourceBase, IResourceRef {
/**
* The parent of this resource or undefined for the root resource.
*/
readonly parentResource?: IResource;
/**
* The rest API that this resource is part of.
*
* The reason we need the RestApi object itself and not just the ID is because the model
* is being tracked by the top-level RestApi object for the purpose of calculating its
* hash to determine the ID of the deployment. This allows us to automatically update
* the deployment when the model of the REST API changes.
*/
readonly api: IRestApi;
/**
* The ID of the resource.
* @attribute
*/
readonly resourceId: string;
/**
* The full path of this resource.
*/
readonly path: string;
/**
* An integration to use as a default for all methods created within this
* API unless an integration is specified.
*/
readonly defaultIntegration?: Integration;
/**
* Method options to use as a default for all methods created within this
* API unless custom options are specified.
*/
readonly defaultMethodOptions?: MethodOptions;
/**
* Default options for CORS preflight OPTIONS method.
*/
readonly defaultCorsPreflightOptions?: CorsOptions;
/**
* Gets or create all resources leading up to the specified path.
*
* - Path may only start with "/" if this method is called on the root resource.
* - All resources are created using default options.
*
* @param path The relative path
* @returns a new or existing resource.
*/
resourceForPath(path: string): Resource;
/**
* Defines a new child resource where this resource is the parent.
* @param pathPart The path part for the child resource
* @param options Resource options
* @returns A Resource object
*/
addResource(pathPart: string, options?: ResourceOptions): Resource;
/**
* Retrieves a child resource by path part.
*
* @param pathPart The path part of the child resource
* @returns the child resource or undefined if not found
*/
getResource(pathPart: string): IResource | undefined;
/**
* Adds a greedy proxy resource ("{proxy+}") and an ANY method to this route.
* @param options Default integration and method options.
*/
addProxy(options?: ProxyResourceOptions): ProxyResource;
/**
* Defines a new method for this resource.
* @param httpMethod The HTTP method
* @param target The target backend integration for this method
* @param options Method options, such as authentication.
*
* @returns The newly created `Method` object.
*/
addMethod(httpMethod: string, target?: Integration, options?: MethodOptions): Method;
/**
* Adds an OPTIONS method to this resource which responds to Cross-Origin
* Resource Sharing (CORS) preflight requests.
*
* Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional
* HTTP headers to tell browsers to give a web application running at one
* origin, access to selected resources from a different origin. A web
* application executes a cross-origin HTTP request when it requests a
* resource that has a different origin (domain, protocol, or port) from its
* own.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
* @param options CORS options
* @returns a `Method` object
*/
addCorsPreflight(options: CorsOptions): Method;
}
export interface ResourceOptions {
/**
* An integration to use as a default for all methods created within this
* API unless an integration is specified.
*
* @default - Inherited from parent.
*/
readonly defaultIntegration?: Integration;
/**
* Method options to use as a default for all methods created within this
* API unless custom options are specified.
*
* @default - Inherited from parent.
*/
readonly defaultMethodOptions?: MethodOptions;
/**
* Adds a CORS preflight OPTIONS method to this resource and all child
* resources.
*
* You can add CORS at the resource-level using `addCorsPreflight`.
*
* @default - CORS is disabled
*/
readonly defaultCorsPreflightOptions?: CorsOptions;
}
export interface ResourceProps extends ResourceOptions {
/**
* The parent resource of this resource. You can either pass another
* `Resource` object or a `RestApi` object here.
*/
readonly parent: IResource;
/**
* A path name for the resource.
*/
readonly pathPart: string;
}
export declare abstract class ResourceBase extends ResourceConstruct implements IResource {
abstract readonly parentResource?: IResource;
abstract readonly api: IRestApi;
abstract readonly resourceId: string;
abstract readonly path: string;
abstract readonly defaultIntegration?: Integration;
abstract readonly defaultMethodOptions?: MethodOptions;
abstract readonly defaultCorsPreflightOptions?: CorsOptions;
private readonly children;
constructor(scope: Construct, id: string);
addResource(pathPart: string, options?: ResourceOptions): Resource;
addMethod(httpMethod: string, integration?: Integration, options?: MethodOptions): Method;
addProxy(options?: ProxyResourceOptions): ProxyResource;
addCorsPreflight(options: CorsOptions): Method;
getResource(pathPart: string): IResource | undefined;
/**
* @internal
*/
_trackChild(pathPart: string, resource: Resource): void;
resourceForPath(path: string): Resource;
get resourceRef(): ResourceReference;
}
/**
* Attributes that can be specified when importing a Resource
*/
export interface ResourceAttributes {
/**
* The ID of the resource.
*/
readonly resourceId: string;
/**
* The rest API that this resource is part of.
*/
readonly restApi: IRestApi;
/**
* The full path of this resource.
*/
readonly path: string;
}
export declare class Resource extends ResourceBase {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
/**
* Import an existing resource
*/
static fromResourceAttributes(scope: Construct, id: string, attrs: ResourceAttributes): IResource;
readonly parentResource?: IResource;
readonly api: IRestApi;
readonly resourceId: string;
readonly path: string;
readonly defaultIntegration?: Integration;
readonly defaultMethodOptions?: MethodOptions;
readonly defaultCorsPreflightOptions?: CorsOptions;
constructor(scope: Construct, id: string, props: ResourceProps);
}
export interface ProxyResourceOptions extends ResourceOptions {
/**
* 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.
*
* @default true
*/
readonly anyMethod?: boolean;
}
export interface ProxyResourceProps extends ProxyResourceOptions {
/**
* The parent resource of this resource. You can either pass another
* `Resource` object or a `RestApi` object here.
*/
readonly parent: IResource;
}
/**
* Defines a {proxy+} greedy resource and an ANY method on a route.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-set-up-simple-proxy.html
*/
export declare class ProxyResource extends Resource {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
/**
* If `props.anyMethod` is `true`, this will be the reference to the 'ANY'
* method associated with this proxy resource.
*/
readonly anyMethod?: Method;
constructor(scope: Construct, id: string, props: ProxyResourceProps);
addMethod(httpMethod: string, integration?: Integration, options?: MethodOptions): Method;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,676 @@
import * as resource_1 from "./resource";
import type { Construct } from 'constructs';
import type { ApiDefinition } from './api-definition';
import type { ApiKeyOptions, IApiKey } from './api-key';
import type { IRestApiRef, RestApiReference } from './apigateway.generated';
import { CfnAccount, CfnRestApi } from './apigateway.generated';
import { Deployment } from './deployment';
import type { DomainNameOptions } from './domain-name';
import { DomainName } from './domain-name';
import type { GatewayResponseOptions } from './gateway-response';
import { GatewayResponse } from './gateway-response';
import type { Method } from './method';
import type { ModelOptions } from './model';
import { Model } from './model';
import type { RequestValidatorOptions } from './requestvalidator';
import { RequestValidator } from './requestvalidator';
import type { IResource, ResourceOptions } from './resource';
import type { StageOptions } from './stage';
import { Stage } from './stage';
import type { UsagePlanProps } from './usage-plan';
import { UsagePlan } from './usage-plan';
import * as cloudwatch from '../../aws-cloudwatch';
import type * as ec2 from '../../aws-ec2';
import * as iam from '../../aws-iam';
import type { IResource as IResourceBase, Size } from '../../core';
import { RemovalPolicy, Resource } from '../../core';
export interface IRestApi extends IResourceBase, IRestApiRef {
/**
* The ID of this API Gateway RestApi.
* @attribute
*/
readonly restApiId: string;
/**
* The name of this API Gateway RestApi.
* @attribute
*/
readonly restApiName: string;
/**
* The resource ID of the root resource.
* @attribute
*/
readonly restApiRootResourceId: string;
/**
* API Gateway deployment that represents the latest changes of the API.
* This resource will be automatically updated every time the REST API model changes.
* `undefined` when no deployment is configured.
*/
readonly latestDeployment?: Deployment;
/**
* API Gateway stage that points to the latest deployment (if defined).
*/
deploymentStage: Stage;
/**
* Represents the root resource ("/") of this API. Use it to define the API model:
*
* api.root.addMethod('ANY', redirectToHomePage); // "ANY /"
* api.root.addResource('friends').addMethod('GET', getFriendsHandler); // "GET /friends"
*
*/
readonly root: IResource;
/**
* Gets the "execute-api" ARN
* @returns The "execute-api" ARN.
* @default "*" returns the execute API ARN for all methods/resources in
* this API.
* @param method The method (default `*`)
* @param path The resource path. Must start with '/' (default `*`)
* @param stage The stage (default `*`)
*/
arnForExecuteApi(method?: string, path?: string, stage?: string): string;
}
/**
* Represents the props that all Rest APIs share
*/
export interface RestApiBaseProps {
/**
* Indicates if a Deployment should be automatically created for this API,
* and recreated when the API model (resources, methods) changes.
*
* 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
*/
readonly deploy?: boolean;
/**
* Options for the API Gateway stage that will always point to the latest
* deployment when `deploy` is enabled. If `deploy` is disabled,
* this value cannot be set.
*
* @default - Based on defaults of `StageOptions`.
*/
readonly deployOptions?: StageOptions;
/**
* Retains old deployment resources when the API changes. This allows
* manually reverting stages to point to old deployments via the AWS
* Console.
*
* @default false
*/
readonly retainDeployments?: boolean;
/**
* A name for the API Gateway RestApi resource.
*
* @default - ID of the RestApi construct.
*/
readonly restApiName?: string;
/**
* Custom header parameters for the request.
* @see https://docs.aws.amazon.com/cli/latest/reference/apigateway/import-rest-api.html
*
* @default - No parameters.
*/
readonly parameters?: {
[key: string]: string;
};
/**
* A policy document that contains the permissions for this RestApi
*
* @default - No policy.
*/
readonly policy?: iam.PolicyDocument;
/**
* Indicates whether to roll back the resource if a warning occurs while API
* Gateway is creating the RestApi resource.
*
* @default false
*/
readonly failOnWarnings?: boolean;
/**
* Configure a custom domain name and map it to this API.
*
* @default - no domain name is defined, use `addDomainName` or directly define a `DomainName`.
*/
readonly domainName?: DomainNameOptions;
/**
* Automatically configure an AWS CloudWatch role for API Gateway.
*
* @default - false if `@aws-cdk/aws-apigateway:disableCloudWatchRole` is enabled, true otherwise
*/
readonly cloudWatchRole?: boolean;
/**
* The removal policy applied to the AWS CloudWatch role when this resource
* is removed from the application.
* Requires `cloudWatchRole` to be enabled.
*
* @default - RemovalPolicy.RETAIN
*/
readonly cloudWatchRoleRemovalPolicy?: RemovalPolicy;
/**
* Export name for the CfnOutput containing the API endpoint
*
* @default - when no export name is given, output will be created without export
*/
readonly endpointExportName?: string;
/**
* A list of the endpoint types of the API. Use this property when creating
* an API.
*
* @default EndpointType.EDGE
*/
readonly endpointTypes?: EndpointType[];
/**
* The EndpointConfiguration property type specifies the endpoint types of a REST API
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-restapi-endpointconfiguration.html
*
* @default EndpointType.EDGE
*/
readonly endpointConfiguration?: EndpointConfiguration;
/**
* Specifies whether clients can invoke the API using the default execute-api
* endpoint. To require that clients use a custom domain name to invoke the
* API, disable the default endpoint.
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html
*
* @default false
*/
readonly disableExecuteApiEndpoint?: boolean;
/**
* A description of the RestApi construct.
*
* @default - 'Automatically created by the RestApi construct'
*/
readonly description?: string;
}
/**
* Props to create a new instance of RestApi
*/
export interface RestApiProps extends resource_1.ResourceOptions, RestApiBaseProps {
/**
* 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.
*/
readonly binaryMediaTypes?: string[];
/**
* 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. 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.
* @deprecated - superseded by `minCompressionSize`
*/
readonly minimumCompressionSize?: number;
/**
* 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. 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.
*/
readonly minCompressionSize?: Size;
/**
* The ID of the API Gateway RestApi resource that you want to clone.
*
* @default - None.
*/
readonly cloneFrom?: IRestApi;
/**
* The source of the API key for metering requests according to a usage
* plan.
*
* @default - Metering is disabled.
*/
readonly apiKeySourceType?: ApiKeySourceType;
}
/**
* Props to instantiate a new SpecRestApi
*/
export interface SpecRestApiProps extends RestApiBaseProps {
/**
* An OpenAPI definition compatible with API Gateway.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-import-api.html
*/
readonly apiDefinition: ApiDefinition;
/**
* The list of binary media mime-types that are supported by the SpecRestApi
* resource, such as "image/png" or "application/octet-stream"
*
* @default - SpecRestApi supports only UTF-8-encoded text payloads.
*/
readonly binaryMediaTypes?: string[];
/**
* 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. 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.
*/
readonly minCompressionSize?: Size;
/**
* The Mode that determines how API Gateway handles resource updates.
*
* Valid values are `overwrite` or `merge`.
*
* For `overwrite`, the new API definition replaces the existing one.
* The existing API identifier remains unchanged.
*
* For `merge`, the new API definition is merged with the existing API.
*
* If you don't specify this property, a default value is chosen:
* - For REST APIs created before March 29, 2021, the default is `overwrite`
* - For REST APIs created after March 29, 2021, the new API definition takes precedence, but any container types such as endpoint configurations and binary media types are merged with the existing API.
*
* Use the default mode to define top-level RestApi properties in addition to using OpenAPI.
* Generally, it's preferred to use API Gateway's OpenAPI extensions to model these properties.
*
* @default - `merge` for REST APIs created after March 29, 2021, otherwise `overwrite`
*/
readonly mode?: RestApiMode;
}
/**
* Base implementation that are common to various implementations of IRestApi
*/
export declare abstract class RestApiBase extends Resource implements IRestApi, iam.IResourceWithPolicy {
/**
* Checks if the given object is an instance of RestApiBase.
* @internal
*/
static _isRestApiBase(x: any): x is RestApiBase;
/**
* API Gateway deployment that represents the latest changes of the API.
* This resource will be automatically updated every time the REST API model changes.
* This will be undefined if `deploy` is false.
*/
get latestDeployment(): Deployment | undefined;
/**
* The first domain name mapped to this API, if defined through the `domainName`
* configuration prop, or added via `addDomainName`
*/
get domainName(): DomainName | undefined;
/**
* The deployed root URL of this REST API.
*/
get url(): string;
/**
* The ID of this API Gateway RestApi.
*/
abstract readonly restApiId: string;
/**
* The resource ID of the root resource.
*
* @attribute
*/
abstract readonly restApiRootResourceId: string;
/**
* Represents the root resource of this API endpoint ('/').
* Resources and Methods are added to this resource.
*/
abstract readonly root: IResource;
/**
* API Gateway stage that points to the latest deployment (if defined).
*
* If `deploy` is disabled, you will need to explicitly assign this value in order to
* set up integrations.
*/
deploymentStage: Stage;
/**
* A human friendly name for this Rest API. Note that this is different from `restApiId`.
* @attribute
*/
readonly restApiName: string;
private _latestDeployment?;
private _domainName?;
private allowedVpcEndpoints;
protected resourcePolicy?: iam.PolicyDocument;
protected cloudWatchAccount?: CfnAccount;
constructor(scope: Construct, id: string, props?: RestApiBaseProps);
abstract addToResourcePolicy(statement: iam.PolicyStatement): iam.AddToResourcePolicyResult;
/**
* Returns the URL for an HTTP path.
*
* Fails if `deploymentStage` is not set either by `deploy` or explicitly.
*/
urlForPath(path?: string): string;
/**
* Defines an API Gateway domain name and maps it to this API.
* @param id The construct id
* @param options custom domain options
*/
addDomainName(id: string, options: DomainNameOptions): DomainName;
/**
* Adds a usage plan.
*/
addUsagePlan(id: string, props?: UsagePlanProps): UsagePlan;
arnForExecuteApi(method?: string, path?: string, stage?: string): string;
/**
* Adds a new gateway response.
*/
addGatewayResponse(id: string, options: GatewayResponseOptions): GatewayResponse;
/**
* Add an ApiKey to the deploymentStage
*/
addApiKey(id: string, options?: ApiKeyOptions): IApiKey;
/**
* Add a resource policy that only allows API execution from a VPC Endpoint to create a private API.
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-resource-policies-examples.html#apigateway-resource-policies-source-vpc-example
*
* @param vpcEndpoints the interface VPC endpoints to grant access to
*/
grantInvokeFromVpcEndpointsOnly(vpcEndpoints: ec2.IVpcEndpoint[]): void;
/**
* Returns the given named metric for this API
*/
metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of client-side errors captured in a given period.
*
* Default: sum over 5 minutes
*/
metricClientError(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of server-side errors captured in a given period.
*
* Default: sum over 5 minutes
*/
metricServerError(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of requests served from the API cache in a given period.
*
* Default: sum over 5 minutes
*/
metricCacheHitCount(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of requests served from the backend in a given period,
* when API caching is enabled.
*
* Default: sum over 5 minutes
*/
metricCacheMissCount(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the total number API requests in a given period.
*
* Default: sample count over 5 minutes
*/
metricCount(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the time between when API Gateway relays a request to the backend
* and when it receives a response from the backend.
*
* Default: average over 5 minutes.
*/
metricIntegrationLatency(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* The time between when API Gateway receives a request from a client
* and when it returns a response to the client.
* The latency includes the integration latency and other API Gateway overhead.
*
* Default: average over 5 minutes.
*/
metricLatency(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Internal API used by `Method` to keep an inventory of methods at the API
* level for validation purposes.
*
* @internal
*/
_attachMethod(method: Method): void;
/**
* Associates a Deployment resource with this REST API.
*
* @internal
*/
_attachDeployment(deployment: Deployment): void;
/**
* Associates a Stage with this REST API
*
* @internal
*/
_attachStage(stage: Stage): void;
/**
* @internal
*/
protected _configureCloudWatchRole(apiResource: CfnRestApi, cloudWatchRole?: boolean, cloudWatchRoleRemovalPolicy?: RemovalPolicy): void;
/**
* @internal
*/
protected _configureDeployment(props: RestApiBaseProps): void;
/**
* @internal
*/
protected _configureEndpoints(props: RestApiProps): CfnRestApi.EndpointConfigurationProperty | undefined;
private cannedMetric;
get restApiRef(): RestApiReference;
}
/**
* Represents a REST API in Amazon API Gateway, created with an OpenAPI specification.
*
* Some properties normally accessible on @see `RestApi` - such as the description -
* must be declared in the specification. All Resources and Methods need to be defined as
* part of the OpenAPI specification file, and cannot be added via the CDK.
*
* By default, the API will automatically be deployed and accessible from a
* public endpoint.
*
*
* @resource AWS::ApiGateway::RestApi
*/
export declare class SpecRestApi extends RestApiBase {
/**
* Uniquely identifies this class.
*/
static readonly PROPERTY_INJECTION_ID: string;
/**
* The ID of this API Gateway RestApi.
*/
readonly restApiId: string;
/**
* The resource ID of the root resource.
*
* @attribute
*/
readonly restApiRootResourceId: string;
readonly root: IResource;
constructor(scope: Construct, id: string, props: SpecRestApiProps);
/**
* Adds a statement to the resource policy associated with this rest api.
* A resource policy will be automatically created upon the first call to `addToResourcePolicy`.
*
* Note that this does not work with imported rest api.
*
* @param statement The policy statement to add
*/
addToResourcePolicy(statement: iam.PolicyStatement): iam.AddToResourcePolicyResult;
}
/**
* Attributes that can be specified when importing a RestApi
*/
export interface RestApiAttributes {
/**
* The ID of the API Gateway RestApi.
*/
readonly restApiId: string;
/**
* The name of the API Gateway RestApi.
*
* @default - ID of the RestApi construct.
*/
readonly restApiName?: string;
/**
* The resource ID of the root resource.
*/
readonly rootResourceId: string;
}
/**
* Represents a REST API in Amazon API Gateway.
*
* Use `addResource` and `addMethod` to configure the API model.
*
* By default, the API will automatically be deployed and accessible from a
* public endpoint.
*/
export declare class RestApi extends RestApiBase {
/**
* Uniquely identifies this class.
*/
static readonly PROPERTY_INJECTION_ID: string;
/**
* Return whether the given object is a `RestApi`
*/
static isRestApi(x: any): x is RestApi;
/**
* Import an existing RestApi.
*/
static fromRestApiId(scope: Construct, id: string, restApiId: string): IRestApi;
/**
* Import an existing RestApi that can be configured with additional Methods and Resources.
*/
static fromRestApiAttributes(scope: Construct, id: string, attrs: RestApiAttributes): IRestApi;
readonly restApiId: string;
readonly root: IResource;
readonly restApiRootResourceId: string;
/**
* The list of methods bound to this RestApi
*/
readonly methods: Method[];
/**
* This list of deployments bound to this RestApi
*/
private readonly deployments;
constructor(scope: Construct, id: string, props?: RestApiProps);
/**
* Adds a statement to the resource policy associated with this rest api.
* A resource policy will be automatically created upon the first call to `addToResourcePolicy`.
*
* Note that this does not work with imported rest api.
*
* @param statement The policy statement to add
*/
addToResourcePolicy(statement: iam.PolicyStatement): iam.AddToResourcePolicyResult;
/**
* Adds a new model.
*/
addModel(id: string, props: ModelOptions): Model;
/**
* Adds a new request validator.
*/
addRequestValidator(id: string, props: RequestValidatorOptions): RequestValidator;
/**
* Internal API used by `Method` to keep an inventory of methods at the API
* level for validation purposes.
*
* @internal
*/
_attachMethod(method: Method): void;
/**
* Attaches a deployment to this REST API.
*
* @internal
*/
_attachDeployment(deployment: Deployment): void;
/**
* Performs validation of the REST API.
*/
private validateRestApi;
}
/**
* The endpoint configuration of a REST API, including VPCs and endpoint types.
*
* EndpointConfiguration is a property of the AWS::ApiGateway::RestApi resource.
*/
export interface EndpointConfiguration {
/**
* A list of endpoint types of an API or its custom domain name.
*
* @default EndpointType.EDGE
*/
readonly types: EndpointType[];
/**
* A list of VPC Endpoints against which to create Route53 ALIASes
*
* @default - no ALIASes are created for the endpoint.
*/
readonly vpcEndpoints?: ec2.IVpcEndpoint[];
/**
* The IP address types that can invoke the API.
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-ip-address-type.html
*
* @default undefined - AWS default is DUAL_STACK for private API, IPV4 for all other APIs.
*/
readonly ipAddressType?: IpAddressType;
}
/**
* Supported IP Address Types
*/
export declare enum IpAddressType {
/**
* IPv4 address type
*/
IPV4 = "ipv4",
/**
* IPv4 and IPv6 address type
*/
DUAL_STACK = "dualstack"
}
export declare enum ApiKeySourceType {
/**
* To read the API key from the `X-API-Key` header of a request.
*/
HEADER = "HEADER",
/**
* To read the API key from the `UsageIdentifierKey` from a custom authorizer.
*/
AUTHORIZER = "AUTHORIZER"
}
export declare enum EndpointType {
/**
* For an edge-optimized API and its custom domain name.
*/
EDGE = "EDGE",
/**
* For a regional API and its custom domain name.
*/
REGIONAL = "REGIONAL",
/**
* For a private API and its custom domain name.
*/
PRIVATE = "PRIVATE"
}
/**
* The Mode that determines how API Gateway handles resource updates when importing an OpenAPI definition.
*/
export declare enum RestApiMode {
/**
* The new API definition replaces the existing one.
*/
OVERWRITE = "overwrite",
/**
* The new API definition is merged with the existing API.
*/
MERGE = "merge"
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,291 @@
import type { Construct } from 'constructs';
import type { IAccessLogDestination } from './access-log';
import { AccessLogFormat } from './access-log';
import type { ApiKeyOptions, IApiKey } from './api-key';
import type { IStageRef, StageReference } from './apigateway.generated';
import type { Deployment } from './deployment';
import type { IRestApi } from './restapi';
import * as cloudwatch from '../../aws-cloudwatch';
import type { Duration, IResource } from '../../core';
import { Resource } from '../../core';
/**
* Represents an APIGateway Stage.
*/
export interface IStage extends IResource, IStageRef {
/**
* Name of this stage.
* @attribute
*/
readonly stageName: string;
/**
* RestApi to which this stage is associated.
*/
readonly restApi: IRestApi;
/**
* Add an ApiKey to this Stage
*/
addApiKey(id: string, options?: ApiKeyOptions): IApiKey;
}
export interface StageOptions extends MethodDeploymentOptions {
/**
* The name of the stage, which API Gateway uses as the first path segment
* in the invoked Uniform Resource Identifier (URI).
*
* @default - "prod"
*/
readonly stageName?: string;
/**
* The CloudWatch Logs log group or Firehose delivery stream where to write access logs.
*
* @default - No destination
*/
readonly accessLogDestination?: IAccessLogDestination;
/**
* A single line format of access logs of data, as specified by selected $content variables.
* The format must include either `AccessLogFormat.contextRequestId()`
* or `AccessLogFormat.contextExtendedRequestId()`.
*
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference
*
* @default - Common Log Format
*/
readonly accessLogFormat?: AccessLogFormat;
/**
* Specifies whether Amazon X-Ray tracing is enabled for this method.
*
* @default false
*/
readonly tracingEnabled?: boolean;
/**
* Indicates whether cache clustering is enabled for the stage.
*
* @default - Disabled for the stage.
*/
readonly cacheClusterEnabled?: boolean;
/**
* The stage's cache cluster size.
* @default 0.5
*/
readonly cacheClusterSize?: string;
/**
* The identifier of the client certificate that API Gateway uses to call
* your integration endpoints in the stage.
*
* @default - None.
*/
readonly clientCertificateId?: string;
/**
* A description of the purpose of the stage.
*
* @default - No description.
*/
readonly description?: string;
/**
* The version identifier of the API documentation snapshot.
*
* @default - No documentation version.
*/
readonly documentationVersion?: string;
/**
* A map that defines the stage variables. Variable names must consist of
* alphanumeric characters, and the values must match the following regular
* expression: [A-Za-z0-9-._~:/?#&=,]+.
*
* @default - No stage variables.
*/
readonly variables?: {
[key: string]: string;
};
/**
* Method deployment options for specific resources/methods. These will
* override common options defined in `StageOptions#methodOptions`.
*
* @param path is {resource_path}/{http_method} (i.e. /api/toys/GET) for an
* individual method override. You can use `*` for both {resource_path} and {http_method}
* to define options for all methods/resources.
*
* @default - Common options will be used.
*/
readonly methodOptions?: {
[path: string]: MethodDeploymentOptions;
};
}
export interface StageProps extends StageOptions {
/**
* The deployment that this stage points to [disable-awslint:ref-via-interface].
*/
readonly deployment: Deployment;
}
export declare enum MethodLoggingLevel {
OFF = "OFF",
ERROR = "ERROR",
INFO = "INFO"
}
export interface MethodDeploymentOptions {
/**
* Specifies whether Amazon CloudWatch metrics are enabled for this method.
*
* @default false
*/
readonly metricsEnabled?: boolean;
/**
* Specifies the logging level for this method, which effects the log
* entries pushed to Amazon CloudWatch Logs.
*
* @default - Off
*/
readonly loggingLevel?: MethodLoggingLevel;
/**
* Specifies whether data trace logging is enabled for this method.
* When enabled, API gateway will log the full API requests and responses.
* This can be useful to troubleshoot APIs, but can result in logging sensitive data.
* We recommend that you don't enable this feature for production APIs.
*
* @default false
*/
readonly dataTraceEnabled?: boolean;
/**
* Specifies the throttling burst limit.
* The total rate of all requests in your AWS account is limited to 5,000 requests.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html
*
* @default - No additional restriction.
*/
readonly throttlingBurstLimit?: number;
/**
* Specifies the throttling rate limit.
* The total rate of all requests in your AWS account is limited to 10,000 requests per second (rps).
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html
*
* @default - No additional restriction.
*/
readonly throttlingRateLimit?: number;
/**
* Specifies whether responses should be cached and returned for requests. A
* cache cluster must be enabled on the stage for responses to be cached.
*
* @default - Caching is Disabled.
*/
readonly cachingEnabled?: boolean;
/**
* Specifies the time to live (TTL), in seconds, for cached responses. The
* higher the TTL, the longer the response will be cached.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html
*
* @default Duration.minutes(5)
*/
readonly cacheTtl?: Duration;
/**
* Indicates whether the cached responses are encrypted.
*
* @default false
*/
readonly cacheDataEncrypted?: boolean;
}
/**
* The attributes of an imported Stage
*/
export interface StageAttributes {
/**
* The name of the stage
*/
readonly stageName: string;
/**
* The RestApi that the stage belongs to
*/
readonly restApi: IRestApi;
}
/**
* Base class for an ApiGateway Stage
*/
export declare abstract class StageBase extends Resource implements IStage {
abstract readonly stageName: string;
abstract readonly restApi: IRestApi;
/**
* Add an ApiKey to this stage
*/
addApiKey(id: string, options?: ApiKeyOptions): IApiKey;
/**
* Returns the invoke URL for a certain path.
* @param path The resource path
*/
urlForPath(path?: string): string;
/**
* Returns the resource ARN for this stage:
*
* arn:aws:apigateway:{region}::/restapis/{restApiId}/stages/{stageName}
*
* Note that this is separate from the execute-api ARN for methods and resources
* within this stage.
*
* @attribute
*/
get stageArn(): string;
/**
* Returns the given named metric for this stage
*/
metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of client-side errors captured in a given period.
*
* @default - sum over 5 minutes
*/
metricClientError(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of server-side errors captured in a given period.
*
* @default - sum over 5 minutes
*/
metricServerError(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of requests served from the API cache in a given period.
*
* @default - sum over 5 minutes
*/
metricCacheHitCount(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the number of requests served from the backend in a given period,
* when API caching is enabled.
*
* @default - sum over 5 minutes
*/
metricCacheMissCount(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the total number API requests in a given period.
*
* @default - sample count over 5 minutes
*/
metricCount(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* Metric for the time between when API Gateway relays a request to the backend
* and when it receives a response from the backend.
*
* @default - average over 5 minutes.
*/
metricIntegrationLatency(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
/**
* The time between when API Gateway receives a request from a client
* and when it returns a response to the client.
* The latency includes the integration latency and other API Gateway overhead.
*
* @default - average over 5 minutes.
*/
metricLatency(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
private cannedMetric;
get stageRef(): StageReference;
}
export declare class Stage extends StageBase {
/**
* Uniquely identifies this class.
*/
static readonly PROPERTY_INJECTION_ID: string;
/**
* Import a Stage by its attributes
*/
static fromStageAttributes(scope: Construct, id: string, attrs: StageAttributes): IStage;
readonly stageName: string;
readonly restApi: IRestApi;
private enableCacheCluster?;
constructor(scope: Construct, id: string, props: StageProps);
private renderMethodSettings;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,108 @@
import type { Construct } from 'constructs';
import type { RestApiProps } from '.';
import { RestApi } from '.';
import type { RequestContext } from './integrations';
import type * as iam from '../../aws-iam';
import * as sfn from '../../aws-stepfunctions';
/**
* Properties for StepFunctionsRestApi
*
*/
export interface StepFunctionsRestApiProps extends RestApiProps {
/**
* The default State Machine that handles all requests from this API.
*
* This stateMachine will be used as a the default integration for all methods in
* this API, unless specified otherwise in `addMethod`.
*/
readonly stateMachine: sfn.IStateMachine;
/**
* Which details of the incoming request must be passed onto the underlying state machine,
* such as, account id, user identity, request id, etc. The execution input will include a new key `requestContext`:
*
* {
* "body": {},
* "requestContext": {
* "key": "value"
* }
* }
*
* @default - all parameters within request context will be set as false
*/
readonly requestContext?: RequestContext;
/**
* Check if querystring is to be included inside the execution input. The execution input will include a new key `queryString`:
*
* {
* "body": {},
* "querystring": {
* "key": "value"
* }
* }
*
* @default true
*/
readonly querystring?: boolean;
/**
* Check if path is to be included inside the execution input. The execution input will include a new key `path`:
*
* {
* "body": {},
* "path": {
* "resourceName": "resourceValue"
* }
* }
*
* @default true
*/
readonly path?: boolean;
/**
* Check if header is to be included inside the execution input. The execution input will include a new key `headers`:
*
* {
* "body": {},
* "headers": {
* "header1": "value",
* "header2": "value"
* }
* }
* @default false
*/
readonly headers?: boolean;
/**
* If the whole authorizer object, including custom context values should be in the execution input. The execution input will include a new key `authorizer`:
*
* {
* "body": {},
* "authorizer": {
* "key": "value"
* }
* }
*
* @default false
*/
readonly authorizer?: boolean;
/**
* An IAM role that API Gateway will assume to start the execution of the
* state machine.
*
* @default - a new role is created
*/
readonly role?: iam.IRole;
/**
* Whether to add default response models with 200, 400, and 500 status codes to the method.
*
* @default true
*/
readonly useDefaultMethodResponses?: boolean;
}
/**
* Defines an API Gateway REST API with a Synchrounous Express State Machine as a proxy integration.
*/
export declare class StepFunctionsRestApi extends RestApi {
/**
* Uniquely identifies this class.
*/
static readonly PROPERTY_INJECTION_ID: string;
constructor(scope: Construct, id: string, props: StepFunctionsRestApiProps);
}

View File

@@ -0,0 +1 @@
"use strict";var __esDecorate=exports&&exports.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(f!==void 0&&typeof f!="function")throw new TypeError("Function expected");return f}for(var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),_,done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]=p==="access"?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!="object")throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&(kind==="field"?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0},__runInitializers=exports&&exports.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0};Object.defineProperty(exports,"__esModule",{value:!0}),exports.StepFunctionsRestApi=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var _1=()=>{var tmp=require(".");return _1=()=>tmp,tmp},stepfunctions_1=()=>{var tmp=require("./integrations/stepfunctions");return stepfunctions_1=()=>tmp,tmp},sfn=()=>{var tmp=require("../../aws-stepfunctions");return sfn=()=>tmp,tmp},errors_1=()=>{var tmp=require("../../core/lib/errors");return errors_1=()=>tmp,tmp},metadata_resource_1=()=>{var tmp=require("../../core/lib/metadata-resource");return metadata_resource_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp},prop_injectable_1=()=>{var tmp=require("../../core/lib/prop-injectable");return prop_injectable_1=()=>tmp,tmp};let StepFunctionsRestApi=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=_1().RestApi;var StepFunctionsRestApi2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),StepFunctionsRestApi2=_classThis=_classDescriptor.value,_metadata&&Object.defineProperty(_classThis,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigateway.StepFunctionsRestApi",version:"2.252.0"};static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-apigateway.StepFunctionsRestApi";constructor(scope,id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigateway_StepFunctionsRestApiProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,StepFunctionsRestApi2),error}if(props.defaultIntegration)throw new(errors_1()).ValidationError((0,literal_string_1().lit)`CannotSpecifyDefaultIntegrationSince`,'Cannot specify "defaultIntegration" since Step Functions integration is automatically defined',scope);if(props.stateMachine.node.defaultChild.stateMachineType!==sfn().StateMachineType.EXPRESS)throw new(errors_1()).ValidationError((0,literal_string_1().lit)`MustBeStateMachineType`,'State Machine must be of type "EXPRESS". Please use StateMachineType.EXPRESS as the stateMachineType',scope);const stepfunctionsIntegration=stepfunctions_1().StepFunctionsIntegration.startExecution(props.stateMachine,{credentialsRole:props.role,requestContext:props.requestContext,path:props.path??!0,querystring:props.querystring??!0,headers:props.headers,authorizer:props.authorizer,useDefaultMethodResponses:props.useDefaultMethodResponses});super(scope,id,props),(0,metadata_resource_1().addConstructMetadata)(this,props),this.root.addMethod("ANY",stepfunctionsIntegration)}static{__runInitializers(_classThis,_classExtraInitializers)}};return StepFunctionsRestApi2=_classThis})();exports.StepFunctionsRestApi=StepFunctionsRestApi;

View File

@@ -0,0 +1,184 @@
import type { Construct } from 'constructs';
import type { IApiKey } from './api-key';
import type { IApiKeyRef, IUsagePlanRef, UsagePlanReference } from './apigateway.generated';
import type { Method } from './method';
import type { IRestApi } from './restapi';
import type { Stage } from './stage';
import type { IResource } from '../../core';
import { Resource } from '../../core';
/**
* Container for defining throttling parameters to API stages or methods.
* @link https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html
*/
export interface ThrottleSettings {
/**
* The API request steady-state rate limit (average requests per second over an extended period of time)
* @default none
*/
readonly rateLimit?: number;
/**
* The maximum API request rate limit over a time ranging from one to a few seconds.
* @default none
*/
readonly burstLimit?: number;
}
/**
* Time period for which quota settings apply.
*/
export declare enum Period {
DAY = "DAY",
WEEK = "WEEK",
MONTH = "MONTH"
}
/**
* Specifies the maximum number of requests that clients can make to API Gateway APIs.
*/
export interface QuotaSettings {
/**
* The maximum number of requests that users can make within the specified time period.
* @default none
*/
readonly limit?: number;
/**
* For the initial time period, the number of requests to subtract from the specified limit.
* @default none
*/
readonly offset?: number;
/**
* The time period for which the maximum limit of requests applies.
* @default none
*/
readonly period?: Period;
}
/**
* Represents per-method throttling for a resource.
*/
export interface ThrottlingPerMethod {
/**
* [disable-awslint:ref-via-interface]
* The method for which you specify the throttling settings.
* @default none
*/
readonly method: Method;
/**
* Specifies the overall request rate (average requests per second) and burst capacity.
* @default none
*/
readonly throttle: ThrottleSettings;
}
/**
* Represents the API stages that a usage plan applies to.
*/
export interface UsagePlanPerApiStage {
/**
* @default none
*/
readonly api?: IRestApi;
/**
*
* [disable-awslint:ref-via-interface]
* @default none
*/
readonly stage?: Stage;
/**
* @default none
*/
readonly throttle?: ThrottlingPerMethod[];
}
export interface UsagePlanProps {
/**
* API Stages to be associated with the usage plan.
* @default none
*/
readonly apiStages?: UsagePlanPerApiStage[];
/**
* Represents usage plan purpose.
* @default none
*/
readonly description?: string;
/**
* Number of requests clients can make in a given time period.
* @default none
*/
readonly quota?: QuotaSettings;
/**
* Overall throttle settings for the API.
* @default none
*/
readonly throttle?: ThrottleSettings;
/**
* Name for this usage plan.
* @default none
*/
readonly name?: string;
}
/**
* Options to the UsagePlan.addApiKey() method
*/
export interface AddApiKeyOptions {
/**
* Override the CloudFormation logical id of the AWS::ApiGateway::UsagePlanKey resource
* @default - autogenerated by the CDK
*/
readonly overrideLogicalId?: string;
}
/**
* A UsagePlan, either managed by this CDK app, or imported.
*/
export interface IUsagePlan extends IResource, IUsagePlanRef {
/**
* Id of the usage plan
* @attribute
*/
readonly usagePlanId: string;
/**
* Adds an ApiKey.
*
* @param apiKey the api key to associate with this usage plan
* @param options options that control the behaviour of this method
*/
addApiKey(apiKey: IApiKeyRef, options?: AddApiKeyOptions): void;
}
declare abstract class UsagePlanBase extends Resource implements IUsagePlan {
/**
* Id of the usage plan
* @attribute
*/
abstract readonly usagePlanId: string;
/**
* Adds an ApiKey.
*
* @param apiKey the api key to associate with this usage plan
* @param options options that control the behaviour of this method
*/
addApiKey(apiKey: IApiKeyRef, options?: AddApiKeyOptions): void;
get usagePlanRef(): UsagePlanReference;
}
export declare class UsagePlan extends UsagePlanBase {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
/**
* Import an externally defined usage plan using its ARN.
*
* @param scope the construct that will "own" the imported usage plan.
* @param id the id of the imported usage plan in the construct tree.
* @param usagePlanId the id of an existing usage plan.
*/
static fromUsagePlanId(scope: Construct, id: string, usagePlanId: string): IUsagePlan;
/**
* @attribute
*/
readonly usagePlanId: string;
private readonly apiStages;
constructor(scope: Construct, id: string, props?: UsagePlanProps);
/**
* Adds an apiStage.
*/
addApiStage(apiStage: UsagePlanPerApiStage): void;
private renderApiStages;
private createStage;
private renderQuota;
private renderThrottle;
private renderThrottlePerMethod;
}
export {};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,26 @@
import * as jsonSchema from './json-schema';
export declare const ALL_METHODS: string[];
export declare function validateHttpMethod(method: string, messagePrefix?: string): void;
export declare function parseMethodOptionsPath(originalPath: string): {
resourcePath: string;
httpMethod: string;
};
export declare function parseAwsApiCall(path?: string, action?: string, actionParams?: {
[key: string]: string;
}): {
apiType: string;
apiValue: string;
};
export declare function validateInteger(property: number | undefined, messagePrefix: string): void;
export declare function validateDouble(property: number | undefined, messagePrefix: string): void;
export declare class JsonSchemaMapper {
/**
* Transforms naming of some properties to prefix with a $, where needed
* according to the JSON schema spec
* @param schema The JsonSchema object to transform for CloudFormation output
*/
static toCfnJsonSchema(schema: jsonSchema.JsonSchema): any;
private static readonly SchemaPropsWithPrefix;
private static readonly SchemaPropsWithUserDefinedChildren;
private static _toCfnJsonSchema;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.JsonSchemaMapper=exports.ALL_METHODS=void 0,exports.validateHttpMethod=validateHttpMethod,exports.parseMethodOptionsPath=parseMethodOptionsPath,exports.parseAwsApiCall=parseAwsApiCall,exports.validateInteger=validateInteger,exports.validateDouble=validateDouble;var url_1=()=>{var tmp=require("url");return url_1=()=>tmp,tmp},jsonSchema=()=>{var tmp=require("./json-schema");return jsonSchema=()=>tmp,tmp},errors_1=()=>{var tmp=require("../../core/lib/errors");return errors_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp};exports.ALL_METHODS=["OPTIONS","GET","PUT","POST","DELETE","PATCH","HEAD"];const ALLOWED_METHODS=["ANY",...exports.ALL_METHODS];function validateHttpMethod(method,messagePrefix=""){if(!ALLOWED_METHODS.includes(method))throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`InvalidHttpMethod`,`${messagePrefix}Invalid HTTP method "${method}". Allowed methods: ${ALLOWED_METHODS.join(",")}`)}function parseMethodOptionsPath(originalPath){if(!originalPath.startsWith("/"))throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`MethodOptionsPathStart`,`Method options path must start with '/': ${originalPath}`);const path=originalPath.slice(1),components=path.split("/");if(components.length<2)throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`MethodOptionsPathInclude`,`Method options path must include at least two components: /{resource}/{method} (i.e. /foo/bar/GET): ${path}`);const httpMethod=components.pop().toUpperCase();httpMethod!=="*"&&validateHttpMethod(httpMethod,`${originalPath}: `);let resourcePath="/~1"+components.join("~1");return components.length===1&&components[0]==="*"?resourcePath="/*":components.length===1&&components[0]===""&&(resourcePath="/"),{httpMethod,resourcePath}}function parseAwsApiCall(path,action,actionParams){if(actionParams&&!action)throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`RequiresActionparamsRequiresAction`,'"actionParams" requires that "action" will be set');if(path&&action)throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`PathActionMutuallyExclusive`,`"path" and "action" are mutually exclusive (path="${path}", action="${action}")`);if(path)return{apiType:"path",apiValue:path};if(action)return actionParams&&(action+="&"+(0,url_1().format)({query:actionParams}).slice(1)),{apiType:"action",apiValue:action};throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`EitherPathActionRequired`,'Either "path" or "action" are required')}function validateInteger(property,messagePrefix){if(property&&!Number.isInteger(property))throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`ShouldBeShouldInteger`,`${messagePrefix} should be an integer`)}function validateDouble(property,messagePrefix){if(property&&isNaN(property)&&isNaN(parseFloat(property.toString())))throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`ShouldBeShouldDouble`,`${messagePrefix} should be an double`)}class JsonSchemaMapper{static toCfnJsonSchema(schema){const result=JsonSchemaMapper._toCfnJsonSchema(schema);return"$schema"in result||(result.$schema=jsonSchema().JsonSchemaVersion.DRAFT4),result}static SchemaPropsWithPrefix={schema:"$schema",ref:"$ref"};static SchemaPropsWithUserDefinedChildren={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};static _toCfnJsonSchema(schema,preserveKeys=!1){return schema==null||typeof schema!="object"?schema:Array.isArray(schema)?schema.map(entry=>JsonSchemaMapper._toCfnJsonSchema(entry)):Object.assign({},...Object.entries(schema).map(([key,value])=>{const newKey=!preserveKeys&&key in JsonSchemaMapper.SchemaPropsWithPrefix?JsonSchemaMapper.SchemaPropsWithPrefix[key]:key,newValue=JsonSchemaMapper._toCfnJsonSchema(value,!preserveKeys&&JsonSchemaMapper.SchemaPropsWithUserDefinedChildren[key]);return{[newKey]:newValue}}))}}exports.JsonSchemaMapper=JsonSchemaMapper;

View File

@@ -0,0 +1,65 @@
import type { Construct } from 'constructs';
import type { IVpcLinkRef, VpcLinkReference } from './apigateway.generated';
import type * as elbv2 from '../../aws-elasticloadbalancingv2';
import type { IResource } from '../../core';
import { Resource } from '../../core';
/**
* Represents an API Gateway VpcLink
*/
export interface IVpcLink extends IResource, IVpcLinkRef {
/**
* Physical ID of the VpcLink resource
* @attribute
*/
readonly vpcLinkId: string;
}
/**
* Properties for a VpcLink
*/
export interface VpcLinkProps {
/**
* The name used to label and identify the VPC link.
* @default - automatically generated name
*/
readonly vpcLinkName?: string;
/**
* The description of the VPC link.
* @default no description
*/
readonly description?: string;
/**
* The network load balancers of the VPC targeted by the VPC link.
* The network load balancers must be owned by the same AWS account of the API owner.
*
* @default - no targets. Use `addTargets` to add targets
*/
readonly targets?: elbv2.INetworkLoadBalancer[];
}
/**
* Define a new VPC Link
* Specifies an API Gateway VPC link for a RestApi to access resources in an Amazon Virtual Private Cloud (VPC).
*/
export declare class VpcLink extends Resource implements IVpcLink {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
/**
* Import a VPC Link by its Id
*/
static fromVpcLinkId(scope: Construct, id: string, vpcLinkId: string): IVpcLink;
/**
* Physical ID of the VpcLink resource
* @attribute
*/
readonly vpcLinkId: string;
readonly vpcLinkRef: VpcLinkReference;
private readonly _targets;
constructor(scope: Construct, id: string, props?: VpcLinkProps);
addTargets(...targets: elbv2.INetworkLoadBalancer[]): void;
/**
* Return the list of DNS names from the target NLBs.
* @internal
* */
get _targetDnsNames(): string[];
private validateVpcLink;
private renderTargets;
}

File diff suppressed because one or more lines are too long