Permalink
Fetching contributors…
Cannot retrieve contributors at this time
167 lines (166 sloc) 3.88 KB
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"GitSha": {
"Type": "String",
"Description": "GitSha to deploy"
},
"DarkSkySecretKey": {
"Type": "String",
"Description": "A Dark Sky secret key to use for authentication"
},
"SlackChannel": {
"Type": "String",
"Description": "Slack channel for posting the weather message.",
"Default": "#general"
},
"SlackHookURL": {
"Type": "String",
"Description": "Webhook URL to which to post the weather messages",
"Default": ""
},
"Lat": {
"Type": "String",
"Description": "Latitude of your location",
"Default": "43.0833231"
},
"Long": {
"Type": "String",
"Description": "Longitude of your location",
"Default": "-73.8712154"
}
},
"Resources": {
"WeatherBotRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"Path": "/weatherbot/",
"AssumeRolePolicyDocument": {
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
},
"Policies": [
{
"PolicyName": "CloudWatch",
"PolicyDocument": {
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:*"
],
"Resource": "arn:aws:logs:*:*:*"
}
]
}
}
]
}
},
"WeatherBotFunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Fn::Join": [
"",
[
"kdecorah-",
{
"Ref": "AWS::Region"
}
]
]
},
"S3Key": {
"Fn::Join": [
"",
[
"weatherbot/",
{
"Ref": "GitSha"
},
".zip"
]
]
}
},
"Role": {
"Fn::GetAtt": [
"WeatherBotRole",
"Arn"
]
},
"Environment": {
"Variables": {
"SlackChannel": {
"Ref": "SlackChannel"
},
"DarkSkySecretKey": {
"Ref": "DarkSkySecretKey"
},
"Lat": {
"Ref": "Lat"
},
"Long": {
"Ref": "Long"
},
"SlackHookURL": {
"Ref": "SlackHookURL"
}
}
},
"Description": "weather",
"Handler": "index.weather",
"MemorySize": 128,
"Runtime": "nodejs6.10",
"Timeout": 300
}
},
"TriggerWeatherBotFunctionEveryDay": {
"Type": "AWS::Events::Rule",
"Properties": {
"Description": "7am, 1pm, 7pm EST every day",
"ScheduleExpression": "cron(0 0,12,18 * * ? *)",
"State": "ENABLED",
"Targets": [
{
"Arn": {
"Fn::GetAtt": [
"WeatherBotFunction",
"Arn"
]
},
"Id": "TriggerWeatherBotFunctionEveryDay"
}
]
}
},
"TriggerWeatherBotFunctionEveryDayPermission": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"WeatherBotFunction",
"Arn"
]
},
"Principal": "events.amazonaws.com",
"SourceArn": {
"Fn::GetAtt": [
"TriggerWeatherBotFunctionEveryDay",
"Arn"
]
}
}
}
}
}