登陆到CommandHost实例,通过AWS CLI来管理各个资源

1. 通过Tags来管理资源

1.1 登陆到CommandHost实例

1.2 找出development实例

1.2.1 打开PowerShell窗口

1.2.2 找出所有tag名为Project,值为ERPSystem

aws ec2 describe-instances --filter "Name=tag:Project,Values=ERPSystem"

1.2.3 使用--query,减少上面命令的输出内容,只显示InstanceId

aws ec2 describe-instances --filter "Name=tag:Project,Values=ERPSystem" --query 'Reservations[*].Instances[*].InstanceId'

1.2.4 在输出内容中包含多个选定值

aws ec2 describe-instances --filter "Name=tag:Project,Values=ERPSystem" --query 'Reservations[*].Instances[*].{ID:InstanceId,AZ:Placement.AvailabilityZone}'

1.2.5 在输出内容中包含Project的tag值

aws ec2 describe-instances --filter "Name=tag:Project,Values=ERPSystem" --query 'Reservations[*].Instances[*].{ID:InstanceId,AZ:Placement.AvailabilityZone,Project:Tags[?Key==`Project`] | [0].Value}'

1.2.6 在输出内容中包含Environment和Version的tag值

aws ec2 describe-instances --filter "Name=tag:Project,Values=ERPSystem" --query 'Reservations[*].Instances[*].{ID:InstanceId,AZ:Placement.AvailabilityZone,Project:Tags[?Key==`Project`] | [0].Value,Environment:Tags[?Key==`Environment`] | [0].Value,Version:Tags[?Key==`Version`] | [0].Value}'

1.2.7 添加格外的过滤条件,只显示Environment的tag值为development的内容

aws ec2 describe-instances --filter "Name=tag:Project,Values=ERPSystem" "Name=tag:Environment,Values=development" --query 'Reservations[*].Instances[*].{ID:InstanceId,AZ:Placement.AvailabilityZone,Project:Tags[?Key==`Project`] | [0].Value,Environment:Tags[?Key==`Environment`] | [0].Value,Version:Tags[?Key==`Version`] | [0].Value}'

1.3 修改development实例的tag名为version的值

1.3.1 运行powershell脚本来修改version值

C:\temp\change-resource-tags.ps1

1.3.2 检查version值是否修改

aws ec2 describe-instances --filter "Name=tag:Project,Values=ERPSystem" "Name=tag:Environment,Values=development" --query 'Reservations[*].Instances[*].{ID:InstanceId,AZ:Placement.AvailabilityZone,Project:Tags[?Key==`Project`] | [0].Value,Environment:Tags[?Key==`Environment`] | [0].Value,Version:Tags[?Key==`Version`] | [0].Value}'

2. 通过Tag停止和启动EC2实例

2.2.1 停止所有Project名为ERPSystem,Environment为development的实例

c:\temp\stopinator.ps1 -tags "Project=ERPSystem;Environment=development"

2.2.2 启动所有Project名为ERPSystem,Environment为development的实例

c:\temp\stopinator.ps1 -tags "Project=ERPSystem;Environment=development" -start

3. Terminate不符合要求的实例

3.1.1 删除Environment标签

3.1.4 运行terminate-instances.ps1脚本

c:\temp\terminate-instances.ps1 -region us-west-2 -subnetid subnet-d67568a1

