account_alerts.tf 758 B

12345678910111213141516171819202122232425
  1. # An SNS queue for email alerts
  2. resource "aws_sns_topic" "account-alerts" {
  3. name = "account-alerts"
  4. tags = merge(var.standard_tags, var.tags)
  5. }
  6. resource "aws_sns_topic_policy" "account-alerts" {
  7. arn = aws_sns_topic.account-alerts.arn
  8. policy = data.aws_iam_policy_document.account-alerts.json
  9. }
  10. data "aws_iam_policy_document" "account-alerts" {
  11. statement {
  12. sid = "AllowAllAccountsToPublish"
  13. actions = [ "SNS:Publish" ]
  14. effect = "Allow"
  15. resources = [ aws_sns_topic.account-alerts.arn ]
  16. principals {
  17. type = "AWS"
  18. identifiers = [ for a in var.responsible_accounts[var.environment]: "arn:${var.aws_partition}:iam::${a}:root" ]
  19. }
  20. }
  21. }
  22. # Unfortunately, terraform does not support email destinations