Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments: Deploy Again #70

Closed
jayair opened this issue Apr 10, 2017 · 24 comments

Comments

Projects
None yet
6 participants
@jayair
Copy link
Member

commented Apr 10, 2017

@jayair jayair added the Discussion label Apr 10, 2017

@geirman

This comment has been minimized.

Copy link

commented Apr 21, 2017

So for this section, I did something simple and pretty cool that I think would easily add value to this chapter. I added deploy scripts to the package.json. Here's what they look like...

"predeploy": "npm run build",
"deploy": "aws s3 sync build/ s3://YOUR_S3_DEPLOY_BUCKET_NAME",
"postdeploy": "aws cloudfront create-invalidation --distribution-id YOUR_CF_DISTRIBUTION_ID --paths '/*' && aws cloudfront create-invalidation --distribution-id YOUR_WWW_CF_DISTRIBUTION_ID --paths '/*'"

Now, I can update my files and simply...

$ npm run deploy
@jayair

This comment has been minimized.

Copy link
Member Author

commented Apr 21, 2017

@geirman right on! I'll remember to add this detail when I update things.

@jayair

This comment has been minimized.

Copy link
Member Author

commented Apr 30, 2017

@geirman added your suggestion to the chapter febd147

@PatrykTies

This comment has been minimized.

Copy link

commented May 5, 2017

It gives me error for CloudFront, Invalid invalidation paths
I found a tip here : https://kylewbanks.com/blog/invalidate-entire-cloudfront-distribution-from-command-line
THIS THROW ERROR:
aws cloudfront create-invalidation --distribution-id YOUR_CF_DISTRIBUTION_ID --paths '/*'

THIS IS WORKING: showing invalidations in AWS console but page dont update
aws cloudfront create-invalidation --distribution-id YOUR_CF_DISTRIBUTION_ID --paths '/*' (adding \ here before astrix )
I tried all combinations and only above give some response from AWS
Weird...any1 have a clue ?

{
    "Invalidation": {
        "Status": "InProgress",
        "InvalidationBatch": {
            "Paths": {
                "Items": [
                    "//*"   <========THIS LOOKS WEIRD TO ME
                ],
                "Quantity": 1
            },
            "CallerReference": "cli-1494008481-711394"
        },
        "Id": "I1HDDV6762VISK",
        "CreateTime": "2017-05-05T18:21:29.619Z"
    },
    "Location": "https://cloudfront.amazonaws.com/2017-03-25/distribution/E1NKEP
QSUUZHQW/invalidation/I1HDDV6762VISK"
}
@jayair

This comment has been minimized.

Copy link
Member Author

commented May 5, 2017

@PatrykTies that is weird. Which OS are you on btw?

@PatrykTies

This comment has been minimized.

Copy link

commented May 5, 2017

Win7 Pro 64bit SP1

@jayair

This comment has been minimized.

Copy link
Member Author

commented May 5, 2017

@PatrykTies Ah I'm not too familiar with the shell in Windows but maybe the escape \ works differently there?

@PatrykTies

This comment has been minimized.

Copy link

commented May 5, 2017

Let me google it out and investigate. Cheers

@PatrykTies

This comment has been minimized.

Copy link

commented May 5, 2017

Btw using npm script also gives the same error....but that get injected into win shell anyways...so

Also i am using gitbash for terminal commands

@PatrykTies

This comment has been minimized.

Copy link

commented May 5, 2017

Solved, for win7 I had to use /^* as --paths, instead of "/*"
Thanks for pointing the possible cause. All done
Now off me go to Jenkins and AWS codepipeline CI/CD for this tut

@jayair

This comment has been minimized.

Copy link
Member Author

commented May 6, 2017

@PatrykTies thanks for reporting back. I'm sure it'll help other folks.

Btw, let us know how your Jenkins setup works out, we are considering writing about that as well.

@ryanjcruz

This comment has been minimized.

Copy link
Contributor

commented May 16, 2017

