Unfortunately this is a ui driven process
- Go to https://your-company.slack.com/services/new
- Click 'Incoming WebHooks'
- Create a new one by selecting a channel and clicking "Add incoming webhook integration"
- Copy the webhook url for use later
> aws sns create-topic --name Billing
{
"TopicArn": "arn:aws:sns:us-east-1:111122223333:Billing"
}
> aws sns subscribe --topic-arn arn:aws:sns:us-east-1:111122223333:Billing --protocol email --notification-endpoint <your-email-address>
> aws cloudwatch put-metric-alarm \
--alarm-name "billing more than $1" \
--comparison-operator GreaterThanOrEqualToThreshold \
--evaluation-periods 1 \
--metric-name EstimatedCharges \
--namespace AWS/Billing \
--dimensions Name=Currency,Value=USD" \
--period 21600 \
--statistic Maximum \
--threshold 1 \
--actions-enabled \
--alarm-actions arn:aws:sns:us-east-1:111122223333:Billing
> aws lambda create-function \
--function-name snsToSlack \
--zip-file file://file-path/snsToSlack-created-from-snsToSlack.js.zip \
--role role-arn-looked-up-from-iam \
--handler index.handler \
--runtime nodejs
{
"CodeSize": number,
"Description": "string",
"FunctionArn": "string",
"FunctionName": "string",
"Handler": "string",
"LastModified": "string",
"MemorySize": number,
"Role": "string",
"Runtime": "string",
"Timeout": number
}
> aws sns subscribe \
--topic-arn arn:aws:sns:us-east-1:111122223333:Billing \
--protocol lambda \
--notification-endpoint arn:aws:lambda:REGION:ACCOUNT:function:LAMBDAFUNCTION