我正在创建一个 YAML 格式的模板来创建堆栈。在 api 网关中,我想为私有(private)类型的端点 id 设置一个值。有什么办法可以在模板中做到这一点吗?或者我可以使用 boto3 来做到这一点吗?
API网关:
Type: 'AWS::ApiGateway::RestApi'
Properties:
Description: A test API
Name: !Ref ApiName
EndpointConfiguration:
Types:
- "PRIVATE"
vpcEndpointIds:
- !Ref VPC
此代码给出错误,表示没有属性 vpcEndpointIds。
最佳答案
从此cloudformation文档看起来它现在已经添加到cloudformation
中。但是,aws-cdk
似乎没有反射(reflect)此更新,但假设 cloudformation
文档反射(reflect)了当前状态,以下(未经测试的)代码应该能够满足您的需求。
const api = new RestApi(this, 'APIGateway', {
deploy: true,
deployOptions: {
stageName: 'live',
tracingEnabled: true,
},
endpointTypes: [EndpointType.PRIVATE],
retainDeployments: false,
restApiName: 'my-api',
description: 'an api',
});
const cfnApi = api.node.defaultChild as CfnMethod;
cfnApi.addOverride('Properties.EndpointConfiguration.VpcEndpointIds', ['12345']);
参见此处here有关向构造添加缺失功能的详细信息。
关于amazon-web-services - 使用 python 中的 cloudformation 在 ApiGateway 中为私有(private)类型设置端点 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58570253/