forked from AHinMaine/AWSCloudFormation-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ElasticBeanstalk.template
161 lines (157 loc) · 6.23 KB
/
ElasticBeanstalk.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template ElasticBeanstalk: Configure and launch an AWS Elastic Beanstalk application that connects to an Amazon RDS database instance. Monitoring is setup on the database. Note, since AWS Elastic Beanstalk is only available in US-East-1, this template can only be used to create stacks in the US-East-1 region. **WARNING** This template creates one or more Amazon EC2 instances and an Amazon Relational Database Service database instance. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"DatabaseName": {
"Default": "BeanstalkDB",
"Type": "String",
"Description" : "Test database name",
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
},
"DatabaseUser": {
"Default": "admin",
"NoEcho": "true",
"Type": "String",
"Description" : "Test database admin account name",
"MinLength": "1",
"MaxLength": "16",
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
},
"DatabasePassword": {
"Default": "password",
"NoEcho": "true",
"Type": "String",
"Description" : "Test database admin account password",
"MinLength": "8",
"MaxLength": "41",
"AllowedPattern" : "[a-zA-Z0-9]*",
"ConstraintDescription" : "must contain only alphanumeric characters."
},
"DatabasePort": {
"Default": "3306",
"Type": "Number",
"MinValue": "1150",
"MaxValue": "65535",
"Description" : "TCP/IP port for the RDS database"
},
"MultiAZ" : {
"Description" : "Create a highly available, multi-AZ RDS instance",
"Type" : "String",
"Default" : "false",
"AllowedValues" : ["true", "false"],
"Description" : "enter true or false."
},
"OperatorEmail": {
"Default": "[email protected]",
"Description": "Email address to notify if there are any operational issues",
"Type": "String"
}
},
"Resources" : {
"SampleApplication" : {
"Type" : "AWS::ElasticBeanstalk::Application",
"Properties" : {
"Description" : "AWS Elastic Beanstalk Sample Application",
"ApplicationVersions" : [{
"VersionLabel" : "Initial Version",
"Description" : "Version 1.0",
"SourceBundle" : {
"S3Bucket" : { "Fn::Join" : ["-", ["cloudformation-samples", { "Ref" : "AWS::Region" }]]},
"S3Key" : "CloudFormationBeanstalkRDSExample.war"
}
}],
"ConfigurationTemplates" : [{
"TemplateName" : "DefaultConfiguration",
"Description" : "Default Configuration Version 1.0 - with SSH access",
"SolutionStackName" : "64bit Amazon Linux running Tomcat 7",
"OptionSettings" : [{
"Namespace" : "aws:elasticbeanstalk:application:environment",
"OptionName" : "JDBC_CONNECTION_STRING",
"Value" : { "Fn::Join": [ "", [ "jdbc:mysql://",
{ "Fn::GetAtt": [ "SampleDB", "Endpoint.Address" ] },
":",
{ "Ref": "DatabasePort" },
"/",
{ "Ref": "DatabaseName" }]]}
},{
"Namespace" : "aws:elasticbeanstalk:application:environment",
"OptionName" : "PARAM1",
"Value" : { "Ref" : "DatabaseUser" }
},{
"Namespace" : "aws:elasticbeanstalk:application:environment",
"OptionName" : "PARAM2",
"Value" : { "Ref" : "DatabasePassword" }
}]
}]
}
},
"SampleEnvironment" : {
"Type" : "AWS::ElasticBeanstalk::Environment",
"Properties" : {
"ApplicationName" : { "Ref" : "SampleApplication" },
"Description" : "AWS Elastic Beanstalk Environment running Sample Application",
"TemplateName" : "DefaultConfiguration",
"VersionLabel" : "Initial Version"
}
},
"DBSecurityGroup": {
"Properties": {
"DBSecurityGroupIngress": {
"EC2SecurityGroupName": "elasticbeanstalk-default"
},
"GroupDescription": "database access"
},
"Type": "AWS::RDS::DBSecurityGroup"
},
"SampleDB": {
"Properties": {
"Engine": "MySQL",
"DBName": { "Ref": "DatabaseName" },
"Port": { "Ref": "DatabasePort" },
"MultiAZ" : { "Ref" : "MultiAZ" },
"MasterUsername": { "Ref": "DatabaseUser" },
"DBInstanceClass": "db.m1.small",
"DBSecurityGroups": [ { "Ref": "DBSecurityGroup" } ],
"AllocatedStorage": "5",
"MasterUserPassword": { "Ref": "DatabasePassword" }
},
"Type": "AWS::RDS::DBInstance"
},
"AlarmTopic": {
"Properties": {
"Subscription": [{
"Endpoint": { "Ref": "OperatorEmail" },
"Protocol": "email"
} ]
},
"Type": "AWS::SNS::Topic"
},
"CPUAlarmHigh": {
"Type" : "AWS::CloudWatch::Alarm",
"Properties": {
"EvaluationPeriods": "10",
"Statistic": "Average",
"Threshold": "50",
"AlarmDescription": "Alarm if CPU too high or metric disappears indicating the RDS database instance is having issues",
"Period": "60",
"Namespace": "AWS/RDS",
"MetricName": "CPUUtilization",
"Dimensions": [ {
"Name": "DBInstanceIdentifier",
"Value": { "Ref": "SampleDB" }
} ],
"ComparisonOperator": "GreaterThanThreshold",
"AlarmActions": [ { "Ref": "AlarmTopic" } ],
"InsufficientDataActions": [ { "Ref": "AlarmTopic" } ]
}
}
},
"Outputs" : {
"URL" : {
"Description" : "URL of the AWS Elastic Beanstalk Environment",
"Value" : { "Fn::Join" : [ "", [ "http://", { "Fn::GetAtt" : [ "SampleEnvironment", "EndpointURL" ] }]]}
}
}
}