如何在API-GW自定义域基本路径映射中使用AWS-CDK设置“阶段”?
这是aws-cdk代码,该代码使用基本路径映射创建api-gw自定义域,但是阶段设置为“ *” 我需要将其设置为特定阶段 我该怎么办?
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)
});
答案 0 :(得分:0)
我找到了一种通过使用低级结构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
});