0

如何在 API-GW 自定义域基本路径映射中使用 AWS-CDK 设置“阶段”?

在此处输入图像描述

这是使用基本路径映射创建 api-gw 自定义域的 aws-cdk 代码,但阶段设置为“*”我需要将其设置为特定阶段我该怎么做?

cdk 版本:1.6.1(构建 a09203a)

      const restApiObj = {
        node: this.node,
        stack: Stack.of(this),
        restApiId: api.ref
      };
      this.customDomainName = new apiGateway.DomainName(this, "DomainName", {
        endpointType: EndpointType.REGIONAL,
        certificate: {
          certificateArn: props.customDomainNameProps.customDomainNameCertificateARN,
          node: this.node,
          stack: Stack.of(this)
        },
        domainName: (props.customDomainNameProps.customDomainName)?props.customDomainNameProps.customDomainName:defaultApiGWDomainName,
      });

      this.customDomainName.addBasePathMapping(restApiObj, {
        basePath: (props.customDomainNameProps.domainNameBasePathMapping?props.customDomainNameProps.domainNameBasePathMapping : ApigwConstruct.API_GW_DEFAULT_BASE_MAPPING)
      });
4

1 回答 1

2

我找到了一种方法来解决这个问题,通过使用低级结构 - CfnBaseMapping,这里是代码:

const basePathMapping = new CfnBasePathMapping(this, "basePathMapping", {
        basePath: (props.customDomainNameProps.domainNameBasePathMapping?props.customDomainNameProps.domainNameBasePathMapping : ApigwConstruct.API_GW_DEFAULT_BASE_MAPPING),
        domainName: this.customDomainName.domainName,
        restApiId: api.ref,
        stage: props.stageName
      });
于 2019-10-25T18:26:03.697 回答