https://pulumi.com logo
#general
Title
# general
f

full-dress-10026

03/20/2019, 9:47 PM
Trying to set up a SNS email subscription and I see this in the docs for `TopicSubscriptionArgs`:
Copy code
/**
     * The protocol to use. The possible values for this are: `sqs`, `sms`, `lambda`, `application`. (`http` or `https` are partially supported, see below) (`email` is option but unsupported, see below).
     */
    readonly protocol: pulumi.Input<string>;
What does "(
email
is option but unsupported, see below)" mean? How am I supposed to create an email subscription?
s

stocky-spoon-28903

03/20/2019, 9:49 PM
Not as far as I’m aware right now
It’s been a limitation of Terraform forever
f

full-dress-10026

03/20/2019, 9:50 PM
So how do people set up CloudWatch alarms with email? Do users typically do this manually?
s

stocky-spoon-28903

03/20/2019, 9:52 PM
My guess is manually, I’ve never actually tried it though
f

full-dress-10026

03/20/2019, 9:55 PM
Seems like the workaround is to use a CF stack to create the subscription: http://aws-cloud.guru/terraform-sns-topic-email-list/. Nasty but will probably work.
s

stocky-spoon-28903

03/20/2019, 10:02 PM
Ugh, that sucks. I wonder if we can do better here. It’s conceivable that there are other workflows since that was done in Terraform (similar to ACM etc)
f

full-dress-10026

03/20/2019, 10:07 PM
It may be possible to wrap a CF template, similar to what the awsx.Cluster.createAutoScalingGroup does.
Will try something like this:
Copy code
function snsEmailSubscription(topicArn: string, email: string) {
    return new aws.cloudformation.Stack("alert-email-subscribe", {
        templateBody: JSON.stringify({
            "AWSTemplateFormatVersion": "2010-09-09",
            "Resources": {
                "EmailSNSTopic": {
                    "Type": "AWS::SNS::Subscription",
                    "Properties": {
                        "TopicArn": topicArn,
                        "Protocol": "email",
                        "Endpoint": email
                    }
                }
            }
        }),
        capabilities: ["CAPABILITY_NAMED_IAM"]
    })
}
s

stocky-spoon-28903

03/20/2019, 10:36 PM
This is probably the kind of thing we should consider adding to
awsx
itself, too (cc @white-balloon-205)
f

full-dress-10026

03/20/2019, 11:40 PM
FWIW, the above snippet works nicely.
2 Views