|
| 1 | +{ |
| 2 | + "AWSTemplateFormatVersion": "2010-09-09", |
| 3 | + "Description": "cassandra Template", |
| 4 | + "Mappings":{ |
| 5 | + "AccountMap": { |
| 6 | + "325426749784": { |
| 7 | + "AlertNotifyEmail": "ecom-sbx-us-east-1@target.com", |
| 8 | + "Environment": "Dev", |
| 9 | + "ELBName": "ddn-cassandra-dev", |
| 10 | + "NotificationTopic":"", |
| 11 | + "AvailabilityZones":["us-east-1e","us-east-1d","us-east-1b","us-east-1a"], |
| 12 | + "Subnets":[""], |
| 13 | + "ChefServer":"", |
| 14 | + "DatabagSecretURL":"", |
| 15 | + "ValidationPEMURL":"", |
| 16 | + "IAMProfile":"", |
| 17 | + "ChefEnvironment":"", |
| 18 | + "KeyPair":"" |
| 19 | + }, |
| 20 | + "562186926922": { |
| 21 | + "AlertNotifyEmail": "", |
| 22 | + "Environment": "Dev", |
| 23 | + "ELBName": "", |
| 24 | + "NotificationTopic":"", |
| 25 | + "AvailabilityZones":["us-west-2a","us-west-2b","us-west-2c"], |
| 26 | + "Subnets":[""], |
| 27 | + "ChefServer":"", |
| 28 | + "DatabagSecretURL":"", |
| 29 | + "ValidationPEMURL":"", |
| 30 | + "IAMProfile":"", |
| 31 | + "ChefEnvironment":"", |
| 32 | + "KeyPair":"" |
| 33 | + }, |
| 34 | + "714815996242":{ |
| 35 | + "AlertNotifyEmail": "", |
| 36 | + "Environment": "Npe", |
| 37 | + "ELBName": "", |
| 38 | + "NotificationTopic":"", |
| 39 | + "AvailabilityZones":["us-east-1e","us-east-1d","us-east-1b","us-east-1a"], |
| 40 | + "Subnets":[""], |
| 41 | + "ChefServer":"", |
| 42 | + "DatabagSecretURL":"", |
| 43 | + "ValidationPEMURL":"", |
| 44 | + "ChefEnvironment":"csp1_stage_e1", |
| 45 | + "IAMProfile":"", |
| 46 | + "KeyPair":"" |
| 47 | + }, |
| 48 | + "942508335643":{ |
| 49 | + "AlertNotifyEmail": "", |
| 50 | + "Environment": "Npe", |
| 51 | + "ELBName": "", |
| 52 | + "NotificationTopic":"", |
| 53 | + "AvailabilityZones":["us-west-2a","us-west-2b","us-west-2c"], |
| 54 | + "Subnets":[""], |
| 55 | + "ChefServer":"", |
| 56 | + "DatabagSecretURL":"", |
| 57 | + "ValidationPEMURL":"", |
| 58 | + "ChefEnvironment":"", |
| 59 | + "IAMProfile":"", |
| 60 | + "KeyPair":"" |
| 61 | + }, |
| 62 | + "136043882679":{ |
| 63 | + "AlertNotifyEmail": "", |
| 64 | + "Environment": "Prod", |
| 65 | + "ELBName": "", |
| 66 | + "NotificationTopic":"", |
| 67 | + "AvailabilityZones":["us-east-1a","us-east-1b","us-east-1c","us-east-1e"], |
| 68 | + "Subnets":[""], |
| 69 | + "ChefServer":"", |
| 70 | + "DatabagSecretURL":"", |
| 71 | + "ValidationPEMURL":"", |
| 72 | + "ChefEnvironment":"", |
| 73 | + "IAMProfile":"", |
| 74 | + "KeyPair":"" |
| 75 | + }, |
| 76 | + "402148488131":{ |
| 77 | + "AlertNotifyEmail": "", |
| 78 | + "Environment": "Prod", |
| 79 | + "ELBName": "", |
| 80 | + "NotificationTopic":"", |
| 81 | + "AvailabilityZones":["us-west-2a","us-west-2b","us-west-2c"], |
| 82 | + "Subnets":[""], |
| 83 | + "ChefServer":"", |
| 84 | + "DatabagSecretURL":"", |
| 85 | + "ValidationPEMURL":"", |
| 86 | + "ChefEnvironment":"", |
| 87 | + "IAMProfile":"", |
| 88 | + "KeyPair":"" |
| 89 | + } |
| 90 | + } |
| 91 | + }, |
| 92 | + "Parameters": { |
| 93 | + "InstanceType": { |
| 94 | + "Description": "Instance type for application server", |
| 95 | + "Type": "String", |
| 96 | + "Default": "i2.2xlarge", |
| 97 | + "AllowedValues": [ |
| 98 | + "i2.2xlarge" |
| 99 | + ] |
| 100 | + |
| 101 | + }, |
| 102 | + "ComponentName": { |
| 103 | + "Description": "Application Name", |
| 104 | + "Type": "String", |
| 105 | + "AllowedValues": ["cassandra"] |
| 106 | + }, |
| 107 | + "LogWatchLogGroup" : { |
| 108 | + "Description" : ":Log watch IAM group", |
| 109 | + "Type" : "String", |
| 110 | + "Default" : "$region.params.logWatchLogGroup" |
| 111 | + }, |
| 112 | + "LogWatchStream" : { |
| 113 | + "Description" : ":Log watch log streamName", |
| 114 | + "Type" : "String", |
| 115 | + "Default" : "varlogboot" |
| 116 | + }, |
| 117 | + "LogWatchLogFile" : { |
| 118 | + "Description" : ":Log watch IAM group", |
| 119 | + "Type" : "String", |
| 120 | + "Default" : "/var/log/boot.log" |
| 121 | + }, |
| 122 | + "AutoscalingMinSize": { |
| 123 | + "Description": "Min Size of Autoscaling Group", |
| 124 | + "Type": "String", |
| 125 | + "Default": "6" |
| 126 | + }, |
| 127 | + "AutoscalingMaxSize": { |
| 128 | + "Description": "Max Size of Autoscaling Group", |
| 129 | + "Type": "String", |
| 130 | + "Default": "6" |
| 131 | + }, |
| 132 | + "AutoscalingDesiredSize": { |
| 133 | + "Description": "Desired Size of Autoscaling Group", |
| 134 | + "Type": "String", |
| 135 | + "Default": "6" |
| 136 | + }, |
| 137 | + "AmiId": { |
| 138 | + "Description": "Ami ID to deploy", |
| 139 | + "Type": "String", |
| 140 | + "Default": "$region.params.defaultImageId" |
| 141 | + }, |
| 142 | + "SharedServicesSG": { |
| 143 | + "Description": "Security group for Shared Services connectivity", |
| 144 | + "Type": "String", |
| 145 | + "Default": "valid-Sec-Grp" |
| 146 | + }, |
| 147 | + "ddncassandraSecurityGroup": { |
| 148 | + "Description": "Security group for cassandra app tiers", |
| 149 | + "Type": "String", |
| 150 | + "Default": "valid-Sec-Grp" |
| 151 | + } |
| 152 | + }, |
| 153 | + "Conditions": { |
| 154 | + "IsProd": { |
| 155 | + "Fn::Equals": [{ |
| 156 | + "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "Environment" ] |
| 157 | + }, "Prod"] |
| 158 | + } |
| 159 | + }, |
| 160 | + "Resources": { |
| 161 | + "AlertNotificationTopic": { |
| 162 | + "Type": "AWS::SNS::Topic", |
| 163 | + "Properties": { |
| 164 | + "Subscription": [{ |
| 165 | + "Endpoint": { |
| 166 | + "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "AlertNotifyEmail" ] |
| 167 | + }, |
| 168 | + "Protocol": "email" |
| 169 | + }], |
| 170 | + "TopicName": { |
| 171 | + "Fn::Join": ["-", [{ |
| 172 | + "Ref": "ComponentName" |
| 173 | + }, { |
| 174 | + "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "Environment" ] |
| 175 | + }, |
| 176 | + "AlertNotify" |
| 177 | + ]] |
| 178 | + }, |
| 179 | + "DisplayName": { |
| 180 | + "Fn::Join": ["-", [{ |
| 181 | + "Ref": "ComponentName" |
| 182 | + }, { |
| 183 | + "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "Environment" ] |
| 184 | + }, "AlertNotify"]] |
| 185 | + } |
| 186 | + } |
| 187 | + }, |
| 188 | + "ServerGroup": { |
| 189 | + "Type": "AWS::AutoScaling::AutoScalingGroup", |
| 190 | + "UpdatePolicy": { |
| 191 | + "AutoScalingRollingUpdate": { |
| 192 | + "MaxBatchSize": "1", |
| 193 | + "MinInstancesInService": "1", |
| 194 | + "PauseTime": "PT5M" |
| 195 | + } |
| 196 | + }, |
| 197 | + "Properties": { |
| 198 | + "NotificationConfiguration": { |
| 199 | + "TopicARN": { |
| 200 | + "Ref": "AlertNotificationTopic" |
| 201 | + }, |
| 202 | + "NotificationTypes": [ |
| 203 | + "autoscaling:EC2_INSTANCE_LAUNCH", |
| 204 | + "autoscaling:EC2_INSTANCE_LAUNCH_ERROR", |
| 205 | + "autoscaling:EC2_INSTANCE_TERMINATE", |
| 206 | + "autoscaling:EC2_INSTANCE_TERMINATE_ERROR" |
| 207 | + ] |
| 208 | + }, |
| 209 | + "AvailabilityZones": { |
| 210 | + "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "AvailabilityZones" ] |
| 211 | + }, |
| 212 | + "LaunchConfigurationName": { |
| 213 | + "Ref": "ServerLaunchConfig" |
| 214 | + }, |
| 215 | + "MinSize": { |
| 216 | + "Ref": "AutoscalingMinSize" |
| 217 | + }, |
| 218 | + "MaxSize": { |
| 219 | + "Ref": "AutoscalingMaxSize" |
| 220 | + }, |
| 221 | + "DesiredCapacity": { |
| 222 | + "Ref": "AutoscalingDesiredSize" |
| 223 | + }, |
| 224 | + "VPCZoneIdentifier": { |
| 225 | + "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "Subnets" ] |
| 226 | + }, |
| 227 | + "Tags": [{ |
| 228 | + "Key": "Name", |
| 229 | + "Value": { |
| 230 | + "Fn::Join": ["-", [{ |
| 231 | + "Ref": "AWS::StackName" |
| 232 | + }, { |
| 233 | + "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "Environment" ] |
| 234 | + }]] |
| 235 | + }, |
| 236 | + "PropagateAtLaunch": "true" |
| 237 | + }, |
| 238 | + { |
| 239 | + "Key": "SNSTopicARN", |
| 240 | + "Value": { |
| 241 | + "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "NotificationTopic" ] |
| 242 | + }, |
| 243 | + "PropagateAtLaunch": "true" |
| 244 | + }, |
| 245 | + {"Key": "Application", |
| 246 | + "Value": "cassandra", |
| 247 | + "PropagateAtLaunch": "true"}] |
| 248 | + } |
| 249 | + }, |
| 250 | + "ServerLaunchConfig": { |
| 251 | + "Type": "AWS::AutoScaling::LaunchConfiguration", |
| 252 | + "Properties": { |
| 253 | + "KeyName": { |
| 254 | + "Ref": "KeyName" |
| 255 | + }, |
| 256 | + "BlockDeviceMappings": [ |
| 257 | + { |
| 258 | + "DeviceName": "/dev/sda1", |
| 259 | + "Ebs": { |
| 260 | + "VolumeSize": 50, |
| 261 | + "DeleteOnTermination": true |
| 262 | + } |
| 263 | + }, |
| 264 | + { |
| 265 | + "DeviceName": "/dev/sdb", |
| 266 | + "VirtualName": "ephemeral0" |
| 267 | + }, |
| 268 | + { |
| 269 | + "DeviceName": "/dev/sdc", |
| 270 | + "VirtualName": "ephemeral1" |
| 271 | + } |
| 272 | + ], |
| 273 | + "ImageId": { |
| 274 | + "Ref": "AmiId" |
| 275 | + }, |
| 276 | + "UserData": { |
| 277 | + "Fn::Base64": { |
| 278 | + "Fn::Join" : [ "", [ |
| 279 | + "{", |
| 280 | + "\"logwatch\": ", |
| 281 | + "{", |
| 282 | + "\"streamName\": \"", { "Ref": "LogWatchStream"}, "\",", |
| 283 | + "\"loggroup\": \"", { "Ref": "LogWatchLogGroup"}, "\",", |
| 284 | + "\"logfile\": \"", { "Ref": "LogWatchLogFile"}, "\"", |
| 285 | + "},", |
| 286 | + "\"csp_data\": ", |
| 287 | + "{", |
| 288 | + "\"region\": \"", { "Ref": "AWS::Region"}, "\",", |
| 289 | + "\"account\": \"", { "Ref": "AWS::AccountId"}, "\",", |
| 290 | + "\"stackId\": \"", { "Ref": "AWS::StackId"}, "\",", |
| 291 | + "\"stackName\": \"", { "Ref": "AWS::StackName"}, "\"", |
| 292 | + "},", |
| 293 | + "\"attributes\": {", |
| 294 | + "\"environment\": \"", {"Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "ChefEnvironment" ]},"\",", |
| 295 | + "\"run_list\": [\"recipe[cassandra]\"]},", |
| 296 | + "\"chef_server\": \"", { "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "ChefServer" ] },"\",", |
| 297 | + "\"validation_pem_url\": \"", { "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "ValidationPEMURL" ] },"\",", |
| 298 | + "\"databag_secret_url\": \"", { "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "DatabagSecretURL" ] },"\"", |
| 299 | + "}" |
| 300 | + ] ] |
| 301 | + } |
| 302 | + }, |
| 303 | + "SecurityGroups": [ |
| 304 | + {"Ref": "ddncassandraSecurityGroup"}, |
| 305 | + {"Ref": "SharedServicesSG"} |
| 306 | + ], |
| 307 | + "IamInstanceProfile": { |
| 308 | + "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "IAMProfile" ] |
| 309 | + }, |
| 310 | + "KeyName": { |
| 311 | + "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "KeyPair" ] |
| 312 | + }, |
| 313 | + "InstanceType": { |
| 314 | + "Ref": "InstanceType" |
| 315 | + } |
| 316 | + } |
| 317 | + }, |
| 318 | + "ServerGroupScaleUpPolicy": { |
| 319 | + "Type": "AWS::AutoScaling::ScalingPolicy", |
| 320 | + "Properties": { |
| 321 | + "AdjustmentType": "ChangeInCapacity", |
| 322 | + "AutoScalingGroupName": { |
| 323 | + "Ref": "ServerGroup" |
| 324 | + }, |
| 325 | + "Cooldown": "60", |
| 326 | + "ScalingAdjustment": "1" |
| 327 | + } |
| 328 | + }, |
| 329 | + "ServerGroupScaleDownPolicy": { |
| 330 | + "Type": "AWS::AutoScaling::ScalingPolicy", |
| 331 | + "Properties": { |
| 332 | + "AdjustmentType": "ChangeInCapacity", |
| 333 | + "AutoScalingGroupName": { |
| 334 | + "Ref": "ServerGroup" |
| 335 | + }, |
| 336 | + "Cooldown": "60", |
| 337 | + "ScalingAdjustment": "-1" |
| 338 | + } |
| 339 | + }, |
| 340 | + "StatusCheckAlarm": { |
| 341 | + "Type": "AWS::CloudWatch::Alarm", |
| 342 | + "Condition": "IsProd", |
| 343 | + "Properties": { |
| 344 | + "AlarmDescription": " Status Check Failed", |
| 345 | + "MetricName": "StatusCheckFailed", |
| 346 | + "Namespace": "AWS/EC2", |
| 347 | + "Statistic": "Maximum", |
| 348 | + "Period": "60", |
| 349 | + "EvaluationPeriods": "3", |
| 350 | + "Threshold": "1", |
| 351 | + "AlarmActions": [{ |
| 352 | + "Fn::If": [ |
| 353 | + "IsProd", { |
| 354 | + "Fn::FindInMap" : [ "AccountMap", { "Ref" : "AWS::AccountId" }, "NotificationTopic" ] |
| 355 | + }, { |
| 356 | + "Ref": "AlertNotificationTopic" |
| 357 | + } |
| 358 | + ] |
| 359 | + }], |
| 360 | + "Dimensions": [{ |
| 361 | + "Name": "AutoScalingGroupName", |
| 362 | + "Value": { |
| 363 | + "Ref": "ServerGroup" |
| 364 | + } |
| 365 | + }], |
| 366 | + "ComparisonOperator": "GreaterThanOrEqualToThreshold" |
| 367 | + } |
| 368 | + } |
| 369 | + }, |
| 370 | + "Outputs": { |
| 371 | + "ServerGroup": { |
| 372 | + "Description": "AutoScalingGroup", |
| 373 | + "Value": { "Ref": "ServerGroup" } |
| 374 | + } |
| 375 | + } |
| 376 | +} |
0 commit comments