启动ec2实例的简单脚本

ecpc的Python项目详细描述


ECPC:简单创建和管理EC2实例

ECPC提供了一个小的命令行工具集合来启动、列出 登录并终止ec2(spot)实例。

这是故意的 为用户调整的参数很少的工具。

先决条件:

你需要有一个aws帐户,并且你有权使用密钥和密钥。然后根据安装BOTO3 说明here

安装:

通过pip

% pip install ecpc

用法:

要启动实例,请使用ecpc create

% ecpc create my_instance
creating a t2.small instance in region eu-west-1 with ID my_instance
key pair created
security group created
required ami identified
launching instance - this may take some time...
instance launched
%

您可以更改实例类型,以及将其启动到的区域:

% ecpc create my_c5 -r us-west-1 -t c5.large
creating a c5.large instance in region eu-west-1 with ID my_c5
key pair created
security group created
required ami identified
launching instance - this may take some time...
instance launched
%

要列出实例:

% ecpc list
ID            region     type      up_time   state       cost($)
my_c5         us-west-1  c5.large  00:00:00  booting-up  0.00   
my_instance   eu-west-1  t2.small  00:04:00  ready       0.00 

^ {STR 1 }注:“成本”值为近似< /强>

要登录到实例,请使用ecpc login

% ecpc login my_instance
Warning: Permanently added '52.19.207.118' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-1029-aws x86_64)

    * Documentation:  https://help.ubuntu.com
    * Management:     https://landscape.canonical.com       
    * Support:        https://ubuntu.com/advantage

  System information as of Fri Dec  7 17:07:20 UTC 2018
  System load:  0.0               Processes:           82
      Usage of /:   13.4% of 7.69GB   Users logged in:     0
      Memory usage: 6%                IP address for eth0: 172.31.21.191
      Swap usage:   0%

      Get cloud support with Ubuntu Advantage Cloud Guest:
        http://www.ubuntu.com/business/services/cloud

    0 packages can be updated.
    0 updates are security updates.



    The programs included with the Ubuntu system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright.

    Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
    applicable law.

    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.

    ubuntu@my_instance:~$ 

要在实例之间传输文件和目录,请使用ecpc transfer

% ecpc transfer my_local_directory my_c5:./
% ecpc transfer my_c5:./results/result.log . 

要终止实例,请使用ecpc terminate

% ecpc terminate my_instance
instance terminated
security group deleted
key pair deleted
.pem file deleted
%

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
junit有没有办法在Java中重新初始化静态类?   在浏览器中点击应用程序时java Play框架挂起   文件Java错误中的NullPointerException   使用Java中的SNMP查找网络中计算机的登录名   java包装服务器引导程序已弃用,有什么替代方案?   当客户在等待理发时,java信号量值是否存在问题?   java如何使用JavaMail仅下载特定类型的附件   如何在java中将十进制转换为十六进制   java Slick2D粒子系统不会生成粒子   java检测更改事件来自何处   将Java集合类型参数类设置为数组   java如何从eclipse导出为可运行JAR文件?   java EntityManager对象未注入Glassfish和Spring   swing从actionPerformed和actionListener Java返回字符串   java在给定另一个等价键对象的情况下获取映射项的当前键   无论输入如何,java网络都会产生相同的输出