Last active
October 20, 2019 16:19
-
-
Save deepak7093/7dde29ff02d69e2f5ca0ad0c86db1da7 to your computer and use it in GitHub Desktop.
Revisions
-
deepak7093 revised this gist
Oct 20, 2019 . 1 changed file with 18 additions and 0 deletions.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 @@ -70,6 +70,24 @@ Before deploy functions to lambda@edge, we have to meet some prerequisites as be ``` 4. Attach above created role to lambda function. 5. Update `EC2 public ip` inside `lambda_handler.py`. 6. IAM Role ``` { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "lambda.amazonaws.com", "edgelambda.amazonaws.com" ] }, "Action": "sts:AssumeRole" } ] } ``` ## Setup lambda@edge trigger -
deepak7093 revised this gist
Oct 20, 2019 . 1 changed file with 1 addition and 0 deletions.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 @@ -25,6 +25,7 @@ Before deploy functions to lambda@edge, we have to meet some prerequisites as be } ``` 3. Now upload `index.html` and `wordDoc.doc.html` to s3. 4. Update static website hosting base path to `index.html` ## Create cloudfront distrubution 1. Create cloudfront distrution with above create s3 as origin. keep other setting as default -
deepak7093 revised this gist
Oct 20, 2019 . 1 changed file with 1 addition and 1 deletion.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 @@ -79,7 +79,7 @@ Before deploy functions to lambda@edge, we have to meet some prerequisites as be ## Validate 1. Open in browser `<cloud_front_distrinution_url>/webPage.aspx` it should open page from EC2. 2. `<cloud_front_distrinution_url>/wordDoc.doc` it should open page from S3 bucket. 3. `<cloud_front_distrinution_url>/` it should get 503 Error -
deepak7093 revised this gist
Oct 20, 2019 . 1 changed file with 57 additions and 2 deletions.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 @@ -2,7 +2,7 @@ Before deploy functions to lambda@edge, we have to meet some prerequisites as below: 1. S3 bucket with public website hosting and set `index.html` as base path. 2. Cloudfront distribution to server content for lambda@edge. 3. Setup webserver on EC2 instance. 4. Create lambda function. 5. Setup lambda@edge trigger. 6. Validation. @@ -30,6 +30,61 @@ Before deploy functions to lambda@edge, we have to meet some prerequisites as be 1. Create cloudfront distrution with above create s3 as origin. keep other setting as default 2. Check by entering distrubution url if it returns s3 `index.html` page ## Setup webserver on EC2 instance 1. Create EC2 instance with ubuntu 18.04 and public ip. 2. Login to EC2 instance using public ip and private key. 3. Install nginx using below command ``` # sudo -i # apt-get update # apt-get install -y nginx # systemctl start nginx.service # systemctl enable nginx.service # touch /var/www/html/index.html # echo "Sample Page from EC2 nginx webserver" > /var/www/html/index.html ``` 4. Allow port `80` and `443` instance security group. ## Create lambda function 1. Create lambda function with runtime `python 3.7 `. 2. Update code from file `lambda_handler.py` 3. Create role as `lambda-edge` with below policy ``` { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents" ], "Resource": [ "arn:aws:logs:*:*:*" ] } ] } ``` 4. Attach above created role to lambda function. 5. Update `EC2 public ip` inside `lambda_handler.py`. ## Setup lambda@edge trigger 1. Publish new version of lambda. 2. On new publish version Add trigger --> Choose cloud front --> Deploy to Lambda@Edge --> select distribution --> choose event `viwer request` --> confirm ## Validate 1. Open in browser `<cloud_front_distrinution_url>/webPage.aspx` it should open page from EC2. 2. `<cloud_front_distrinution_url>/wordDoc.doc` it should open page from S3 bucket. 3. `<cloud_front_distrinution_url>/ it should get 503 Error -
deepak7093 revised this gist
Oct 20, 2019 . 1 changed file with 1 addition and 1 deletion.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 @@ -28,7 +28,7 @@ Before deploy functions to lambda@edge, we have to meet some prerequisites as be ## Create cloudfront distrubution 1. Create cloudfront distrution with above create s3 as origin. keep other setting as default 2. Check by entering distrubution url if it returns s3 `index.html` page ## -
deepak7093 revised this gist
Oct 20, 2019 . 1 changed file with 11 additions and 5 deletions.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 @@ -1,11 +1,11 @@ # Deploy Lambda@edge Before deploy functions to lambda@edge, we have to meet some prerequisites as below: 1. S3 bucket with public website hosting and set `index.html` as base path. 2. Cloudfront distribution to server content for lambda@edge. 3. EC2 instance with nginx and sample pages. 4. Create lambda function. 5. Setup lambda@edge trigger. 6. Validation. ## Create S3 Bucket with public website hosting 1. Create S3 bucket and add enable static website hosting. @@ -26,4 +26,10 @@ Before deploy functions to lambda@edge, we have to meet some prerequisites as be ``` 3. Now upload `index.html` and `wordDoc.doc.html` to s3. ## Create cloudfront distrubution 1. Create cloudfront distrution with above create s3 as origin. keep other setting as default 2. Check by entering distrubution url if it returns s3 index.html page ## -
deepak7093 revised this gist
Oct 20, 2019 . 1 changed file with 8 additions and 4 deletions.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 @@ -1,7 +1,11 @@ # Deploy Lambda@edge Before deploy functions to lambda@edge, we have to meet some prerequisites as below: 1. S3 bucket with public website hosting 2. Cloudfront distribution to server content for lambda@edge 3. EC2 instance with nginx and sample pages. 4. Create lambda function 5. Setup lambda@edge trigger 6. Validation ## Create S3 Bucket with public website hosting 1. Create S3 bucket and add enable static website hosting. -
deepak7093 revised this gist
Oct 20, 2019 . 1 changed file with 25 additions and 1 deletion.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 @@ -1 +1,25 @@ To deploy functions to lambda@edge, we need below prerequisites: 1. Cloudfront distribution 2. S3 bucket with public website hosting 3. EC2 instance with nginx and sample pages ## Create S3 Bucket with public website hosting 1. Create S3 bucket and add enable static website hosting. 2. Add below bucket policy ``` { "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::<bucket_name>/*" } ] } ``` 3. Now upload `index.html` and `wordDoc.doc.html` to s3. -
deepak7093 created this gist
Oct 20, 2019 .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 @@ #