Last active
March 25, 2016 09:46
-
-
Save aq/641418103c8435e42606 to your computer and use it in GitHub Desktop.
Sample of an Elasticbeanstalk config file used by eb cli to create an autoscaled worker based on an SQS queue .ebextension/autoscaling.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The name of this file is autoscaling.config. .yml has been added for syntax highlighting. | |
# References: | |
# http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-elasticbeanstalksqsd | |
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html | |
# http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-resources.html | |
# Create manually first those 2 resources: | |
# * the SQS queue, here its name is: my-sqs-queue | |
# * the RDS Postgres database | |
# * the Elasticache cluster (Redis) | |
# * the EC2 security group named: my-ec2-security-group-bridge (RDS-Elasticache access) | |
# Setup the correct IAM configuration with: autoscaling_iam_configuration.json | |
option_settings: | |
- namespace: aws:elasticbeanstalk:command | |
option_name: Timeout | |
value: 900 | |
- namespace: aws:elasticbeanstalk:sqsd | |
option_name: WorkerQueueURL | |
value: https://sqs.us-east-1.amazonaws.com/123123123123/my-sqs-queue | |
- namespace: aws:elasticbeanstalk:sqsd | |
option_name: HttpConnections | |
value: 1 | |
- namespace: aws:elasticbeanstalk:sqsd | |
option_name: VisibilityTimeout | |
value: 600 | |
- namespace: aws:autoscaling:asg | |
option_name: MinSize | |
value: 1 | |
- namespace: aws:autoscaling:asg | |
option_name: MaxSize | |
value: 100 | |
- namespace: aws:autoscaling:launchconfiguration | |
option_name: InstanceType | |
value: m3.medium | |
- namespace: aws:autoscaling:launchconfiguration | |
option_name: SecurityGroups | |
value: | |
- Ref: AWSEBSecurityGroup | |
- my-ec2-security-group-bridge | |
Resources: | |
ScalingPolicy1: | |
Type: AWS::AutoScaling::ScalingPolicy | |
Properties: | |
ScalingAdjustment: 1 | |
AdjustmentType: ChangeInCapacity | |
AutoScalingGroupName: | |
Ref: AWSEBAutoScalingGroup | |
QueueDepthAlarm1: | |
Type: AWS::CloudWatch::Alarm | |
Properties: | |
AlarmDescription: "Alarm if queue is bigger than 3 messages in average" | |
Namespace: AWS/SQS | |
MetricName: ApproximateNumberOfMessagesVisible | |
Dimensions: | |
- Name: QueueName | |
Value: my-sqs-queue | |
Statistic: Average | |
Period: 60 | |
EvaluationPeriods: 2 | |
Threshold: 5 | |
ComparisonOperator: GreaterThanOrEqualToThreshold | |
AlarmActions: | |
- Ref: ScalingPolicy1 | |
ScalingPolicy2: | |
Type: AWS::AutoScaling::ScalingPolicy | |
Properties: | |
ScalingAdjustment: 20 | |
AdjustmentType: ChangeInCapacity | |
AutoScalingGroupName: | |
Ref: AWSEBAutoScalingGroup | |
QueueDepthAlarm2: | |
Type: AWS::CloudWatch::Alarm | |
Properties: | |
AlarmDescription: "Alarm if queue is bigger than 10 messages in average" | |
Namespace: AWS/SQS | |
MetricName: ApproximateNumberOfMessagesVisible | |
Dimensions: | |
- Name: QueueName | |
Value: my-sqs-queue | |
Statistic: Average | |
Period: 60 | |
EvaluationPeriods: 2 | |
Threshold: 10 | |
ComparisonOperator: GreaterThanOrEqualToThreshold | |
AlarmActions: | |
- Ref: ScalingPolicy2 | |
ScalingPolicy3: | |
Type: AWS::AutoScaling::ScalingPolicy | |
Properties: | |
ScalingAdjustment: -5 | |
AdjustmentType: ChangeInCapacity | |
AutoScalingGroupName: | |
Ref: AWSEBAutoScalingGroup | |
QueueDepthAlarm3: | |
Type: AWS::CloudWatch::Alarm | |
Properties: | |
AlarmDescription: "Alarm if queue is less than 5 messages in average" | |
Namespace: AWS/SQS | |
MetricName: ApproximateNumberOfMessagesVisible | |
Dimensions: | |
- Name: QueueName | |
Value: my-sqs-queue | |
Statistic: Average | |
Period: 60 | |
EvaluationPeriods: 2 | |
Threshold: 2 | |
ComparisonOperator: LessThanOrEqualToThreshold | |
AlarmActions: | |
- Ref: ScalingPolicy3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "EBSBucketAccess", | |
"Action": [ | |
"s3:Get*", | |
"s3:List*", | |
"s3:PutObject" | |
], | |
"Effect": "Allow", | |
"Resource": [ | |
"arn:aws:s3:::elasticbeanstalk-*", | |
"arn:aws:s3:::elasticbeanstalk-*/*" | |
] | |
}, | |
{ | |
"Action": "s3:*", | |
"Effect": "Allow", | |
"Sid": "Mybucket", | |
"Resource": [ | |
"arn:aws:s3:::my-bucket", | |
"arn:aws:s3:::my-bucket/*" | |
] | |
}, | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"ecs:Poll", | |
"ecs:StartTask", | |
"ecs:StopTask", | |
"ecs:DiscoverPollEndpoint", | |
"ecs:StartTelemetrySession", | |
"ecs:RegisterContainerInstance", | |
"ecs:DeregisterContainerInstance", | |
"ecs:DescribeContainerInstances", | |
"ecs:Submit*" | |
], | |
"Resource": "*" | |
}, | |
{ | |
"Sid": "QueueAccess", | |
"Action": "sqs:*", | |
"Effect": "Allow", | |
"Resource": "*" | |
}, | |
{ | |
"Sid": "MetricsAccess", | |
"Action": [ | |
"cloudwatch:PutMetricData", | |
"ec2:DescribeTags" | |
], | |
"Effect": "Allow", | |
"Resource": "*" | |
}, | |
{ | |
"Sid": "ECSAccess", | |
"Effect": "Allow", | |
"Action": [ | |
"ecs:Poll", | |
"ecs:StartTask", | |
"ecs:StopTask", | |
"ecs:DiscoverPollEndpoint", | |
"ecs:StartTelemetrySession", | |
"ecs:RegisterContainerInstance", | |
"ecs:DeregisterContainerInstance", | |
"ecs:DescribeContainerInstances", | |
"ecs:Submit*" | |
], | |
"Resource": "*" | |
}, { | |
"Sid": "DynamoPeriodicTasks", | |
"Action": [ | |
"dynamodb:BatchGetItem", | |
"dynamodb:BatchWriteItem", | |
"dynamodb:DeleteItem", | |
"dynamodb:GetItem", | |
"dynamodb:PutItem", | |
"dynamodb:Query", | |
"dynamodb:Scan", | |
"dynamodb:UpdateItem" | |
], | |
"Effect": "Allow", | |
"Resource": [ | |
"arn:aws:dynamodb:*:*:table/*-stack-AWSEBWorkerCronLeaderRegistry*" | |
] | |
}, { | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment