- Buy a domain and create an AWS account
- TODO: host the domain in route53
Go to AWS and into S3
Create an S3 bucket with the following settings:
- Set "Block all public access" to "Off"
- Under "properties", enable "Static website hosting"
- Then under "Index document", in the static website settings, write "index.html"
Remember to go into "permissions" and add
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<name-of-your-bucket>/*"
}
]
}
Go to AWS and into Cloudfront
Create a distribution
- Under "Origin domain", select your s3 bucket
- Choose "Use website endpoint"
- You can select "Do not enable security protections"
Once the distribution has been created, go to settings and edit it
- Under "Alternate domain name (CNAME) - optional" set your domain that you bought
- Under "Default root object - optional" write "index.html"
Take note of the Distribution Id!
Go to AWS and into IAM
Got to users and create a user
Create a policy for the user when asked and copy this one
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::<name-of-your-bucket>"
]
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::<name-of-your-bucket>/*"
]
},
{
"Effect": "Allow",
"Action": [
"cloudfront:CreateInvalidation"
],
"Resource": "*"
}
]
}
Then, once the user is created, go to the user and create an access key:
- In "Access key best practices & alternatives" select "Application running outside AWS"
- In "Set description tag" write "github-action"
- In "Retrieve access keys" copy both the access key and the secret to a file for the time being
Go to your github repo -> settings -> secrets and variables -> actions
Now take the
- s3 bucket name
- aws region you created your bucket
- distribution id
- access key
- access secret
and create a secret for each one named:
- S3_BUCKET
- AWS_REGION
- CLOUDFRONT_DISTRIBUTION_ID
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
respectively.