Image for post
Give the user the name serverless-admin with Programmatic access selected. Click Next: Permissions.
Switch to the Attach existing policies directly tab and select AdministratorAccess (for testing). In the future, make sure to scope the IAM permissions based on your level of access. As this is not a deep dive into IAM we will keep it simple. Then click Next: Review.
We need to copy the Access Key ID and the Secret Access Key for later use. So click Download .csv. Click Close.
now, download latest aws cli https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html
after it is installed run
./install awscli

replace credentials by yours
create now the bucket where the app is going to be hosted
after the bucket is created
In the Set properties tab, you can just hit next.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPublicReadAccess",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::example-bucket/*"
]
}
]
}
This gives users read access to your bucket. Go ahead and hit save.
Let’s open up our react-app project in a text editor and create a deployment script to make updating our live ReactJS application easier.
Open up your package.json file. Inside there is a section called scripts. We’re going to add a script called deploy which will use the AWS CLI to sync our build directory to our S3 bucket. Swap out example-bucket for your bucket name and copy/paste it into your package.json file using the image below as a guide.
aws s3 sync build/ s3://example-bucket --acl public-read

now to compile do it as usually as npm run build
and to deploy do npm run deploy
so, let's get now the public Endpoint in the S3 - PROPERTIES - STATIC WEB HOSTING
in this case the
Comments
Post a Comment