As the first step of this workshop, we will host the web application (front-end) with S3 Static website hosting:


fcajdmswebstore
In this workshop, we select Account Regional namespace (recommended) so that the bucket name only needs to be unique within your AWS account and Region, instead of globally unique. Amazon S3 automatically appends a suffix containing the account ID and Region to the bucket name, so you can use the name fcajdmswebstore without worrying about conflicts with other users. Be sure to note down the full bucket name (including the suffix) after it is created, because we will use it again in later steps.
If you select Global namespace, the bucket name must be globally unique. If the name fcajdmswebstore is already taken, add a suffix, for example: fcajdmswebstore-<your-name>.




index.html for Index documentindex.html for Error document
The web application is a Single Page Application. Paths such as /document or /profile are handled by the application; they are not files on S3. Setting the Error document to index.html lets you reload the page at these paths without a 404 error.



{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKET_NAME/*"
}
]
}
BUCKET_NAME with the name of your bucket, then click the Save changes button
npm run build
aws s3 cp dist s3://BUCKET_NAME --recursive

BUCKET_NAME with the name of your bucketnpm run build command creates the dist folder that contains the built application. The application uses the amplify_outputs.json file created in workshop 134 to connect to Amazon Cognito and S3, so you do not need to run npx ampx sandbox again.If the upload fails, configure the access key ID, secret access key, region ap-southeast-1 and output format with the aws configure command
The result after uploading:


We have not created the API yet, so you will see errors in the browser Console when the application gets the document list. This is expected; we will create the API in the next section.
You have finished hosting your website on S3. In the next section, we will update the Lambda function of workshop 133 and create API Gateway.