Amazon s3 s3cmd失效选择分布
我正在尝试使用s3cmd工具使我的文件无效, 似乎s3cmd自动为我选择了一个发行版, 但我有来自同一个桶的更多分发,我如何选择使分发失效 我试过这个:Amazon s3 s3cmd失效选择分布,amazon-s3,s3cmd,invalidation,Amazon S3,S3cmd,Invalidation,我正在尝试使用s3cmd工具使我的文件无效, 似乎s3cmd自动为我选择了一个发行版, 但我有来自同一个桶的更多分发,我如何选择使分发失效 我试过这个: s3cmd同步-cf使我的文件无效cf://xxxxxxxxx/mypath 但它不起作用。我明白了: 无效的源/目标“ 有什么想法吗 谢谢 我相信您会希望通过origin(即您的S3存储桶或类似存储桶)强制执行失效,如下所示: 我无法使s3cmd的无效化工作,因此我使用s3cmd更新文件,并使用cloudfront invalidater执行
s3cmd同步-cf使我的文件无效cf://xxxxxxxxx/mypath
但它不起作用。我明白了:
无效的源/目标“
有什么想法吗
谢谢 我相信您会希望通过origin(即您的S3存储桶或类似存储桶)强制执行失效,如下所示:
我无法使
s3cmd
的无效化工作,因此我使用s3cmd
更新文件,并使用cloudfront invalidater
执行无效化。脚本读取s3cmd
为cloudfront Invalidater
使用的aws身份验证
#!/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
这是我最后的结论:
经过多次尝试,解决方案非常有限
s3cmd sync--cf invalidate--acl public--preserve--recursive./[local\u folder]s3://[my\u bucket]/[remote\u folder]/
实际上,我创建了一个sinatra服务器来发送包含完整xml数据的post数据,以开始失效。我的sh将只发送一个文件的字符串内容键。curl-X GET“http://[sinatra_server_ip]:[port]/signinval?objectList=${filelist}&s3dist=${s3dist}&token=${serverToken}&bucket=${bucket}&type=${fileType}”本地文件应该准备好。
#!/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