如何在travis部署脚本中运行AWS Configure? [英] How to run aws configure in a travis deploy script?
问题描述
我正在尝试获取 travis-ci 来运行使用
I am trying to get travis-ci to run a custom deploy script that uses awscli
to push a deployment up to my staging server.
在我的.travis.yml
文件中,我有这个:
In my .travis.yml
file I have this:
before_deploy:
- 'curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"'
- 'unzip awscli-bundle.zip'
- './awscli-bundle/install -b ~/bin/aws'
- 'export PATH=~/bin:$PATH'
- 'aws configure'
并且我设置了以下环境变量:
And I have set up the following environment variables:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION
在travis-ci
Web界面中具有正确的值.
with their correct values in the travis-ci
web interface.
但是,当aws configure
运行时,它将停止并等待用户输入.如何告诉它使用已定义的环境变量?
However when the aws configure
runs, it stops and waits for user input. How can I tell it to use the environment variables I have defined?
推荐答案
您可以通过两种方式进行设置.
You can set these in a couple of ways.
首先,通过在~/.aws/config
(或~/.aws/credentials
)创建文件.
Firstly, by creating a file at ~/.aws/config
(or ~/.aws/credentials
).
例如:
[default]
aws_access_key_id=foo
aws_secret_access_key=bar
region=us-west-2
第二,您可以为每个设置添加环境变量.
Secondly, you can add environment variables for each of your settings.
例如,创建以下环境变量:
For example, create the following environment variables:
AWS_DEFAULT_REGION
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
第三,您可以将region作为命令行参数传入.例如:
Thirdly, you can pass region in as a command line argument. For example:
aws eb deploy --region us-west-2
在这种情况下,由于配置了cli,因此您无需运行aws configure
.
You won't need to run aws configure
in these cases as the cli is configured.
此页面上还有其他AWS文档.
There is further AWS documentation on this page.
这篇关于如何在travis部署脚本中运行AWS Configure?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!