Deploy to S3

From @jayair on Mon Apr 10 2017 01:09:09 GMT+0000 (UTC)

Link to chapter - http://serverless-stack.com/chapters/deploy-to-s3.html

Copied from original issue: https://github.com/AnomalyInnovations/serverless-stack-com/issues/63

From @riogaj89 on Wed Apr 26 2017 13:42:53 GMT+0000 (UTC)

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?

From @riogaj89 on Wed Apr 26 2017 15:29:50 GMT+0000 (UTC)

@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?

From @jayair on Wed Apr 26 2017 17:10:00 GMT+0000 (UTC)

@riogaj89 does the login on your local work fine?

From @riogaj89 on Wed Apr 26 2017 18:18:58 GMT+0000 (UTC)

@jayair Yes it worked fine when deployed them on my local

From @jayair on Wed Apr 26 2017 23:23:32 GMT+0000 (UTC)

That’s really strange. Can I see the full error as it shows in the console?

From @ryanjcruz on Sat May 20 2017 06:45:39 GMT+0000 (UTC)

@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?

From @jayair on Sat May 20 2017 18:44:05 GMT+0000 (UTC)

@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.

From @manubhat90 on Wed Aug 02 2017 21:26:12 GMT+0000 (UTC)

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.

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

From @biznuge on Tue Aug 22 2017 08:32:21 GMT+0000 (UTC)

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.

From @jayair on Tue Aug 22 2017 17:14:16 GMT+0000 (UTC)

@biznuge Thanks for the kind words!

And thanks for reporting back. I’m sure it’ll help some folks.

From @designpressure on Mon Sep 25 2017 08:04:00 GMT+0000 (UTC)

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.amazon while up to now all regions where in the form eu-central-1?
    As a matter of fact I don’t know where to start troubleshooting… if someone can help…

From @designpressure on Mon Sep 25 2017 08:24:55 GMT+0000 (UTC)

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.

From @QuantumInformation on Fri Oct 06 2017 15:29:23 GMT+0000 (UTC)

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".

From @teseodemigod on Sat Dec 02 2017 19:13:37 GMT+0000 (UTC)

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.

From @jayair on Sat Dec 02 2017 19:24:22 GMT+0000 (UTC)

@teseodemigod I’m not too familiar with your setup so I can’t really help. But maybe somebody else can.

From @roxy-target on Mon Dec 11 2017 14:35:42 GMT+0000 (UTC)

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 :slight_smile:

From @jayair on Tue Dec 12 2017 17:49:24 GMT+0000 (UTC)

@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

From @roxy-target on Wed Dec 13 2017 15:04:22 GMT+0000 (UTC)

@jayair I manage to get it working ! So thank you for the help :slight_smile:

From @jonasbarsten on Sat Jan 20 2018 18:10:54 GMT+0000 (UTC)

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.