{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Template to create an SNS topic, subscribe an email, and set a billing alarm",
  "Parameters": {
	"EmailAddress": {
	  "Type": "String",
	  "Description": "Email address to subscribe to the SecurityAlerts SNS topic"
	}
  },
  "Resources": {
	"SecurityAlertsTopic": {
	  "Type": "AWS::SNS::Topic",
	  "Properties": {
		"TopicName": "SecurityAlerts"
	  }
	},
	"EmailSubscription": {
	  "Type": "AWS::SNS::Subscription",
	  "Properties": {
		"Protocol": "email",
		"Endpoint": {
		  "Ref": "EmailAddress"
		},
		"TopicArn": {
		  "Ref": "SecurityAlertsTopic"
		}
	  }
	},
	"BillingAlert": {
	  "Type": "AWS::CloudWatch::Alarm",
	  "Properties": {
		"AlarmDescription": "Alarm when AWS billing exceeds $10",
		"MetricName": "EstimatedCharges",
		"Namespace": "AWS/Billing",
		"Statistic": "Maximum",
		"Period": 21600,
		"EvaluationPeriods": 1,
		"Threshold": 10,
		"ComparisonOperator": "GreaterThanOrEqualToThreshold",
		"Dimensions": [
		  {
			"Name": "Currency",
			"Value": "USD"
		  }
		],
		"AlarmActions": [
		  {
			"Ref": "SecurityAlertsTopic"
		  }
		],
		"TreatMissingData": "notBreaching"
	  }
	}
  },
  "Outputs": {
	"SecurityAlertsTopicArn": {
	  "Description": "ARN of the SecurityAlerts SNS Topic",
	  "Value": {
		"Ref": "SecurityAlertsTopic"
	  }
	}
  }
}