amazon-web-services - 使用 python 中的 cloudformation 在 ApiGateway 中为私有(private)类型设置端点 ID

标签 amazon-web-services aws-cloudformation aws-api-gateway boto3 amazon-vpc

我正在创建一个 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/

相关文章:

amazon-web-services - 将 JSON 对象传递到 AWS CloudFormation 中的 ECS 实例

amazon-web-services - AWS 云形成 : Reference to subnet causing error

amazon-web-services - 安全组和子网属于不同的网络

aws-lambda - 被 CORS 阻止,也无法使用 Amplify Functions 访问 REST API 端点

amazon-web-services - 使用 Import 和 sub psudo 函数返回错误

python - 如何从 S3 存储桶加载 pickle(.pkl) 文件

amazon-web-services - 如何让自己免于 AWS 费用?

aws-cloudformation - 我可以在 CloudFormation 中创建一个 lambda 函数来运行 aws cli 命令来更新注册域的名称服务器吗?

amazon-web-services - 处理 AWS API Gateway API URL 中的空间 - 我正在使用 Dynamodb 代理

amazon-web-services - 如何使用 AWS 开发工具包进行身份验证