Category: English

Date:

In this tutorial, I'll be guiding you how to store your static HTML files on Bitbucket private repo and publish them on Amazon S3. You will be able to deploy your changes with git push and the files will be automatically deployed to S3.

We have three parties: AWS S3, dploy.io, Bitbucket. dploy.io is a deployment service with 1 repository access in the free plan. When you git push to your bitbucket git repository, a webhook informs dploy.io to pull the content and publish it to S3. dploy.io has read access to git repository and read/write access to S3.

Let's start building. Instructions might be missing since dploy.io gives only 1 repository and user interfaces change once you create your repository. So I could not test a second one to give you more precise instructions.

We will use mysite.com for demonstration. You may use your domain with www in front as well.

AWS S3 Setup

  • Create a new s3 bucket on AWS: mysite.com
  • Create a new user mysitecom with IAM credentials. Download credentials.cv.
  • Grant access to S3 repo mysite.com
  • At mysite.com bucket properties, Edit bucket policy, Paste this:

    {
        "Version": "2012-10-17",
        "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effct": "Allow",
            "Pricipal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::mysite.com/*"
        }
        ]
    }
    
  • In the Static Website Hosting section of the properties, choose "Enable website hosting".

  • Set Index document: index.html
  • For using your custom domain, follow this link.

Bitbucket Setup

  • Create a new repo on bitbucket: mysite.com
  • git clone the repo to your local and push your initial commit: index.html.

Dploy.io Setup

  • Integrations->Amazon->Connect->Account Name, Access Key, Secret Key, Region
  • Repositories->Connect a repository->Generic/custom git repository.
  • Use address: git@bitbucket.org:gituser/mysite.com.git
  • Choose master branch, and do configurations.
  • Repositories -> mysite.com -> General -> Public Key for Submodules -> Copy the public key or there should be a download link, download the file and copy the content of the downloaded file (deployment key).
  • Repositories -> mysite.com -> Settings -> Web Hooks & Badges -> Copy the given URL (hook URL)

Bitbucket Integration

  • Hooks section -> Select A Hook -> POST -> Add Hook and Paste the given Hook URL.
  • Deployment Keys -> Add Key -> Paste deployment key from dploy.io, give a label: gituser.dploy.io.

Testing

  • Now you should be able to see your S3 site on http://mysite.com.s3-website-eu-west-1.amazonaws.com/

Potential Problems

As of now, deployment performs copy operation on AWS S3, not a sync operation. So if you deleted any files locally, they won't be deleted on the remote (S3). You may have to delete it manually.


Share: FacebookGoogle+Email


comments powered by Disqus