【发布时间】:2021-09-27 08:04:15
【问题描述】:
以下 CloudFormation 已经过验证,并包含一个 SESAccessPolicy,其中传递了一些参数。
不同的帐户 ID(用于生产:XXXXXXXXXXXXX 和测试:YYYYYYYYYYYYY)
Parameters:
ProdEmailFromAddress:
Type: String
Description: "Email address to use as sender"
Default: "arn:aws:ses:eu-west-1:XXXXXXXXXXXXX:identity/no-reply@company.no"
TestEmailFromAddress:
Type: String
Description: "Email address to use as sender"
Default: "arn:aws:ses:eu-west-1:YYYYYYYYYYYYY:identity/no-reply@companytest.no"
Conditions:
IsProductionDeployment: !Equals [!Ref "AWS::AccountId", "XXXXXXXXXXXXX"]
SESAccessPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
Description: Permissions to send email from SES
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "ses:SendEmail"
Resource:
- !If [IsProductionDeployment,!Ref ProdEmailFromAddress, !Ref TestEmailFromAddress]
更新堆栈时,我们得到以下错误事件
Resource no-reply@companytest.no must be in ARN format or "*". (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument; Request ID: 7af958ba-9c99-4073-a3b3-4da1b3ae80da; Proxy: null)
尽管如果我将 SESAccessPolicy 的资源从使用 !Ref 更改为硬编码字符串,它仍然可以工作并且堆栈已部署。
Resource:
- !If [IsProductionDeployment,!Ref ProdEmailFromAddress, "arn:aws:ses:eu-west-1:YYYYYYYYYYYYY:identity/no-reply@companytest.no" ]
我想使用 !Ref 并且不明白为什么它会引发异常但接受 String 作为 ARN。
我看到了一个使用 CloudTrail 解决此案例的网页,但现在找不到了。
有人可以对此有所了解或指出正确的方向吗? TIA
【问题讨论】:
-
是否有实际传递给堆栈的参数或者是否使用了默认值?
-
不,那些参数没有传递给模板(ProdEmailFromAddress 和 TestEmailFromAddress),目标是使用默认值。
-
大家好,谢谢,我已经解决了,我会发布答案:)
标签: amazon-web-services amazon-cloudformation