Permalink
Find file
7044a2c Feb 25, 2017
@cbeer @eefahy @jcoyne @bbranan
463 lines (461 sloc) 15.5 KB
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Hydra-in-a-Box application worker tier",
"Parameters" : {
"StackName": {
"Type": "String",
"Description": "Name of the ElasticBeanstalk environment",
"Default" : "HyboxApplication"
},
"ApplicationName": {
"Type": "String",
"Description": "Name of the ElasticBeanstalk environment"
},
"VersionLabel": {
"Type": "String",
"Description": "Name of the ElasticBeanstalk version"
},
"KeyName": {
"Type": "AWS::EC2::KeyPair::KeyName",
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the ECS instances"
},
"MinSize": {
"Type": "Number",
"Default" : "1",
"Description": "Minimum number of instances"
},
"MaxSize": {
"Type": "Number",
"Default" : "4",
"Description": "Maximum number of instances"
},
"PublicSubnets": {
"Type": "List<AWS::EC2::Subnet::Id>",
"Description": "[UNUSED] List of an existing subnet IDs to use for the load balancer"
},
"PrivateSubnets": {
"Type": "List<AWS::EC2::Subnet::Id>",
"Description": "List of an existing subnet IDs to use for the auto scaling group"
},
"SecurityGroups": {
"Type": "List<AWS::EC2::SecurityGroup::Id>",
"Description": "A list of security groups, such as sg-a123fd85."
},
"LBSecurityGroups": {
"Type": "List<AWS::EC2::SecurityGroup::Id>",
"Description": "[UNUSED] A list of security groups, such as sg-a123fd85."
},
"HostedZoneName" : {
"Description" : "Route53 zone to create an alias in",
"Type" : "String"
},
"SecretKeyBase" : {
"NoEcho": "true",
"Description" : "Secret key for Rails",
"Type" : "String"
},
"FcrepoUrl" : {
"Description" : "URL to Fedora",
"Type" : "String"
},
"SolrUrl" : {
"Description" : "URL to Solr",
"Type" : "String"
},
"ZookeeperHosts": {
"Type": "String",
"Description": "A list of zookeeper host IP + ports",
"Default": "127.0.0.1:2181"
},
"RedisHost": {
"Type": "String",
"Description": "URL to Redis"
},
"RedisPort": {
"Type": "String",
"Description": "Redis Port",
"Default": "6379"
},
"RDSDatabaseName": {
"Type": "String",
"Description": "Database name",
"Default": "hybox"
},
"RDSUsername": {
"Type": "String",
"Description": "Username for Database",
"Default": "root"
},
"RDSPassword": {
"NoEcho": "true",
"Type": "String",
"Description": "Password for Database",
"Default": "changeme"
},
"RDSHostname": {
"Type": "String",
"Description": "Hostname for RDS Database"
},
"RDSPort": {
"Type": "String",
"Description": "Database Port",
"Default": "5432"
},
"QueuePrefix": {
"Type": "String",
"Description": "SQS Queue prefix",
"Default": "hybox"
},
"DefaultQueue": {
"Type": "String",
"Description": "SQS Default Queue"
},
"DefaultQueueName": {
"Type": "String",
"Description": "SQS Default Queue Name"
},
"IamInstanceProfile" : {
"Description" : "ARN for an IAM profile to assign to the EC2 instances",
"Type" : "String"
},
"UploadBucket" : {
"Description" : "S3 Bucket to store uploaded files into",
"Type" : "String"
},
"InstanceType" : {
"Description" : "The EC2 instance type",
"Type" : "String",
"Default" : "t2.medium",
"AllowedValues" : [ "t2.micro", "t2.small", "t2.medium", "t2.large", "m3.medium", "m3.large", "m3.xlarge",
"m3.2xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "c4.large", "c4.xlarge",
"c4.2xlarge", "c4.4xlarge", "c4.8xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge",
"i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge", "d2.xlarge", "d2.2xlarge", "d2.4xlarge", "d2.8xlarge",
"hi1.4xlarge", "hs1.8xlarge", "cr1.8xlarge", "cc2.8xlarge", "m4.large", "m4.xlarge", "m4.2xlarge", "m4.4xlarge",
"m4.10xlarge", "m4.16xlarge"],
"ConstraintDescription" : "must be a valid EC2 instance type."
},
"HealthReportingSystemType": {
"Type": "String",
"Description": "Health reporting system",
"Default": "enhanced",
"AllowedValues" : [ "enhanced", "basic"]
},
"BeanstalkSNSTopic": {
"Type": "String",
"Description": "SNS Topic for Beanstalk application to write change events to"
},
"HoneybadgerApiKey": {
"Type": "String",
"Description": "The api key for honeybadger.io",
"Default": ""
},
"LogzioKey": {
"Type": "String",
"Description": "The logz.io key",
"Default": ""
}
},
"Resources" : {
"WorkerEnvironment": {
"Type": "AWS::ElasticBeanstalk::Environment",
"Properties": {
"ApplicationName": { "Ref": "ApplicationName" },
"Description": "Hybox worker Environment",
"EnvironmentName": { "Fn::Join": ["-", [{ "Ref" : "StackName"}, "workers"]] },
"TemplateName": { "Ref": "HyboxWorkersConfigurationTemplate" },
"VersionLabel": { "Ref": "VersionLabel" },
"Tier": {
"Name": "Worker",
"Type": "SQS/HTTP"
},
"OptionSettings" : [
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "STACK_NAME",
"Value": { "Ref": "StackName"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SECRET_KEY_BASE",
"Value": { "Ref" : "SecretKeyBase"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "RAILS_GROUPS",
"Value": "aws"
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SOLR_URL",
"Value": { "Ref" : "SolrUrl"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SETTINGS__SOLR__URL",
"Value": { "Ref" : "SolrUrl"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "FEDORA_URL",
"Value": { "Ref" : "FcrepoUrl"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "DISABLE_REDIS_CLUSTER",
"Value": "true"
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "REDIS_HOST",
"Value": { "Ref" : "RedisHost"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "REDIS_PORT",
"Value": { "Ref" : "RedisPort"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SETTINGS__ZOOKEEPER__CONNECTION_STR",
"Value": { "Ref" : "ZookeeperHosts"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SETTINGS__MULTITENANCY__DEFAULT_HOST",
"Value": { "Fn::Join": [ ".", [ "%{tenant}", { "Ref": "StackName" }, { "Ref": "HostedZoneName" } ] ] }
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SETTINGS__MULTITENANCY__ADMIN_HOST",
"Value": { "Fn::Join": [ ".", [ { "Ref": "StackName" }, { "Ref": "HostedZoneName" } ] ] }
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "RDS_DB_NAME",
"Value": { "Ref" : "RDSDatabaseName"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "RDS_USERNAME",
"Value": { "Ref" : "RDSUsername"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "RDS_PASSWORD",
"Value": { "Ref" : "RDSPassword"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "RDS_HOSTNAME",
"Value": { "Ref" : "RDSHostname"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "RDS_PORT",
"Value": { "Ref" : "RDSPort"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SETTINGS__S3__UPLOAD_BUCKET",
"Value": { "Ref" : "UploadBucket"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "HONEYBADGER_API_KEY",
"Value": { "Ref" : "HoneybadgerApiKey"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "LOGZIO_KEY",
"Value": { "Ref" : "LogzioKey"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "AWS_REGION",
"Value": { "Ref" : "AWS::Region"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SETTINGS__ACTIVE_JOB__QUEUE_ADAPTER",
"Value": "better_active_elastic_job"
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SETTINGS__ACTIVE_JOB_QUEUE__URL",
"Value": { "Ref" : "DefaultQueue"}
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SETTINGS__WORKER",
"Value": "true"
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SETTINGS__SOLR__COLLECTION_OPTIONS__REPLICATION_FACTOR",
"Value": "3"
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "SETTINGS__SOLR__COLLECTION_OPTIONS__RULE",
"Value": "shard:*,replica:<2,cores:<5~"
},
{
"Namespace": "aws:elasticbeanstalk:application:environment",
"OptionName": "JAVA_TOOL_OPTIONS",
"Value": "-Xmx128m"
},
{
"Namespace": "aws:elasticbeanstalk:sqsd",
"OptionName": "WorkerQueueURL",
"Value": { "Ref" : "DefaultQueue"}
},
{
"Namespace": "aws:elasticbeanstalk:sqsd",
"OptionName": "HttpConnections",
"Value": "15"
}
]
}
},
"HyboxWorkersConfigurationTemplate" : {
"Type" : "AWS::ElasticBeanstalk::ConfigurationTemplate",
"Properties" : {
"ApplicationName" : { "Ref" : "ApplicationName"},
"Description" : "Hybox configuration template",
"OptionSettings" : [
{
"Namespace" : "aws:autoscaling:launchconfiguration",
"OptionName" : "InstanceType",
"Value" : { "Ref" : "InstanceType"}
},
{
"Namespace" : "aws:ec2:vpc",
"OptionName" : "Subnets",
"Value" : { "Fn::Join" : [",", { "Ref" : "PrivateSubnets" }] }
},
{
"Namespace" : "aws:autoscaling:launchconfiguration",
"OptionName" : "EC2KeyName",
"Value" : { "Ref" : "KeyName" }
},
{
"Namespace" : "aws:autoscaling:launchconfiguration",
"OptionName" : "SSHSourceRestriction",
"Value" : "tcp, 22, 22, 10.0.0.0/16"
},
{
"Namespace" : "aws:autoscaling:launchconfiguration",
"OptionName" : "SecurityGroups",
"Value" : { "Fn::Join": [",", { "Ref" : "SecurityGroups" }] }
},
{
"Namespace" : "aws:autoscaling:launchconfiguration",
"OptionName" : "IamInstanceProfile",
"Value" : { "Ref" : "IamInstanceProfile" }
},
{
"Namespace": "aws:autoscaling:asg",
"OptionName": "MinSize",
"Value": { "Ref" : "MinSize" }
},
{
"Namespace": "aws:autoscaling:asg",
"OptionName": "MaxSize",
"Value": { "Ref" : "MaxSize" }
},
{
"Namespace": "aws:elasticbeanstalk:environment",
"OptionName": "EnvironmentType",
"Value": "LoadBalanced"
},
{
"Namespace": "aws:elasticbeanstalk:command",
"OptionName": "DeploymentPolicy",
"Value": "Immutable"
},
{
"Namespace" : "aws:autoscaling:trigger",
"OptionName" : "LowerThreshold",
"Value" : "30"
},
{
"Namespace" : "aws:autoscaling:trigger",
"OptionName" : "MeasureName",
"Value" : "CPUUtilization"
},
{
"Namespace" : "aws:autoscaling:trigger",
"OptionName" : "Statistic",
"Value" : "Maximum"
},
{
"Namespace" : "aws:autoscaling:trigger",
"OptionName" : "Unit",
"Value" : "Percent"
},
{
"Namespace" : "aws:autoscaling:trigger",
"OptionName" : "UpperThreshold",
"Value" : "85"
},
{
"Namespace": "aws:autoscaling:updatepolicy:rollingupdate",
"OptionName": "RollingUpdateEnabled",
"Value": "true"
},
{
"Namespace": "aws:autoscaling:updatepolicy:rollingupdate",
"OptionName": "RollingUpdateType",
"Value": "Health"
},
{
"Namespace": "aws:elasticbeanstalk:healthreporting:system",
"OptionName": "SystemType",
"Value": { "Ref" : "HealthReportingSystemType" }
},
{
"Namespace": "aws:elasticbeanstalk:application",
"OptionName": "Application Healthcheck URL",
"Value": "/is_it_working"
},
{
"Namespace": "aws:elasticbeanstalk:environment",
"OptionName": "ServiceRole",
"Value": "aws-elasticbeanstalk-service-role"
},
{
"Namespace": "aws:elasticbeanstalk:sns:topics",
"OptionName": "Notification Topic ARN",
"Value": { "Ref" : "BeanstalkSNSTopic"}
},
{
"Namespace": "aws:elasticbeanstalk:managedactions:platformupdate",
"OptionName": "UpdateLevel",
"Value": "minor"
},
{
"Namespace": "aws:elasticbeanstalk:managedactions:platformupdate",
"OptionName": "InstanceRefreshEnabled",
"Value": "true"
},
{
"Namespace": "aws:elasticbeanstalk:managedactions",
"OptionName": "ManagedActionsEnabled",
"Value": "true"
},
{
"Namespace": "aws:elasticbeanstalk:managedactions",
"OptionName": "PreferredStartTime",
"Value": "Sun:00:00"
}
],
"SolutionStackName" : "64bit Amazon Linux 2016.09 v2.3.0 running Ruby 2.3 (Puma)"
}
}
},
"Outputs": {
"EnvironmentName": {
"Value" : { "Ref" : "WorkerEnvironment" }
}
}
}