This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelasticBeanStalk_setup.yml
228 lines (224 loc) · 7.51 KB
/
elasticBeanStalk_setup.yml
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
AWSTemplateFormatVersion: 2010-09-09
Description: Elasticbeanstalk test template
Parameters:
SolutionStackName:
#64bit Amazon Linux 2018.03 v4.14.1 running Node.js
Type: String
Default: ""
PlatformArn:
Type: String
Default: ""
NotificationEmail:
Type: String
EC2KeyName:
Type: String
Resources:
S3BucketELBLog:
Type: 'AWS::S3::Bucket'
S3BucketELBLogBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref S3BucketELBLog
PolicyDocument:
Statement:
- Effect: Allow
Principal:
AWS: arn:aws:iam::127311923021:root
Action: s3:PutObject
Resource: !Join
- ''
- - !GetAtt S3BucketELBLog.Arn
- /ELB/*
- Effect: Allow
Principal:
Service: delivery.logs.amazonaws.com
Action: s3:PutObject
Resource: !Join
- ''
- - !GetAtt S3BucketELBLog.Arn
- /ELB/*
Condition:
StringEquals:
s3:x-amz-acl: bucket-owner-full-control
- Effect: Allow
Principal:
Service: delivery.logs.amazonaws.com
Action: s3:GetBucketAcl
Resource: !GetAtt S3BucketELBLog.Arn
IAMRoleElasticBeanstalkService:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- elasticbeanstalk.amazonaws.com
Action:
- 'sts:AssumeRole'
Condition:
StringEquals:
sts:ExternalId: elasticbeanstalk
Path: /
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkEnhancedHealth
- arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkService
IAMRoleElasticBeanstalkEC2:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Statement:
- Sid: ""
Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
Policies:
- PolicyName: dynamodb-table-access
PolicyDocument:
Statement:
- Sid: ListAndDescribe
Effect: Allow
Action:
- dynamodb:List*
- dynamodb:DescribeReservedCapacity*
- dynamodb:DescribeLimits
- dynamodb:DescribeTimeToLive
Resource: "*"
- Sid: SpecificTable
Effect: Allow
Action:
- dynamodb:BatchGetItem
- dynamodb:BatchWriteItem
- dynamodb:DescribeTable
- dynamodb:Get*
- dynamodb:Query
- dynamodb:Scan
- dynamodb:DeleteItem
- dynamodb:UpdateItem
- dynamodb:PutItem
Resource: !GetAtt CommentsTable.Arn
Version: 2012-10-17
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AWSElasticBeanstalkWebTier
- arn:aws:iam::aws:policy/AWSElasticBeanstalkMulticontainerDocker
- arn:aws:iam::aws:policy/AWSElasticBeanstalkWorkerTier
IAMInstanceProfileEC2:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref IAMRoleElasticBeanstalkEC2
Application:
Properties:
ApplicationVersions:
- Description: Version 1.0
SourceBundle:
S3Bucket: !Join
- '-'
- - elasticbeanstalk-samples
- !Ref 'AWS::Region'
S3Key: nodejs-sample.zip
VersionLabel: Initial Version
Description: Demo App
Type: AWS::ElasticBeanstalk::Application
Environment:
Properties:
ApplicationName: !Ref Application
Description: AWS Elastic Beanstalk Environment running Node.js Sample Application
PlatformArn: !Ref PlatformArn
SolutionStackName: !Ref SolutionStackName
VersionLabel: Initial Version
OptionSettings:
- Namespace: aws:elasticbeanstalk:command
OptionName: BatchSize
Value: '1'
- Namespace: aws:elasticbeanstalk:command
OptionName: BatchSizeType
Value: Fixed
- Namespace: aws:elasticbeanstalk:command
OptionName: DeploymentPolicy
Value: AllAtOnce
- Namespace: aws:elasticbeanstalk:application:environment
OptionName: AWS_REGION
Value: !Ref 'AWS::Region'
- Namespace: aws:elasticbeanstalk:application:environment
OptionName: DYNAMODB_TABLENAME
Value: !Ref CommentsTable
- Namespace: aws:autoscaling:trigger
OptionName: BreachDuration
Value: '2'
- Namespace: aws:autoscaling:trigger
OptionName: LowerThreshold
Value: '1'
- Namespace: aws:autoscaling:trigger
OptionName: MeasureName
Value: TargetResponseTime
- Namespace: aws:autoscaling:trigger
OptionName: Period
Value: '2'
- Namespace: aws:autoscaling:trigger
OptionName: Unit
Value: Seconds
- Namespace: aws:elasticbeanstalk:environment:process:default
OptionName: Port
Value: '8080'
- Namespace: aws:autoscaling:launchconfiguration
OptionName: EC2KeyName
Value: !Ref EC2KeyName
- Namespace: aws:autoscaling:trigger
OptionName: UpperThreshold
Value: '2'
- Namespace: aws:elasticbeanstalk:sns:topics
OptionName: Notification Endpoint
Value: !Ref NotificationEmail
- Namespace: aws:autoscaling:asg
OptionName: MaxSize
Value: '2'
- Namespace: aws:elbv2:loadbalancer
OptionName: AccessLogsS3Enabled
Value: true
- Namespace: aws:elbv2:loadbalancer
OptionName: AccessLogsS3Prefix
Value: ELB
- Namespace: aws:elbv2:loadbalancer
OptionName: AccessLogsS3Bucket
Value: !Ref S3BucketELBLog
- Namespace: aws:elasticbeanstalk:cloudwatch:logs
OptionName: StreamLogs
Value: true
- Namespace: aws:elasticbeanstalk:environment
OptionName: ServiceRole
Value: !Ref IAMRoleElasticBeanstalkService
- Namespace: aws:elasticbeanstalk:environment
OptionName: LoadBalancerType
Value: application
- Namespace: aws:autoscaling:launchconfiguration
OptionName: IamInstanceProfile
Value: !Ref IAMInstanceProfileEC2
- Namespace: aws:elasticbeanstalk:cloudwatch:logs:health
OptionName: HealthStreamingEnabled
Value: true
- Namespace: aws:elasticbeanstalk:healthreporting:system
OptionName: SystemType
Value: enhanced
Type: AWS::ElasticBeanstalk::Environment
CommentsTable:
Type: AWS::DynamoDB::Table
Properties:
KeySchema:
HashKeyElement: {AttributeName: Subject, AttributeType: S}
RangeKeyElement: {AttributeName: User, AttributeType: S}
ProvisionedThroughput: {ReadCapacityUnits: 1, WriteCapacityUnits: 1}
Outputs:
ApplicationID:
Description: Logical ID of the Elastic Beanstalk Application
Value: !Ref Application
EnvironmentID:
Description: Logical ID of the Elastic Beanstalk Environment
Value: !Ref Environment
EnvironmentURL:
Description: URL of the Elastic Beanstalk Environment
Value: !GetAtt Environment.EndpointURL