这是我的.travis.yml
:
language: python
python:
- "3.5"
cache: pip
install:
- pip install awscli
script:
- echo 'test'
deploy:
provider: s3
access_key_id: $AWS_ACCESS_ID
secret_access_key: $AWS_SECRET_ID
bucket: "xxxxx.com"
local_dir: build
skip_cleanup: true
cache_control: "max-age=21600"
on:
branch: master
after_deploy:
- aws configure set preview.cloudfront true
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
这只是一个没有节点或其他框架的html页面。我想推送到AWS S3存储桶,并为此存储桶的Cloudfront创建一个无效项。
问题在于,它可以成功上传到AWS S3存储桶,并且无法运行cloudfront来创建失效。
我从Travis收到了此错误消息。
> Deploying application
> uploading "index.html" with {:content_type=>"text/html", :cache_control=>"max-age=21600"}
>$ aws configure set preview.cloudfront true
>$ aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
Unable to locate credentials. You can configure credentials by running "aws configure".
Done.
对此有何想法?
答案 0 :(得分:1)
我相信这是因为您为S3上传的文件提供了访问密钥,但这些密钥特定于该操作。您需要设置凭据,以便after_deploy
中的AWS CLI命令可以使用它们。在您的after_deploy
中尝试一下:
after_deploy:
- aws configure set aws_access_key_id $AWS_ACCESS_ID
- aws configure set aws_secret_access_key $AWS_SECRET_ID
- aws configure set preview.cloudfront true
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"