aws-cdk-lib.aws_apigateway.AssetApiDefinition

class AssetApiDefinition

LanguageType name
.NETAmazon.CDK.AWS.APIGateway.AssetApiDefinition
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#AssetApiDefinition
Javasoftware.amazon.awscdk.services.apigateway.AssetApiDefinition
Pythonaws_cdk.aws_apigateway.AssetApiDefinition
TypeScript (source)aws-cdk-lib » aws_apigateway » AssetApiDefinition

Extends ApiDefinition

OpenAPI specification from a local file.

Example

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

declare const dockerImage: cdk.DockerImage;
declare const grantable: iam.IGrantable;
declare const localBundling: cdk.ILocalBundling;
const assetApiDefinition = new apigateway.AssetApiDefinition('path', /* all optional props */ {
  assetHash: 'assetHash',
  assetHashType: cdk.AssetHashType.SOURCE,
  bundling: {
    image: dockerImage,

    // the properties below are optional
    bundlingFileAccess: cdk.BundlingFileAccess.VOLUME_COPY,
    command: ['command'],
    entrypoint: ['entrypoint'],
    environment: {
      environmentKey: 'environment',
    },
    local: localBundling,
    network: 'network',
    outputType: cdk.BundlingOutput.ARCHIVED,
    securityOpt: 'securityOpt',
    user: 'user',
    volumes: [{
      containerPath: 'containerPath',
      hostPath: 'hostPath',

      // the properties below are optional
      consistency: cdk.DockerVolumeConsistency.CONSISTENT,
    }],
    volumesFrom: ['volumesFrom'],
    workingDirectory: 'workingDirectory',
  },
  deployTime: false,
  exclude: ['exclude'],
  followSymlinks: cdk.SymlinkFollowMode.NEVER,
  ignoreMode: cdk.IgnoreMode.GLOB,
  readers: [grantable],
});

Initializer

new AssetApiDefinition(path: string, options?: AssetOptions)

Parameters

  • path string
  • options AssetOptions

Methods

NameDescription
bind(scope)Called when the specification is initialized to allow this object to bind to the stack, add resources and have fun.
bindAfterCreate(scope, restApi)Called after the CFN RestApi resource has been created to allow the Api Definition to bind to it.

bind(scope)

public bind(scope: Construct): ApiDefinitionConfig

Parameters

  • scope Construct

Returns

  • ApiDefinitionConfig

Called when the specification is initialized to allow this object to bind to the stack, add resources and have fun.


bindAfterCreate(scope, restApi)

public bindAfterCreate(scope: Construct, restApi: IRestApi): void

Parameters

  • scope Construct
  • restApi IRestApi

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.