【发布时间】:2021-03-09 14:55:51
【问题描述】:
我已经定义了这样的 cloudformation 模板:
AWSTemplateFormatVersion: 2010-09-09
Description: Auth stack
Transform: AWS::Serverless-2016-10-31
Parameters:
DeveloperProviderName:
Description: Developer provider name
Type: String
Conditions:
Never:
!Equals [ "true", "false" ]
Resources:
CognitoIdentityPool:
Type: Custom::CognitoIdentityPool
Version: '1.0'
Properties:
IdentityPoolName: !Sub "${AWS::StackName}-cognito-idp"
DeveloperProviderName: !Ref DeveloperProviderName
ServiceToken: !GetAtt CreateIdentityPoolFunction.Arn
.
.
more stuff here for the lambda function etc
.
.
那我想加个栈策略,拒绝replace和delete:
{
"Statement": [
{
"Effect": "Allow",
"Action": "Update:*",
"Principal": "*",
"Resource": "*"
},
{
"Effect": "Deny",
"Action": [
"Update:Replace",
"Update:Delete"
],
"Principal": "*",
"Resource": "*",
"Condition": {
"StringEquals": {
"ResourceType": [
"Custom::CognitoIdentityPool"
]
}
}
}
]
}
这就是我设置堆栈策略的方式:
aws cloudformation set-stack-policy \
--stack-name ${stackName} \
--stack-policy-body file://${policyPath}
这是我在设置堆栈策略时遇到的错误:
An error occurred (ValidationError) when calling the SetStackPolicy operation: Error validating stack policy: Unknown resource type 'Custom::CognitoIdentityPool' in statement {}
任何想法如何使用堆栈策略保护这些自定义资源?
【问题讨论】:
标签: amazon-web-services amazon-cloudformation amazon-cognito