【发布时间】:2023-03-06 19:03:02
【问题描述】:
我正在尝试创建 PRIVATE 类型的 AWS API 网关,
这需要一个资源策略,因为我能够从 AWS 控制台创建网关,所以我拥有该策略,
我想知道如何通过 CF 模板添加资源策略 -
以下是资源策略的swagger定义-
x-amazon-apigateway-policy:
Version: "2012-10-17"
Statement:
- Effect: "Deny"
Principal: "*"
Action: "execute-api:Invoke"
Resource: "arn:aws:execute-api:us-east-1:awsAccountId:xxxx/*/*/*"
Condition:
StringNotEquals:
aws:sourceVpc: "vpc-xxxxx"
- Effect: "Allow"
Principal: "*"
Action: "execute-api:Invoke"
Resource: "arn:aws:execute-api:us-east-1:xxxx:xxxx/*/*/*"
如何在CF模板中配置-
AWSTemplateFormatVersion: 2010-09-09
Transform: 'AWS::Serverless-2016-10-31'
Description: G2G Api Template Stack
Resources:
g2gPrivate:
Type: 'AWS::ApiGateway::RestApi'
Properties:
Name: 'private-gw'
EndpointConfiguration:
Types:
- PRIVATE
参考 -
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html
【问题讨论】:
标签: amazon-web-services amazon-cloudformation aws-api-gateway