Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

cloudfront remove cache after deploy S3

#!/usr/bin/env bash

BUCKET=mysite.com
SOURCE_DIR=dist/

export AWS_ACCESS_KEY_ID=xxxxxxxxxxx
export AWS_SECRET_ACCESS_KEY=xxxxxxxxx
export AWS_DEFAULT_REGION=eu-west-1


echo "Building production"
if npm run build:prod ; then
   echo "Build Successful"
else
  echo "exiting.."
  exit 1
fi


echo "Removing all files on bucket"
aws s3 rm s3://${BUCKET} --recursive


echo "Attempting to upload site .."
echo "Command:  aws s3  sync $SOURCE_DIR s3://$BUCKET/"
aws s3  sync ${SOURCE_DIR} s3://${BUCKET}/
echo "S3 Upload complete"

echo "Invalidating cloudfrond distribution to get fresh cache"
aws cloudfront create-invalidation --distribution-id=S11A16G5KZMEQD --paths / --profile=myawsprofile

echo "Deployment complete"  
Comment

PREVIOUS NEXT
Code Example
Shell :: task scheduler powershell closes immediately 
Shell :: push local file to remote forcefully 
Shell :: Termux comandos hack 
Shell :: deb http://la-mirrors.evowise.com/ubuntu/ disco-security multiverse 
Shell :: ubuntu string variable 
Shell :: get logs of local git branches 
Shell :: copy paste keys vim 
Shell :: linux privilege s 
Shell :: conda install packages from different channels 
Shell :: https://ubuntu.com/tutorials/install-and-configure-wordpress 
Shell :: make folder public digital ocean bucket 
Shell :: github clone mirror 
Shell :: Install Kubernetes Operator SDK 
Shell :: git push origin deatched hhead 
Shell :: set 
Shell :: maingit-branch--m-main-<BRANCH-git-fetch-origin-git-branch--u-origin/<BRANCH-<BRANCH-git-remote-set-head-origin--a 
Shell :: How to download Brave Browser in a chromebook 
Shell :: This script uses variables to make a backup of my home directory. 
Shell :: scan full form nmap 
Shell :: ray core file 
Shell :: bash cp command error with parenthesis 
Shell :: how to change line in slack 
Shell :: nextjs cli node options 
Shell :: install Dirichlet Multinomial R package 
Shell :: vim stuck in insert mode 
Shell :: Navigate to previous directory in windows command prompt 
Shell :: free code camp offline 
Shell :: git unstage 
Shell :: pyglet linux 
Shell :: list ios devices command line 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =