I have defined the cloudformation template like that:
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
.
.
Then I want to add a stack policy and deny the replace and delete:
{
"Statement": [
{
"Effect": "Allow",
"Action": "Update:*",
"Principal": "*",
"Resource": "*"
},
{
"Effect": "Deny",
"Action": [
"Update:Replace",
"Update:Delete"
],
"Principal": "*",
"Resource": "*",
"Condition": {
"StringEquals": {
"ResourceType": [
"Custom::CognitoIdentityPool"
]
}
}
}
]
}
This is how I'm setting the stack policy:
aws cloudformation set-stack-policy \
--stack-name ${stackName} \
--stack-policy-body file://${policyPath}
This is the error I'm getting while setting the stack policy:
An error occurred (ValidationError) when calling the SetStackPolicy operation: Error validating stack policy: Unknown resource type 'Custom::CognitoIdentityPool' in statement {}
Any ideas how to protect these custom resources with the stack policy?