ThoughtWorksStudios / eb_deployer

AWS Elastic Beanstalk blue-green deployment automation from ThoughtWorks Mingle Team
MIT License
400 stars 94 forks source link

mongodb #61

Closed claudeomusic closed 8 years ago

claudeomusic commented 8 years ago

would really appreciate suggestions on how to use eb_deployer with a mongodb setup? pretty new to deploying on elastic beanstalk

xli commented 8 years ago

@claudeomusic, you can use aws cloudformation to prevision mongodb, then pass mongodb url to your application, example:

resources:
  template: config/aws_resources.json
  capabilities:
    - CAPABILITY_IAM
  inputs:
    Namespace: <%= environment %>
    MongoPassword: <%= db_password %>
  outputs:
    SecurityGroupName:
      namespace: aws:autoscaling:launchconfiguration
      option_name: SecurityGroups
    MongoConnectionUrl:
      namespace: aws:elasticbeanstalk:application:environment
      option_name: MONGO_URL

Then, in your application which is deployed by ElasticBeanstalk, read environment variable MONGO_URL to access your mongodb.

For security, in above example, there is output named "SecurityGroupName", which is the access group to access EC2 instance that is running mongodb server. The output of "SecurityGroupName" is added to your ElasticBeanstalk application configuration as "SecurityGroups" which will be assigned to your EC2 instances by ElasticBeanstalk

claudeomusic commented 8 years ago

thanks for the suggestions, will definitely give it a shot!