Comments: Deploy to S3
Link to chapter - http://serverless-stack.com/chapters/deploy-to-s3.html
When I run this command $ aws s3 sync build/ s3://gajen-notes-app-client, I get an error: Invalid endpoint: https://s3.region=us-east-1.amazonaws.com.... Any feedback on this?
@jayair I was able to resolve the issue above, however, when I opened the webpage and tried to log in I get an error message TypeError: re is not a function. Am I missing anything?
@riogaj89 does the login on your local work fine?
@jayair Yes it worked fine when deployed them on my local
That's really strange. Can I see the full error as it shows in the console?
@jayair just wondering, how secure is running this command? Would anyone - and I mean anyone be able to deploy to an S3 bucket if they know what's the bucket's name?
@ryanjcruz In this case they need your AWS credentials to upload it. So as long as you are not giving those out, you should be fine.
This guide is incredible, thanks for all the hard work!
I'm having an issue with the production build deployed to S3. Everything works fine locally and deployment isn't an issue, but when I go to my S3 URL to load the application I get the following error in console:
Uncaught TypeError: Cannot read property 'call' of undefined at t (main.a20f4176.js:1)
Based on the the issue link below, I assume its something to do with webpack. Any chance you have an idea of how to fix it? Haven't been able to figure it out myself. https://github.com/webpack/webpack/issues/959
I've incorporated a couple additional things to your guide: redux, react-redux, react-router-redux, redux-thunk, redux form and some babel/eslint stuff. Link to my test repository below, would really appreciate any help or thoughts. https://github.com/manubhat90/serverless-test
Once I attempted the aws s3 sync command here, I realised nothing was being written to my s3 bucket.
After a little reading I realied that my admin IAM user didn't have PUT access to that bucket, so I amended the bucket policy to the version I've provided below.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadForGetBucketObjects",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::notes-app-client-XXX/*"
},
{
"Sid": "PublicWriteForPutBucketObjects",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::YYYYYYYY:user/admin"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::notes-app-client-XXX/*"
}
]
}
Hopefully this helps someone out in the same situation.
Otherwise an absolutely smashing tutorial here guys. Amazingly thorough and I've learned loads in just a few short hours.
Cheers.
@biznuge Thanks for the kind words!
And thanks for reporting back. I'm sure it'll help some folks.
when trying to sync I received this message
fatal error: Could not connect to the endpoint URL: "https://s3.Frankfurt.amazon
aws.com/notes-app-client-my1test?prefix=&encoding-type=url"
a couple of thing I don't understand:
- what is this
?prefix=&encoding-type=url - why
s3.Frankfurt.amazonwhile up to now all regions where in the formeu-central-1? As a matter of fact I don't know where to start troubleshooting... if someone can help...
Ok, so maybe this can help somebody else. I created the notes-app-client folder inside the notes-app-server. I thought it should inherit the login credential but it didnt, so I simply reconfigure awscli with a new accesskey and secretId.
Don't forget to use --profile personal when uploading if you have profiles otherwise you will get
serverless-stack-demo-client git:(master) ✗ aws s3 sync build/ s3://notes-site-test
fatal error: An error occurred (InvalidRequest) when calling the ListObjects operation: You are attempting to operate on a bucket in a region that requires Signature Version 4. You can fix this issue by explicitly providing the correct region location using the --region argument, the AWS_DEFAULT_REGION environment variable, or the region variable in the AWS CLI configuration file. You can get the bucket's location by running "aws s3api get-bucket-location --bucket BUCKET".
Hi all, everything was working fine until I run npm run build... I'm using babili instead of uglify... The build is complete, but when I run the project I get this error: Uncaught (in promise) TypeError: h.a.config.credentials.getPromise is not a function
The line is return AWS.config.credentials.getPromise() in the getAwsCredentials() method, file awsLib.js
Does anybody have an idea of what's going wrong? Thanks in advance for helping.
@teseodemigod I'm not too familiar with your setup so I can't really help. But maybe somebody else can.
Hi,
I created my S3 bucket and went to do npm run build and I deployed the build/ file to the S3 bucket I created. In AWS the bucket shows up with all the files created in the build file, however when I go to the endpoint, the url where my app should be live, it shows up with the favicon icon but the screen is blank and the error i get from the console is: Failed to load resource: the server responded with a status of 404 (Not Found) main.f5cd3d98.js Failed to load resource: the server responded with a status of 404 (Not Found) main.0e9b8740.css Failed to load resource: the server responded with a status of 404 (Not Found) I understand that it is not reading the static files created during the build but I cannot seem to figure out how to fix this error? Hopefully someone can help me please? Thanks :)
@roxy-target Can you ensure the permissions for the S3 bucket are set right? The CORS and permission section in this chapter - https://serverless-stack.com/chapters/create-an-s3-bucket-for-file-uploads.html
@jayair I manage to get it working ! So thank you for the help :)
Should maybe add --delete to
aws s3 sync build/ s3://YOUR_S3_DEPLOY_BUCKET_NAME --delete
So that the changes don't accumulate.
Before I did that, earlier versions were buffered and the correct version was not always rendered.
I'm getting the following response, "npm ERR! missing script: build"
What can I do to address this?