System Operations on AWS - Lab 5W - Managing Resources (Windows)的更多相关文章

  1. System Operations on AWS - Lab 3W - Managing Storage (Windows)

    创建一个名叫Processor的EC2实例,登陆到CommandHost实例,通过AWS CLI对Processor实例的EBS卷做snapshot,设置周期性snapshot的计划任务, 登陆到Pr ...

  2. System Operations on AWS - Lab 1W - Creating EC2 (Windows)

    1. 创建CommandHost实例,登录到CommandHost,通过AWS CLI创建WebServer实例. 1.1 为CommandHost实例创建一个IAM角色 1.2 创建CommandH ...

  3. System Operations on AWS - Lab 7 - CloudFormation

    CloudFormation模板:创建一个VPC(包含Public子网,Private子网,分别在不同的AZ),创建NAT,Bastion Server在Public子网. 1. 修改并运行AWS C ...

  4. System Operations on AWS - Lab 6W - Using Auto Scaling (Windows)

    创建你的一个web server,然后将这个实例制成你的AMI,通过启动配置生成一个Auto Scaling组(包括scale-in/scale-out策略),配置一台Load Balancer指向你 ...

  5. System Operations on AWS - Lab 4W - Monitoring (Windows)

    创建Web Server实例,配置CloudWatch来收集Web Server的系统日志,当错误登录次数达到设定值时触发报警 1. 创建Web Server 1.1 创建一个IAM策略 1.2 创建 ...

  6. System Operations on AWS - Lab 2 - Configuring VPC

    建立包含Public和Private子网的VPC,建立Internet Gateway,建立Public和Private子网的路由表,创建NAT和Bastion EC2实例 1. 配置你的私有虚拟云 ...

  7. RH133读书笔记(1)-Lab 1 Managing Startup

    Lab 1 Managing Startup Goal: To familiarize yourself with the startup process System Setup: A system ...

  8. 转 Oracle 12c: Managing Resources

    http://www.oracle-class.com/?p=3058 1. Introduction: Oracle database 12c comes with several Resource ...

  9. System x 服务器制作ServerGuide U盘安装Windows Server 2012 R2操作系统

    以下内容来源于:联想官方知识库  http://iknow.lenovo.com.cn/detail/dc_154773.html 本例介绍以U盘方式,通过ServerGuide引导在System x ...

随机推荐

  1. 【网络流24题】 No.14 孤岛营救问题 (分层图最短路)

    [题意] 1944 年,特种兵麦克接到国防部的命令,要求立即赶赴太平洋上的一个孤岛, 营救被敌军俘虏的大兵瑞恩. 瑞恩被关押在一个迷宫里, 迷宫地形复杂, 但幸好麦克得到了迷宫的地形图. 迷宫的外形是 ...

  2. 配置.NET程序使用代理进行HTTP请求

    方式一:代码方式 var defaultProxy = new WebProxy(); defaultProxy.Address = new Uri("http://proxy:8080&q ...

  3. SPRING IN ACTION 第4版笔记-第三章ADVANCING WIRING-005-Bean的作用域@Scope、ProxyMode

    一. Spring的bean默认是单例的 But sometimes you may find yourself working with a mutable class that does main ...

  4. eval

    字符串形式:表达式计算 Vsftp:/root/perl/14# cat aa 9 5 1 2 Vsftp:/root/perl/14# cat a1.pl open (A,aa); while ($ ...

  5. unicode转中文

    <pre name="code" class="html">[root@dr-mysql01 ~]# cat a1.pl my $str=" ...

  6. linux下解压缩jar包

    在部署项目是需要对jar中的文件进行编辑,这就要在linux命令行下对jar进行解压缩操作. 比如有个jar包,/usr/local/EtnetChinaApplication.jar 解包到临时目录 ...

  7. 1px

    Retina屏的移动设备如何实现真正1px的线? <!DOCTYPE html> <html> <head> <meta charset="utf- ...

  8. 使用Eclipse构建GeoTools项目

    转自:http://hi.baidu.com/liushuigs/item/a62969e6667f9815585dd8b1 由于GeoTools是原本是使用Maven构建的,所以,不能直接将工程导入 ...

  9. AKKA初体验

    关于thread和actor下面这段话讲的很好Experienced developers have learned to be very careful with unrestricted thre ...

  10. SQL SERVER 自定义函数 整数转成指定长度的16进制 转换成指定长度的16进制 不足补0

    最近做项目扩展的时候,遇到问题就是将整型转换成指定长度的16进制 刚开始就是直接使用 cast(12 as varbinary(4))但是发现这个不能解决我的问题 所以就上网搜了一下,然后改了改,下面 ...