-
Notifications
You must be signed in to change notification settings - Fork 937
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2438 from biswanathmukherjee/biswanathmukherjee-f…
…eature-r53-alb-s3 New Serverless Pattern - Route53-ALB-S3 (hosting a private website)
- Loading branch information
Showing
6 changed files
with
657 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Internal static website hosting using Amazon Route53, Application Load Balancer and Amazon S3 | ||
|
||
This pattern deploys a framework to host an internal static website on Amazon S3 bucket that can only be accessed from private network. | ||
|
||
Learn more about this pattern at Serverless Land Patterns: [https://serverlessland.com/patterns/route53-alb-s3](https://serverlessland.com/patterns/route53-alb-s3) | ||
|
||
**Important:** this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example. | ||
|
||
## Requirements | ||
|
||
* [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources. | ||
* [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured | ||
* [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) | ||
* [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed | ||
|
||
## Deployment Instructions | ||
|
||
1. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file: | ||
``` | ||
sam deploy --guided | ||
``` | ||
2. During the prompts: | ||
* Enter a stack name | ||
* Enter the desired AWS Region e.g. us-east-1 | ||
* Enter PrivateWebsiteDomainName e.g. hello-world.example.com | ||
* Allow SAM CLI to create IAM roles with the required permissions | ||
* Leave all other options to default values | ||
Once you have run `sam deploy --guided` mode once and saved arguments to a configuration file (samconfig.toml), you can use `sam deploy` in future to use these defaults. | ||
3. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for testing. | ||
4. From the command line, run the below command to upload the `index.html` to the S3 bucket. Replace `{WebsiteBucket}` with the corresponding output value of the `sam deploy` command. | ||
``` | ||
aws s3 cp index.html s3://{WebsiteBucket} | ||
``` | ||
## How it works | ||
Please refer to the architecture diagram below: | ||
![End to End Architecture](architecture.png) | ||
This template deploys a Route53 hosted zone, an Application Load Balancer (ALB), a VPC Endpoint and a S3 bucket. The private website URL will be exposed via the Route 53 private hosted zone. This URL is accessible from within the VPC. | ||
## Testing | ||
1. [Create a CloudShell VPC environment](https://docs.aws.amazon.com/cloudshell/latest/userguide/creating-vpc-environment.html). Enter the following values: | ||
* Name - enter your preferred environment name. | ||
* VPC - `VPCId` from the `sam deploy` output. | ||
* Subnet - Select any of the two available subnets under the above VPC. | ||
* Security - `ALBSecurityGroup` from the `sam deploy` output. | ||
2. From the CloudShell command prompt run the following command to access your private website. Replace `{PrivateWebsiteUrl}` with the corresponding output value of the `sam deploy` command: | ||
``` | ||
curl -k -L {PrivateWebsiteUrl} | ||
``` | ||
- The `curl` command makes an HTTP GET request to the deployed private website. | ||
- `-k` option allows curl to ignore that the certificate is issued by a private certificate authority and proceed with making the invocation. | ||
- `-L` option tells curl to follow any HTTP redirects that the server sends. If the server responds with a 3xx HTTP status code and provides a new URL, curl will automatically issue a new request to the new URL. | ||
3. You can also test by spinning up an EC2 instance within the same VPC or from another location that has private connectivity to the VPC. However, if you try to access the URL from outside network, it will not be reachable. | ||
## Cleanup | ||
1. Delete the contents of the S3 bucket. Make sure to use the correct bucket name. | ||
```bash | ||
aws s3 rm s3://{WebsiteBucket} --recursive | ||
``` | ||
2. Delete the CloudShell environment created in the VPC. | ||
3. Delete the stack | ||
```bash | ||
sam delete | ||
``` | ||
---- | ||
Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: MIT-0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"title": "Internal static website hosting using Amazon Route53, ALB and Amazon S3", | ||
"description": "This pattern hosts an internal static website on an Amazon S3 bucket that can only be accessed from private network.", | ||
"language": "YAML", | ||
"level": "200", | ||
"framework": "SAM", | ||
"introBox": { | ||
"headline": "How it works", | ||
"text": [ | ||
"This template deploys a Route53 hosted zone, an Application Load Balancer (ALB), a VPC Endpoint and a S3 bucket.", | ||
"The private website URL will be exposed via the Route 53 private hosted zone. This URL is accessible from within the VPC." | ||
] | ||
}, | ||
"gitHub": { | ||
"template": { | ||
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/route53-alb-s3", | ||
"templateURL": "serverless-patterns/route53-alb-s3", | ||
"projectFolder": "route53-alb-s3", | ||
"templateFile": "template.yaml" | ||
} | ||
}, | ||
"resources": { | ||
"bullets": [ | ||
{ | ||
"text": "Hosting Internal HTTPS Static Websites with ALB, S3, and PrivateLink", | ||
"link": "https://aws.amazon.com/blogs/networking-and-content-delivery/hosting-internal-https-static-websites-with-alb-s3-and-privatelink/" | ||
}, | ||
{ | ||
"text": "AWS PrivateLink for Amazon S3", | ||
"link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/privatelink-interface-endpoints.html" | ||
} | ||
] | ||
}, | ||
"deploy": { | ||
"text": [ | ||
"sam build", | ||
"sam deploy --guided" | ||
] | ||
}, | ||
"testing": { | ||
"text": [ | ||
"See the GitHub repo for detailed testing instructions." | ||
] | ||
}, | ||
"cleanup": { | ||
"text": [ | ||
"Delete the content of the S3 bucket: <code>aws s3 rm s3://{WebsiteBucket} --recursive</code>", | ||
"Delete the stack: <code>sam delete</code>.", | ||
"Delete the newly created CloudShell environment." | ||
] | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Biswanath Mukherjee", | ||
"image": "https://d1rwvjey2iif32.cloudfront.net", | ||
"bio": "I am a Sr. Solutions Architect working at AWS India.", | ||
"linkedin": "biswanathmukherjee" | ||
}, | ||
{ | ||
"name": "Rakshith Rao", | ||
"image": "https://rao.sh/assets/img/profile_pic.png", | ||
"bio": "I am a Senior Solutions Architect at AWS and help our strategic customers build and operate their key workloads on AWS.", | ||
"linkedin": "rakshithrao" | ||
} | ||
] | ||
} |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Sample Website</title> | ||
<style> | ||
body { | ||
color: #ffffff; | ||
background-color: #0188cc; | ||
font-family: Arial, sans-serif; | ||
font-size: 14px; | ||
} | ||
|
||
h1 { | ||
font-size: 500%; | ||
font-weight: normal; | ||
margin-bottom: 0; | ||
} | ||
|
||
h2 { | ||
font-size: 200%; | ||
font-weight: normal; | ||
margin-bottom: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div align="center"> | ||
<h1>Hello World!</h1> | ||
</div> | ||
</body> | ||
</html> | ||
|
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
"title": "Internal static website hosting using Amazon Route53, ALB and Amazon S3", | ||
"description": "This pattern hosts an internal static website on an Amazon S3 bucket that can only be accessed from private network.", | ||
"language": "YAML", | ||
"level": "200", | ||
"framework": "SAM", | ||
"introBox": { | ||
"headline": "How it works", | ||
"text": [ | ||
"This template deploys a Route53 hosted zone, an Application Load Balancer (ALB), a VPC Endpoint and a S3 bucket.", | ||
"The private website URL will be exposed via the Route 53 private hosted zone. This URL is accessible from within the VPC." | ||
] | ||
}, | ||
"gitHub": { | ||
"template": { | ||
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/route53-alb-s3", | ||
"templateURL": "serverless-patterns/route53-alb-s3", | ||
"projectFolder": "route53-alb-s3", | ||
"templateFile": "template.yaml" | ||
} | ||
}, | ||
"resources": { | ||
"bullets": [ | ||
{ | ||
"text": "Hosting Internal HTTPS Static Websites with ALB, S3, and PrivateLink", | ||
"link": "https://aws.amazon.com/blogs/networking-and-content-delivery/hosting-internal-https-static-websites-with-alb-s3-and-privatelink/" | ||
}, | ||
{ | ||
"text": "AWS PrivateLink for Amazon S3", | ||
"link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/privatelink-interface-endpoints.html" | ||
} | ||
] | ||
}, | ||
"deploy": { | ||
"text": [ | ||
"sam build", | ||
"sam deploy --guided" | ||
] | ||
}, | ||
"testing": { | ||
"text": [ | ||
"See the GitHub repo for detailed testing instructions." | ||
] | ||
}, | ||
"cleanup": { | ||
"text": [ | ||
"Delete the content of the S3 bucket: <code>aws s3 rm s3://{WebsiteBucket} --recursive</code>", | ||
"Delete the stack: <code>sam delete</code>.", | ||
"Delete the newly created CloudShell environment." | ||
] | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Biswanath Mukherjee", | ||
"image": "https://d1rwvjey2iif32.cloudfront.net", | ||
"bio": "I am a Sr. Solutions Architect working at AWS India.", | ||
"linkedin": "biswanathmukherjee" | ||
}, | ||
{ | ||
"name": "Rakshith Rao", | ||
"image": "https://rao.sh/assets/img/profile_pic.png", | ||
"bio": "I am a Senior Solutions Architect at AWS and help our strategic customers build and operate their key workloads on AWS.", | ||
"linkedin": "rakshithrao" | ||
} | ||
], | ||
"patternArch": { | ||
"icon1": { | ||
"x": 20, | ||
"y": 50, | ||
"service": "route53", | ||
"label": "Route 53" | ||
}, | ||
"icon2": { | ||
"x": 50, | ||
"y": 50, | ||
"service": "alb", | ||
"label": "Application Load Balancer" | ||
}, | ||
"icon3": { | ||
"x": 80, | ||
"y": 50, | ||
"service": "s3", | ||
"label": "S3 bucket" | ||
}, | ||
"line1": { | ||
"from": "icon1", | ||
"to": "icon2", | ||
"label": "" | ||
}, | ||
"line2": { | ||
"from": "icon2", | ||
"to": "icon3", | ||
"label": "" | ||
} | ||
} | ||
} |
Oops, something went wrong.