I'm getting an error on postdeploy:
An error occurred (InvalidArgument) when calling the CreateInvalidation operation: Your request contains one or more invalid invalidation paths.
aws cloudfront create-invalidation --distribution-id CF_DISTRIBUTION_ID --paths '/*' && aws cloudfront create-invalidation --distribution-id WWW_CF_DISTRIBUTION_ID --paths '/*'

But when executed individually, they both seem to work
aws cloudfront create-invalidation --distribution-id CF_DISTRIBUTION_ID --paths '/*'
aws cloudfront create-invalidation --distribution-id WWW_CF_DISTRIBUTION_ID --paths '/*'

@jayair

This comment has been minimized.

Copy link
Member Author

commented May 16, 2017

@ryanjcruz Are you on Windows?

@ryanjcruz

This comment has been minimized.

Copy link
Contributor

commented May 17, 2017

@jayair yep windows 10, but using git bash to run the command

@jayair

This comment has been minimized.

Copy link
Member Author

commented May 17, 2017

@ryanjcruz I see. How do you combine two shell commands together?

@ryanjcruz

This comment has been minimized.

Copy link
Contributor

commented May 18, 2017

@jayair

This comment has been minimized.

Copy link
Member Author

commented May 18, 2017

@ryanjcruz

This comment has been minimized.

Copy link
Contributor

commented May 19, 2017

@jayair looks like it is, Maybe the syntax has some issues with non-unix like machine. I think the issue for windows is the && part as running them individually seems to go just ok.

Update - nah changing it to & still didn't work though.

Update 2 - hmmm running the command as is not part of npm run deploy seems to be working. Though the error seems to be on that part of the script running the postdeploy task

notes-app-client@0.1.0 postdeploy C:\Users\Ryan\Documents\Projects\notes-app-client
aws cloudfront create-invalidation --distribution-id E1EH1YYONEF1TY --paths '/' & aws cloudfront create-invalidation --distribution-id E3NKA80S86XILI --paths '/'

An error occurred (InvalidArgument) when calling the CreateInvalidation operation: Your request contains one or more invalid invalidation paths.

An error occurred (InvalidArgument) when calling the CreateInvalidation operation: Your request contains one or more invalid invalidation paths.

@ryanjcruz

This comment has been minimized.

Copy link
Contributor

commented May 27, 2017

@jayair finally figured it out on another project, for windows --paths '/*' should be just --paths /* for combined create-invalidation commands on 2 cloudfront distribution ids

@littleredshack

This comment has been minimized.

Copy link

commented Dec 13, 2017

Strange one. I have got all the way through the process and all working fine. But when I try to redeploy to S3 I get an error about my AWS key being invalid.

C:\Users\gstokes\Documents\Personal\Coding\Serverless\notes-app-frontend\notes-app-client>aws s3 sync build/ s3://gbs-notes-app-client
fatal error: An error occurred (InvalidAccessKeyId) when calling the ListObjects operation: The AWS Access Key Id you provided does not exist in our records.

I have re-run AWS configure just in case those got changed somehow. Still not working.

Anyone got any ideas?

@littleredshack

This comment has been minimized.

Copy link

commented Dec 13, 2017

I just went into IAM and then in the user that I had originally created I chose the option to create a new Access Key. I used that and it is working. No idea why the previous one suddenly stopped.

@drakeloud

This comment has been minimized.

Copy link

commented Feb 24, 2018

I'm not sure if anyone else has pointed this out in a different chapter, but I think that you should add the --delete flag when syncing your s3 bucket. So the full command would be this:

aws s3 sync build/ s3://YOUR_S3_DEPLOY_BUCKET_NAME --delete

This deletes the files that aren't in your local directory. When you run npm build, it creates unique ids for the static files, so simply syncing s3 gives you the old files, and adds the new ones. E.g. my app is 6MB and it was adding another 6MB every time I deploy.

@jayair

This comment has been minimized.

Copy link
Member Author

commented Feb 24, 2018

@drakeloud Good point. I'll add a note.

@jayair

This comment has been minimized.

Copy link
Member Author

commented May 9, 2018

@jayair jayair closed this May 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.