Created
May 8, 2018 05:35
-
-
Save monkut/aa011550d596088ef577ad6d82722a20 to your computer and use it in GitHub Desktop.
Revisions
-
monkut created this gist
May 8, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ ## Build your sphinx document > Assumes you already have a [sphinx](http://www.sphinx-doc.org/en/master/) project installed and a project created ``` make html ``` > By default this command will build documentation to `_build/html` ## Setup IP restricted S3 Bucket (for use as internal website) This describes the procedure to setup an S3 bucket. > NOTE: This assumes you have the awscli installed In order to apply an IP restriction you need to set the `bucket policy`. 1. Confirm the current bucket policy: ``` aws s3api get-bucket-policy --bucket store-manager-spec ``` > If you don't have a bucket policy defined you will get an error: "... The bucket policy does not exist" 2. Define your policy document, create a file named `ip-restriced-bucket-policy.json` and update with the following: ``` { "Id": "IPLimitedAccessPolicy", "Version": "2012-10-17", "Statement": [ { "Sid": "AllowTrustedIPs", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::MY_BUCKET_NAME/*", "Condition": { "IpAddress": { "aws:SourceIp": [ "IP_TO_ALLOW/32" ] } } } ] } ``` 3. Set the bucket policy: ``` aws s3api put-bucket-policy --bucket MY_BUCKET_NAME --policy file://ip-restriced-bucket-policy.json ``` ## Send built documentation to s3 bucket From the `_build/html` directory run the following command to sync the content of the folder with the remote bucket: ``` aws s3 sync . s3://MY_BUCKET_NAME/ ``` ## Configure bucket as static website The following will configure the s3 bucket to operate as a website at: ``` aws s3 website s3://MY_BUCKET_NAME/ --index-document index.html ```