The React PWA Reference Storefront is pre-configured to deploy on Amazon Web Service S3 (AWS S3).
Before you deploy on AWS S3, you need the following tools and accounts:
An AWS account to deploy the website on the AWS S3 bucket. Ensure that you can use the AWS S3 bucket for hosting your storefront.
An AWS Identity and Access Management (IAM) profile.
The AWS CLI tool.
For more information about platform specific procedures, see the Amazon documentation.
Your AWS credentials are set up on CLI.
Open a new terminal, and type
React PWA Reference Storefront on Amazon S3 Bucket Example
Create an Amazon S3 bucket.
Log in to the AWS account.
Follow the guidelines for using the available access policy options and generate a policy with the following settings:
Ensure that your bucket policy sets the bucket and all objects in the bucket to public.
For the ARN (Amazon Resource Names), use the name of your bucket with
/*at the end to provide everyone access to all files.
Set up the bucket as static hosting.
In the bucket’s console, navigate to Properties > Static Website Hosting.
Select Use this bucket to host a website.
Fill the form and click Save.
Update the CORS (Cross-Origin Resource Sharing) configuration.
- Copy the following XML:
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> <AllowedOrigin>*</AllowedOrigin> <AllowedMethod>HEAD</AllowedMethod> <AllowedMethod>GET</AllowedMethod> <AllowedMethod>PUT</AllowedMethod> <AllowedMethod>POST</AllowedMethod> <AllowedMethod>DELETE</AllowedMethod> <ExposeHeader>ETag</ExposeHeader> <ExposeHeader>x-amz-meta-custom-header</ExposeHeader> <AllowedHeader>*</AllowedHeader> </CORSRule> </CORSConfiguration>
Navigate to Permissions > CORS configuration.
Paste the XML snippet, and modify the settings as required.
With this configuration, the storefront can perform cross-origin requests to any origin.
- Click Save:
Deploy your application
Update the bucket name in the
"deploy": "aws s3 sync build/ s3://bucket-name"
yarn run buildcommand.
yarn run deploycommand.
Configure the Amazon CloudFront following the instructions at Getting Started with CloudFront.
After completing the set up, you can access your website at the domain name.