【发布时间】:2018-05-17 04:46:51
【问题描述】:
在以下 Cloudformation 模板中,我正在创建 SES 接收规则。 在其中我计算要通知的 SNS TopicArn。 我想输出该值,但我无法使用语法来获取它。 所有其他输出都是模板参数。
回答:- 在调用模板上设置它并将其作为参数传递:-
Resources:
ReceiptRule:
Type: 'AWS::SES::ReceiptRule'
Properties:
RuleSetName: !Ref ReceiptRuleSetName
Rule:
Name: !Ref RuleName
Enabled: !Ref RuleEnabled
ScanEnabled: !Ref RuleScanEnabled
TlsPolicy: !Ref RuleTLSPolicy
Recipients:
- !Ref RuleRecipients
Actions:
- S3Action:
ObjectKeyPrefix: !Ref RuleS3ActionObjectKeyPrefix
BucketName: !Ref RuleS3ActionObjectBucketName
TopicArn: !Join [ '',
[
!Sub 'arn:aws:sns:${AWS::Region}:${AWS::AccountId}:',
!Ref RuleS3ActionObjectSNSTopic
]
]
Outputs:
Recipients:
Value: !Sub ${RuleRecipients}
S3Bucket:
Value: !Sub ${RuleS3ActionObjectBucketName}
S3Prefix:
Value: !Sub ${RuleS3ActionObjectKeyPrefix}
SNSTopicArn:
Value: >--What do i put here<--
答案:-
RuleS3ActionObjectSNSTopic: !Join [ '',
[
!Sub 'arn:aws:sns:${AWS::Region}:${AWS::AccountId}:',
!FindInMap [ SourceMap, !Ref rr5 , snstopic ]
]
]
然后模板变成
Resources:
ReceiptRule:
Type: 'AWS::SES::ReceiptRule'
Properties:
RuleSetName: !Ref ReceiptRuleSetName
Rule:
Name: !Ref RuleName
Enabled: !Ref RuleEnabled
ScanEnabled: !Ref RuleScanEnabled
TlsPolicy: !Ref RuleTLSPolicy
Recipients:
- !Ref RuleRecipients
Actions:
- S3Action:
ObjectKeyPrefix: !Ref RuleS3ActionObjectKeyPrefix
BucketName: !Ref RuleS3ActionObjectBucketName
TopicArn: !Ref RuleS3ActionObjectSNSTopic
Outputs:
Recipients:
Value: !Sub ${RuleRecipients}
S3Bucket:
Value: !Sub ${RuleS3ActionObjectBucketName}
S3Prefix:
Value: !Sub ${RuleS3ActionObjectKeyPrefix}
SNSTopicArn:
Value: !Sub ${RuleS3ActionObjectSNSTopic}
【问题讨论】:
标签: amazon-web-services amazon-cloudformation amazon-ses