AWS CloudFormation: How to create aws budget with multiple emails

0

I have a cloudformation template like this:

 Parameters:
     EmailList:
       Type: String
  
  Resources:
      Budget:
        Type: AWS::Budgets::Budget
        Properties:
          Budget:
            BudgetName: "my-test-budget"
          NotificationsWithSubscribers:
            - Notification:
                NotificationType: !Ref NotificationType
                ComparisonOperator: GREATER_THAN
                Threshold: !Ref WarningThreshold
              Subscribers:
                Address: !Ref EmailList

Here the EmailList is array of emailIds searated by comma(e.g: abc@gmail.com,hello123@gmail.com), hence cannot use !Ref EmailList directly, If I split the EmailList and assign it to Address

Address: !Split [",", !Ref EmailList] 

this is not working, as Address field is expecting only one email Id to be assigned at once.

Since EmailList is a user provided emails, splitting by index o(i.e.

 Address: !Select [0, !Split [",", !Ref EmailList]]

) wouldn't be helpful as this assigns only 0th emailId to Address, also, will not be knowing exactly how many email ids will be provided.

As the https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-budgets-budget.html assigns each email to individually to Address, but https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-budgets-budget-notificationwithsubscribers.html#cfn-budgets-budget-notificationwithsubscribers-subscribers says subnscribers are list of subscribers, but its is expecting individual emailId to be provided.

How can we split and assign each emailId to Address field individually?

1 Answer
0

Hello.

"Subscribers" is "Array of Subscribers", so you need to do the following:
In other words, I think it is necessary to pass the email addresses one by one as parameters instead of separating them with commas.
Alternatively, there may be a workaround such as creating a mailing list and consolidating it into one email address.

Parameters:
    Email1:
      Type: String
    Email2:
      Type: String

 Resources:
     Budget:
       Type: AWS::Budgets::Budget
       Properties:
         Budget:
           BudgetName: "my-test-budget"
         NotificationsWithSubscribers:
           - Notification:
               NotificationType: !Ref NotificationType
               ComparisonOperator: GREATER_THAN
               Threshold: !Ref WarningThreshold
             Subscribers:
               - Address: !Ref Email1
                 SubscriptionType: EMAIL
               - Address: !Ref Email2
                 SubscriptionType: EMAIL
profile picture
EXPERT
answered 17 days ago
profile pictureAWS
EXPERT
reviewed 17 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions