March 21, 2015

Setup Ghost Blog with Postgresql / AWS SES

[amazon-ses-180x180](http://i2.wp.com/www.geoffcorey.com/wp-content/uploads/2015/03/amazon-ses-180x180.png) Configuring Ghost Blog for Postgresql and Amazon SES for mail took a lot longer then it should.   Ghost is a blogging platform written in Node.js. Docs are a bit underwhelming for self hosting and I am not sure if that is on purpose to sign up for their hosted solution or nobody seems to care. After searching a lot of pages that were not on Ghost’s site I finally had a solution that works.   I hope this helps a lot of other folks not waste a lot of time hosting their own solution. # Setup Ghost Blog with Postgresql / AWS SES On Amazon Web Service (AWS) setup a new Identy Access Management (IAM) user and download the credentials for AWS access keys. Add a policy for that user to be able to use Email Sending Service (SES). Go to SES and create a verified email used to send email. In this example I am using no-reply@mycompany.com. Environment variables:
export APP_URL=http://blog.mycompany.com
export VERIFIED_FROM_EMAIL=no-reply@mycompany.com
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_KEY=
export DB_URL=postgres://<username>:<password>@<host>:<port>/<dbname>
Here is the snippet of the config.js that will allow you to use Postgresql and Amazon SES.
var config

config = {
    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production:
    {
    url: process.env.APP_URL,
    mail:
    {
      transport: 'SES',
      fromaddress: process.env.VERIFED_FROM_EMAIL,
      options:
      {
        AWSAccessKeyID: process.env.AWS_ACCESS_KEY_ID,
        AWSSecretKey: process.env.AWS_SECRET_KEY
      },
    },
    database:
    {
      client: 'postgres',
      connection: process.env.DB_URL,
      debug: false
    },
    server:
    {
      host: '0.0.0.0',
      port: process.env.PORT
    }
  }
};

// Export config
module.exports = config;