A useful walkthrough is also available on docs.aws.amazon.com.
- Open the AWS console and choose s3 link
- Create a new bucket, naming it exactly as your domain name e.g.
mydomain.com
- Open the Permissions settings and click "Edit bucket policy", setting the value to a policy as follows (remember to swap in your bucket name):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::mydomain.com/*"
}
]
}
- Set the "Static Website Hosting" option for this bucket to "Enable website hosting", setting the Index Document to
index.html
(or the index document of your choice) - Create a new bucket, nameing it exactly as the first bucket, but with
www.
preceding the name e.g. `www.mydomain.com - Set the "Static Website Hosting" option for this bucket to "Redirect all requests to another host name and set the redirection destination to your domain name e.g.
mydomain.com
- Upload your site's files to the first bucket (without the
www
), or simply upload a dummyindex.html
file. Visit the bucket's endpoint (you can find it under the "Static Website Hosting" section for the bucket. The site's content should now be accessible over the public web.
- Go to AWS Route53 in the AWS console link
- Create a new Hosted zone for your domain name
- Create a record set for the naked domain and the www. alias, pointing at the respective S3 buckets
- Create record sets as appropriate depending on your existing DNS setup
- Set your domain's DNS Servers to be the ones provided by AWS (find them on the "Hosted Zone" entry you just created
- Check the domain is pointing properly to the s3 bucket by visiting the URL in a browser. You may need to use dnschecker.org, the
dig
command line tool, clear your caches, or even use a VPN to see that the updates have taken effect.
- Go to AWS IAM console link
- Create new IAM user
- Take a note of the Access Key ID and Secret Access Key
- Attach a policy to the user, selecting
AmazonS3FullAccess
(you could narrow down the policy to allow access to your specific buckets only)
- Go to Codeship and create a new project. Link your Github repo as normal.
- Save the project with no testing pipeline configured (unless you want to run tests, of course)
- Click "Project Settings", then "Deployment".
- Set up a new Deployment Pipeline for the
master
branch and choose Amazon S3 as the deployment method - Fill in the AWS access key ID and secret access key fields with the IAM user's keys from the previous section. Select the same region as your buckets are in, set the S3 bucket name (e.g.
mydomain.com
), set the local path to./
and set the ACL according to the policy you attached to the IAM user (e.g.bucket-owner-full-control
- Attempt a deploy and see if it worked!
You just saved my life. Was struggling with this local path for hours. I've tried
/
and Codeship uploaded the whole VM to my S3 bucket (more than 3gb). Thanks :)