class BasePathMapping (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.APIGateway.BasePathMapping |
Java | software.amazon.awscdk.services.apigateway.BasePathMapping |
Python | aws_cdk.aws_apigateway.BasePathMapping |
TypeScript (source) | @aws-cdk/aws-apigateway » BasePathMapping |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
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.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as apigateway from '@aws-cdk/aws-apigateway';
declare const domainName: apigateway.DomainName;
declare const restApi: apigateway.RestApi;
declare const stage: apigateway.Stage;
const basePathMapping = new apigateway.BasePathMapping(this, 'MyBasePathMapping', {
domainName: domainName,
restApi: restApi,
// the properties below are optional
basePath: 'basePath',
stage: stage,
});
Initializer
new BasePathMapping(scope: Construct, id: string, props: BasePathMappingProps)
Parameters
- scope
Construct
- id
string
- props
Base
Path Mapping Props
Construct Props
Name | Type | Description |
---|---|---|
domain | IDomain | The DomainName to associate with this base path mapping. |
rest | IRest | The RestApi resource to target. |
base | string | 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. |
stage? | Stage | The Deployment stage of API [disable-awslint:ref-via-interface]. |
domainName
Type:
IDomain
The DomainName to associate with this base path mapping.
restApi
Type:
IRest
The RestApi resource to target.
basePath?
Type:
string
(optional, 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.)
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.
stage?
Type:
Stage
(optional, default: map to deploymentStage of restApi otherwise stage needs to pass in URL)
The Deployment stage of API [disable-awslint:ref-via-interface].
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
node | Construct | The construct tree node associated with this construct. |
stack | Stack | The stack in which this resource is defined. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
node
Type:
Construct
The construct tree node associated with this construct.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.