Skip to content

Commit 9aa6b56

Browse files
authored
Merge pull request #19 from topcoder-platform/dev
CF cache issue fix
2 parents 9afe6a6 + 54d1e9d commit 9aa6b56

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed

buildenv.sh

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ download_buildenvfile()
3737
track_error $? "$listname.json"
3838
done
3939
}
40+
41+
download_psfile()
42+
{
43+
Buffer_seclist=$(echo $SECPS_LIST | sed 's/,/ /g' )
44+
for listname in $Buffer_seclist;
45+
do
46+
aws s3 cp s3://tc-platform-${ENV_CONFIG}/securitymanager/$listname.json .
47+
track_error $? "$listname.json download"
48+
jq 'keys[]' $listname.json
49+
track_error $? "$listname.json"
50+
done
51+
}
52+
4053
uploading_buildenvvar()
4154
{
4255
Buffer_seclist=$(echo $BUILDENV_LIST | sed 's/,/ /g')
@@ -59,6 +72,38 @@ uploading_buildenvvar()
5972
done
6073
}
6174

75+
uploading_buildpsenvar()
76+
{
77+
if [ -z $SECPS_LIST ];
78+
then
79+
log "No ps file provided"
80+
else
81+
Buffer_seclist=$(echo $SECPS_LIST | sed 's/,/ /g')
82+
for listname in $Buffer_seclist;
83+
do
84+
local o=$IFS
85+
IFS=$(echo -en "\n\b")
86+
varpath=$( cat $listname.json | jq -r ' .ParmeterPathList[] ' )
87+
#log "vars are fetched"
88+
for k in $varpath;
89+
do
90+
echo $k
91+
aws ssm get-parameters-by-path --with-decryption --path $k --query "Parameters[*].{Name:Name, Value:Value}" > paramnames.json
92+
###paramnames=$(cat paramnames.json | jq -r .[].Name | rev | cut -d / -f 1 | rev)
93+
for s in $(cat paramnames.json | jq -c .[] )
94+
do
95+
varname=$(echo $s | jq -r .Name | rev | cut -d / -f 1 | rev)
96+
varvalue=$(echo $s | jq -r .Value)
97+
#varvalue="arn:aws:ssm:$AWS_REGION:$AWS_ACCOUNT_ID:parameter$s"
98+
echo export "$varname"="'$varvalue'" >>"buildenvvar"
99+
#echo "$varname" "$varvalue"
100+
done
101+
done
102+
IFS=$o
103+
done
104+
fi
105+
}
106+
62107
configure_aws_cli() {
63108
aws --version
64109
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
@@ -68,7 +113,7 @@ configure_aws_cli() {
68113
log "Configured AWS CLI."
69114
}
70115

71-
while getopts .b:e:. OPTION
116+
while getopts .b:e:l:. OPTION
72117
do
73118
case $OPTION in
74119
e)
@@ -77,7 +122,9 @@ do
77122
b)
78123
BUILDENV_LIST=$OPTARG
79124
;;
80-
125+
l)
126+
SECPS_LIST=$OPTARG
127+
;;
81128
?)
82129
log "additional param required"
83130
usage
@@ -104,6 +151,8 @@ done
104151
ENV_CONFIG=`echo "$ENV" | tr '[:upper:]' '[:lower:]'`
105152
download_buildenvfile
106153
uploading_buildenvvar
154+
download_psfile
155+
uploading_buildpsenvar
107156

108157
if grep -Fxq "buildenvvar" .dockerignore
109158
then

master_deploy.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ ebstemplate=""
6969
#variable for cloud front
7070
#AWS_S3_BUCKET=""
7171
#AWS_S3_SOURCE_SYNC_PATH=""
72-
CFCACHE="true"
72+
CFCACHE="false"
7373

7474
# Variables for Lambda
7575
#AWS_LAMBDA_DEPLOY_TYPE=""
@@ -648,10 +648,10 @@ deploy_s3bucket() {
648648
cat /etc/mime.types | grep -i map
649649
cat /etc/mime.types | grep -i ttf
650650
if [ "$CFCACHE" = "true" ]; then
651-
S3_CACHE_OPTIONS="--cache-control max-age=0,s-maxage=86400"
651+
S3_CACHE_OPTIONS="--cache-control private,no-store,no-cache,must-revalidate,max-age=0"
652+
echo "*** Deploying with Cloudfront Cache disabled ***"
652653
else
653-
S3_CACHE_OPTIONS="--cache-control private,no-store,no-cache,must-revalidate,max-age=0"
654-
echo "*** Deploying with Cloudfront Cache disabled ***"
654+
S3_CACHE_OPTIONS="--cache-control max-age=0,s-maxage=86400"
655655
fi
656656

657657
S3_OPTIONS="--exclude '*.txt' --exclude '*.js' --exclude '*.css'"

0 commit comments

Comments
 (0)