Skip to content
v2.277.0

ApiMappingOptions Struct ​

Options for creating an api mapping.

Example ​

ts
declare const acmCertificateForExampleCom: any;
declare const restApi: apigateway.RestApi;
declare const secondRestApi: apigateway.RestApi;

const domain = new apigateway.DomainName(this, 'custom-domain', {
  domainName: 'example.com',
  certificate: acmCertificateForExampleCom,
  mapping: restApi,
});

domain.addApiMapping(secondRestApi.deploymentStage, {
  basePath: 'orders/v2/api',
});
python
# acm_certificate_for_example_com: Any
# rest_api: apigateway.RestApi
# second_rest_api: apigateway.RestApi


domain = apigateway.DomainName(self, "custom-domain",
    domain_name="example.com",
    certificate=acm_certificate_for_example_com,
    mapping=rest_api
)

domain.add_api_mapping(second_rest_api.deployment_stage,
    base_path="orders/v2/api"
)
java
Object acmCertificateForExampleCom;
RestApi restApi;
RestApi secondRestApi;


DomainName domain = DomainName.Builder.create(this, "custom-domain")
        .domainName("example.com")
        .certificate(acmCertificateForExampleCom)
        .mapping(restApi)
        .build();

domain.addApiMapping(secondRestApi.getDeploymentStage(), ApiMappingOptions.builder()
        .basePath("orders/v2/api")
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var acmCertificateForExampleCom;
RestApi restApi;
RestApi secondRestApi;


var domain = new DomainName(this, "custom-domain", new DomainNameProps {
    DomainName = "example.com",
    Certificate = acmCertificateForExampleCom,
    Mapping = restApi
});

domain.AddApiMapping(secondRestApi.DeploymentStage, new ApiMappingOptions {
    BasePath = "orders/v2/api"
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var acmCertificateForExampleCom interface{}
var restApi RestApi
var secondRestApi RestApi


domain := apigateway.NewDomainName(this, jsii.String("custom-domain"), &DomainNameProps{
	DomainName: jsii.String("example.com"),
	Certificate: acmCertificateForExampleCom,
	Mapping: restApi,
})

domain.AddApiMapping(secondRestApi.DeploymentStage, &ApiMappingOptions{
	BasePath: jsii.String("orders/v2/api"),
})

Properties ​

basePathoptionalstringbase_pathoptionalstrbasePathoptionalStringBasePathoptionalstringBasePathoptional*string#
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.

Default: map requests from the domain root (e.g. example.com).

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.