Giter Club home page Giter Club logo

s3fs-on-aws-beanstalk's Introduction

s3fs-on-aws-beanstalk

This is a simple example of how to configure and mount S3FS buckets into your Elastic Beanstalk application. It was built for a PHP app like Drupal or Wordpress that needs a local folder to persist across load balanced instances.

Features

  • Should be able to drop into any PHP app to enable S3FS folders.
  • Downloads, compiles and installs everything using ebextensions/*.config files. No custom AMI required.
  • Uses Elastic Beanstalk's deploy hooks to take actions at the appropriate times during deploy cycle.

How it works

It reads the local folder to bucket mappings from your etc/s3fs.json file and places the commands needed into the following files:

/opt/elasticbeanstalk/hooks/appdeploy/pre/11_unmount_s3fs.sh /opt/elasticbeanstalk/hooks/appdeploy/enact/02_s3fs.sh

The 11_unmount_s3fs.sh file is called right before the script that fixes the ownership of all your existing files. If you don't unmount the s3fs buckets first, then the chown commands take so long that the application fails to launch. It is also very important that this script runs before the enact/09clean.sh script is run because it will remove all the files from your bucket if the mounts are still connected.

Then the 02_s3fs.sh script should be called right after your application has "flipped" into place. Moving the new version from /var/app/ondeck to /var/app/current.

The correct order to a deployment is:

  1. Unpack your new version and make sure the environment is in place.
  2. Unmount existing S3FS folders.
  3. Move your new version into place.
  4. Mount the S3FS folders into the new version.
  5. Delete the old version.

Directions

  1. Check out the sample app into a local folder.
  2. Create a PHP Elastic Beanstalk Application.
  3. Put your S3 credentials into the Environment's container.
  4. Add your bucket into the etc/s3fs.json file.
  5. Use git aws.push to push the application live.
  6. Visit your application's domain to see if the buckets were mounted.

Notes

Uses s3fs version 1.61. Version 1.63 did not allow for non-root write permissions. In the typical application, the apache user needs to be able to write files (like images) to the S3 bucket.

Tested with the "32bit Amazon Linux running PHP 5.3" AMI.

s3fs-on-aws-beanstalk's People

Contributors

nathanlenz avatar

Watchers

James Cloos avatar Adam Robertson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.