#amazon-web-services #aws-lambda #amazon-cloudformation #aws-api-gateway #aws-sam
#amazon-web-services #aws-lambda #aws-cloudformation #aws-api-gateway #aws-sam
Вопрос:
У меня есть ресурс rest API как таковой,
TempApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: !Sub ${Environment}-temp-api
EndpointConfiguration:
Types:
- PRIVATE
VpcEndpointIds:
- vpce-0cfefxxxxxxxxxxxx
Policy: !Sub |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow"
"Principal": "*"
"Action": "execute-api:Invoke"
"Resource": "execute-api:/*"
},
{
"Effect": "Deny"
"Principal": "*"
"Action": "execute-api:Invoke"
"Resource": "execute-api:/*"
"Condition": {
"StringNotEquals": {
"aws:sourceVpce": !FindInMap [Environments, !Ref Environment, VPCEndpointAPI]
}
}
}
]
}
При развертывании я получаю следующую ошибку:
Invalid policy document. Please check the policy syntax and ensure that Principals are valid.
(Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException)
Мы будем признательны за любую помощь в определении того, что не так с документом политики.
Спасибо,
Пункты
Ответ №1:
Только что обнаружил, что допустил глупую ошибку, пропустил запятые после каждой пары ключ-значение.
Исправлена политика:
TempApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: !Sub ${Environment}-temp-api
EndpointConfiguration:
Types:
- PRIVATE
VpcEndpointIds:
- vpce-0cfefxxxxxxxxxxxx
Policy: !Sub |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "execute-api:/*"
},
{
"Effect": "Deny",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "execute-api:/*",
"Condition": {
"StringNotEquals": {
"aws:sourceVpce": !FindInMap [Environments, !Ref Environment, VPCEndpointAPI]
}
}
}
]
}