3
4

3 回答 3

1

I believe you'd be looking to force an invalidation via the origin (i.e. your S3 bucket or similar) like so:

s3cmd --cf-invalidate _site/ s3://example-origin.com/
于 2013-09-23T10:48:40.170 回答
1

Here is my final conclusion:
after many many tries , the solution is very restrict.

  1. follow this format:

s3cmd sync --cf-invalidate --acl-public --preserve --recursive ./[local_folder] s3://[my_bucket]/[remote_folder]/

  1. when I run this command , the actual folder should be in command running folder

  2. local file should have ./

  3. remote folder should be end by /

于 2015-06-07T20:14:30.603 回答
0

I could not make s3cmd's invalidation work, so I used s3cmd to update the file and cloudfront-invalidator to do the invalidation. The script reads the aws authentication used by s3cmd for cloudfront-invalidator.

#!/bin/bash

if [ -z "$(which s3cmd)" ]; then
  echo "s3cmd is not installed or is not on the PATH"
  exit -1
fi

if [ -z "$(which cloudfront-invalidator)" ]; then
  echo "cloudfront-invalidator is not installed or is not on the PATH"
  echo "See https://github.com/reidiculous/cloudfront-invalidator"
  echo "TL;DR: sudo gem install cloudfront-invalidator"
  exit -1
fi

function awsKeyId {
  awk -F '=' '{if (! ($0 ~ /^;/) && $0 ~ /aws_access_key_id/) print $2}' ~/.aws/config | tr -d ' '
}

function awsSecret {
  awk -F '=' '{if (! ($0 ~ /^;/) && $0 ~ /aws_secret_access_key/) print $2}' ~/.aws/config | tr -d ' '
}

export file="stylesheets/main.css"
export distributionId=blahblah
export bucket=www.blahblah

s3cmd -P -m 'text/css' put public/$file s3://$bucket/$f
cloudfront-invalidator invalidate `awsKeyId` `awsSecret` $distributionId $file
于 2015-04-17T18:19:16.120 回答