bunker是一个命令行程序,用于在aws中设置ec2进行远程开发或作为备份。它可以克隆您的Git RePOS,并将忽略的文件从您的机器转移到EC2。
aws-bunker的Python项目详细描述
燃料库
bunker是一个命令行程序,用于在aws中设置ec2进行远程开发或作为备份。除此之外,它还可以克隆您的git repo并将忽略的文件从您的计算机传输到ec2。
远程工作,使用蜂窝网络已经有15年的可能了。随着网络的发展,带宽的问题越来越少,但即使在今天的蜂窝网络上,下载大型文件(如Docker图像、ZIP档案等)也不切实际且成本高昂。一种解决方案是通过ssh连接到云上的虚拟机,然后在那里工作,但是跨多台计算机管理git repo和私有或被忽略的文件很快就会出现问题。
有了Bunker,这一过程更容易自动化。您只需要一个运行ubuntu的实例id和aws ec2,就可以运行shell脚本,将源文件复制到.profile,并根据需要复制任意多的repo和忽略的文件。例子:
# init bunker with your instance ID, etc
$ bunker init
# save some files to the ignored files list
$ bunker ignore config.ini .env.production terraform.tfvars
# run `/home/ubuntu/install-things.sh` on the instance
$ bunker install /home/ubuntu/install-things.sh
# source `/home/ubuntu/.prompt` to the .profile on the instance
$ bunker prompt /home/ubuntu/.prompt
# clone a local repo on the instance, and then copy over any files from the ignored file list
$ bunker build -r /path/to/local/repo
与我们的示例terraform文件(https://gitlab.com/shindagger/bunker" rel="nofollow">https://gitlab.com/shindagger/bunker一起使用时,您可以启动一个全新的ec2,克隆所需的repo,复制忽略的文件,并在大约5分钟内工作。terraform将输出一个实例id,可以用于bunker init。然后,您可以使用一个命令完成其余操作,如:
$ bunker install -y && bunker prompt -y && bunker build -r /path/to/local/repo -y
有关详细信息,请参阅下面的TerraForm和使用部分。
要求
- 巨蟒
- aws cli
- (地形)
此外,您还需要aws上的ec2实例,最好运行ubuntu>;=18.04。这个ec2需要打开ssh(端口22)和附加的ssm角色(amazonec2roleforsm)。
有关为ec2创建ssm角色的更多信息,请参见:
https://docs.aws.amazon.com/systems manager/latest/userguide/setup instance profile.html"实例配置文件添加权限
安装
$pip安装在所有AWS存储库中
注意:请参见下面的shell脚本和terraform部分:
项目主页:https://gitlab.com/shindagger/bunker rel="nofollow">https://gitlab.com/shindagger/bunker
shell脚本
install
和提示符
子命令假定ec2上有shell脚本。默认名称(不带位置参数)分别为:install essentials.sh
和.prompt.sh
。
第一个shell脚本用于基本软件(如python、pip、node和npm)。如果脚本尚未执行,请使用[-e]标志。提示
只需在ec2上的~/.profile中生成一个文件。
请参见此处的示例脚本(https://gitlab.com/shindagger/bunker)以及下面的terraform部分:
地形
我们还提供了terraform文件(https://gitlab.com/shindagger/bunker" rel="nofollow">https://gitlab.com/shindagger/bunker),配置后,这些文件将启动一个可用于bunker的ec2实例,并提供了所有示例shell脚本和您的.vimrc
。当然,我们鼓励您根据喜好更改这些文件。TerraForm将输出一个实例ID,您可以使用它初始化Bunker。
要配置和使用这些terraform文件:
CD放入repo dir和
ls*。默认值
。这些是在初始化terraform之前需要编辑的文件。每个文件都需要扩展名.tf.default
更改为.tf
编辑
alfa.tf
并确保区域正确。编辑
beta.tf代码>并将s3 bucket更改为您自己的bucket。还要确保区域正确。
使用aws sdk访问id和密钥编辑terraform.tfvars。还要确保您已使用aws configure配置此帐户
编辑
variables.tf
并更改默认值以反映您的愿望。注意:如果还没有,则需要手动创建自己的ssm角色和ssh密钥文件。ec2\u key\u name
只是aws中密钥对的名称,而ssh\u private\u key
是本地计算机上.pem文件的完整(绝对)路径。terraform初始化
地形平面图和地形图应用
< > >您有一个ec2实例id(请参见上面的"terraform")
您有一个目录(前缀),您将在其中保存
repositories.txt
和ignoredfiles.txt
。您可以复制此repo中的示例文件,并对其进行编辑以反映您的repo和忽略的文件。你有一个.pem文件,你知道它的位置路径。您为ec2设置了一个密钥对名称,它使用这个.pem文件。
你知道ec2的用户名(应该是"ubuntu")。我们可以选择在将来的版本中支持其他操作系统。
您已经为git提供程序创建了私钥,并在git提供程序设置中添加了公钥。此外,您已将本地ssh配置为使用此密钥,并至少测试或使用过一次。
< > >
在您初始化存储库之前
燃料库使用
$bunker-h
显示主存储库帮助页并退出
显示子命令的帮助页 编写存储库配置文件 示例 在repo文件中添加或删除repo目录。使用相对或绝对路径。 在忽略文件中添加或删除文件名。 在EC2实例上安装必要的软件。此命令将在EC2上运行可执行的shell脚本。默认脚本(不定义位置参数)命名为 在 克隆ec2上git repos的列表(repositories.txt),然后将忽略文件的rsync列表(ignored files.txt)从本地repos复制到ec2 repos。$bunker build-h
build
并退出。这将适用于任何可用的子命令$bunker初始化
~/.config bunker.ini
如果该文件已经存在,则答案将填充现有值[带下划线],只有在提供替换值时才会被覆盖。~/.config bunker.ini
:[default]
prefix = /Users/username/bunker-config
repos = repositories.txt
ignored = ignoredfiles.txt
pem = /Users/username/somename.pem
instance_id = i-04xxxxxxxxxxxx148
username = ubuntu
gitkeys = /Users/username/.ssh/git_rsa
$bunker repo path/to/repo/absolute/path/to/another repo../somerepo
$bunker ignore.env.local config.ini terraform.tfvars
$bunker安装
$bunker安装/home/ubuntu/script.sh
/home/ubuntu/install essentials.sh
。这是为了安装使用ec2所必需的任何软件。为了不知道用户希望在ec2上安装什么样的软件,bunker没有安装附带的shell脚本。不过,我们确实在项目主页上提供了示例shell脚本(以及ec2的terraform):
https://gitlab.com/shindagger/bunker$bunker提示
$bunker prompt/home/ubuntu/another prompt.sh
/home/ubuntu/.profile
中获取自定义提示文件此命令将在/home/ubuntu/.profile
中获取文件。默认名称为:/home/ubuntu/.prompt.sh
$bunker build
git clone
将使用ssh,假设您在git提供程序中设置了公钥,一个工作的使用ssh-t git@providerurl
至少一次,并使用bunker init
设置相关的私钥。
推荐PyPI第三方库