单位老大让我研究一下关于命令行管理 AWS对象,顺便把操作的过程贴出来,以便后期参考:
bogon:~ yuanjicai$ aws ec2 create-vpc --cidr-block 172.10.0.0/16 创建VPC
{
"Vpc": {
"VpcId": "vpc-1c34e475",
"InstanceTenancy": "default",
"State": "pending",
"DhcpOptionsId": "dopt-c1a747a8",
"CidrBlock": "172.10.0.0/16",
"IsDefault": false
}
}
bogon:~ yuanjicai$ aws ec2 describe-vpcs 查看VPC
{
"Vpcs": [
{
"VpcId": "vpc-1c34e475",
"InstanceTenancy": "default",
"State": "available",
"DhcpOptionsId": "dopt-c1a747a8",
"CidrBlock": "172.10.0.0/16",
"IsDefault": false
},
{
"VpcId": "vpc-a95cbdc0",
"InstanceTenancy": "default",
"State": "available",
"DhcpOptionsId": "dopt-c1a747a8",
"CidrBlock": "172.31.0.0/16",
"IsDefault": true
}
]
}
bogon:~ yuanjicai$ aws ec2 describe-availability-zones 查看可用区域
{
"AvailabilityZones": [
{
"State": "available",
"RegionName": "ap-south-1",
"Messages": [],
"ZoneName": "ap-south-1a"
},
{
"State": "available",
"RegionName": "ap-south-1",
"Messages": [],
"ZoneName": "ap-south-1b"
}
]
}
bogon:~ yuanjicai$ aws ec2 create-subnet --vpc-id vpc-1c34e475 --cidr-block 172.10.1.0/24 --availability-zone ap-south-1a 在每个可用区域中创建相应的子网
{
"Subnet": {
"VpcId": "vpc-1c34e475",
"CidrBlock": "172.10.1.0/24",
"State": "pending",
"AvailabilityZone": "ap-south-1a",
"SubnetId": "subnet-c4815dad",
"AvailableIpAddressCount": 251
}
}
bogon:~ yuanjicai$ aws ec2 create-subnet --vpc-id vpc-1c34e475 --cidr-block 172.10.2.0/24 --availability-zone ap-south-1b 在每个可用区域中创建相应的子网
{
"Subnet": {
"VpcId": "vpc-1c34e475",
"CidrBlock": "172.10.2.0/24",
"State": "pending",
"AvailabilityZone": "ap-south-1b",
"SubnetId": "subnet-df839e95",
"AvailableIpAddressCount": 251
}
}
bogon:~ yuanjicai$
bogon:~ yuanjicai$ aws ec2 create-internet-gateway 创建internet网关
{
"InternetGateway": {
"Tags": [],
"InternetGatewayId": "igw-4a35f123",
"Attachments": []
}
}
bogon:~ yuanjicai$ aws ec2 attach-internet-gateway --internet-gateway-id igw-4a35f123 --vpc-id vpc-1c34e475 将internet网关附加到vpc上
bogon:~ yuanjicai$ aws ec2 describe-route-tables 查看路由表
{
"RouteTables": [
{
"Associations": [
{
"RouteTableAssociationId": "rtbassoc-4d846424",
"Main": true,
"RouteTableId": "rtb-2eb75747"
}
],
"RouteTableId": "rtb-2eb75747",
"VpcId": "vpc-a95cbdc0",
"PropagatingVgws": [],
"Tags": [],
"Routes": [
{
"GatewayId": "local",
"DestinationCidrBlock": "172.31.0.0/16",
"State": "active",
"Origin": "CreateRouteTable"
},
{
"GatewayId": "igw-b25abcdb",
"DestinationCidrBlock": "0.0.0.0/0",
"State": "active",
"Origin": "CreateRoute"
}
]
},
{
"Associations": [
{
"RouteTableAssociationId": "rtbassoc-cd0aa2a4",
"Main": true,
"RouteTableId": "rtb-3cd00c55"
}
],
"RouteTableId": "rtb-3cd00c55",
"VpcId": "vpc-1c34e475",
"PropagatingVgws": [],
"Tags": [],
"Routes": [
{
"GatewayId": "local",
"DestinationCidrBlock": "172.10.0.0/16",
"State": "active",
"Origin": "CreateRouteTable"
}
]
}
]
}
bogon:~ yuanjicai$ aws ec2 associate-route-table --route-table-id rtb-3cd00c55 --subnet-id subnet-c4815dad 将创建的子网关联到路由表
{
"AssociationId": "rtbassoc-7b0ea612"
}
bogon:~ yuanjicai$ aws ec2 associate-route-table --route-table-id rtb-3cd00c55 --subnet-id subnet-df839e95
{
"AssociationId": "rtbassoc-720ea61b"
}
bogon:~ yuanjicai$
bogon:~ yuanjicai$ aws ec2 create-route --route-table-id rtb-3cd00c55 --destination-cidr-block 0.0.0.0/0 --gateway-id igw-4a35f123 在路由表中创建相关路由条目
{
"Return": true
}
bogon:~ yuanjicai$ aws ec2 create-key-pair --key-name aws-mb-personal.pem 创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7JMc2SDPK\nU7l4yBW+TiyLRQohPmfJgmcHseHhBEfd2736bKtfZ93ZVu0CgYAOMyS/Q5gQ2vu6rtSa7D8K9TmV\nLIiziHLnR3FOVlX39iiuU02ubCwPsf7/LqBi3UfpjtA0IkNdMQO5TIovFzGgEDkOxTmO8TpyPsgK\nR+m0yjD9KUKEHIsdJUNOodVeBYsxGNrlbAVZLgV1JGnHKilfMQYILvZNC1ZBzFLi+ewlQg==\n-----END RSA PRIVATE KEY-----" > Downloads/aws-mb-personal.pem 将私钥保存在本地,文件名为aws-mb-personal.pem
bogon:~ yuanjicai$ chmod 600 Downloads/aws-mb-personal.pem 为私钥设置权限
bogon:~ yuanjicai$ aws ec2 create-security-group --group-name allow-ssh_web --description "test" --vpc-id vpc-1c34e475 创建安全组
{
"GroupId": "sg-5aa21533"
}
bogon:~ yuanjicai$ aws ec2 authorize-security-group-ingress --group-id sg-5aa21533 --protocol tcp --port 22 --cidr 0.0.0.0/0 在安全组中创建访问规则
bogon:~ yuanjicai$ aws ec2 describe-security-groups --query SecurityGroups[*].[GroupName,GroupId,VpcId] 查看安全组
[
[
"allow-ssh_web",
"sg-5aa21533",
"vpc-1c34e475"
],
[
"default",
"sg-50a71039",
"vpc-1c34e475"
],
[
"default",
"sg-f318f49a",
"vpc-a95cbdc0"
]
]
bogon:~ yuanjicai$ aws ec2 describe-security-groups --group-ids sg-5aa21533 查看安全组的访问规则
{
"SecurityGroups": [
{
"IpPermissionsEgress": [
{
"IpProtocol": "-1",
"IpRanges": [
{
"CidrIp": "0.0.0.0/0"
}
],
"UserIdGroupPairs": [],
"PrefixListIds": []
}
],
"Description": "test",
"IpPermissions": [
{
"PrefixListIds": [],
"FromPort": 22,
"IpRanges": [
{
"CidrIp": "0.0.0.0/0"
}
],
"ToPort": 22,
"IpProtocol": "tcp",
"UserIdGroupPairs": []
}
],
"GroupName": "allow-ssh_web",
"VpcId": "vpc-1c34e475",
"OwnerId": "632310953995",
"GroupId": "sg-5aa21533"
}
]
}
bogon:~ yuanjicai$
bogon:~ yuanjicai$ aws ec2 run-instances --image-id ami-cacbbea5 --count 1 --instance-type t2.micro --key-name aws-mb-personal.pem --security-group-ids sg-5aa21533 --subnet-id subnet-df839e95 --associate-public-ip-address 创建实例,指定相关的AMI、数量、类型、密钥、安全组、子网等
{
"OwnerId": "632310953995",
"ReservationId": "r-0be49b2436993213e",
"Groups": [],
"Instances": [
{
"Monitoring": {
"State": "disabled"
},
"PublicDnsName": "",
"RootDeviceType": "ebs",
"State": {
"Code": 0,
"Name": "pending"
},
"EbsOptimized": false,
"LaunchTime": "2016-10-14T13:39:02.000Z",
"PrivateIpAddress": "172.10.2.162",
"ProductCodes": [],
"VpcId": "vpc-1c34e475",
"StateTransitionReason": "",
"InstanceId": "i-01912a2add60e2f97",
"ImageId": "ami-cacbbea5",
"PrivateDnsName": "ip-172-10-2-162.ap-south-1.compute.internal",
"KeyName": "aws-mb-personal.pem",
"SecurityGroups": [
{
"GroupName": "allow-ssh_web",
"GroupId": "sg-5aa21533"
}
],
"ClientToken": "",
"SubnetId": "subnet-df839e95",
"InstanceType": "t2.micro",
"NetworkInterfaces": [
{
"Status": "in-use",
"MacAddress": "0a:2d:73:8d:d5:5d",
"SourceDestCheck": true,
"VpcId": "vpc-1c34e475",
"Description": "",
"NetworkInterfaceId": "eni-f1fb60bc",
"PrivateIpAddresses": [
{
"Primary": true,
"PrivateIpAddress": "172.10.2.162"
}
],
"Attachment": {
"Status": "attaching",
"DeviceIndex": 0,
"DeleteOnTermination": true,
"AttachmentId": "eni-attach-1b6a34a0",
"AttachTime": "2016-10-14T13:39:02.000Z"
},
"Groups": [
{
"GroupName": "allow-ssh_web",
"GroupId": "sg-5aa21533"
}
],
"SubnetId": "subnet-df839e95",
"OwnerId": "632310953995",
"PrivateIpAddress": "172.10.2.162"
}
],
"SourceDestCheck": true,
"Placement": {
"Tenancy": "default",
"GroupName": "",
"AvailabilityZone": "ap-south-1b"
},
"Hypervisor": "xen",
"BlockDeviceMappings": [],
"Architecture": "x86_64",
"StateReason": {
"Message": "pending",
"Code": "pending"
},
"RootDeviceName": "/dev/xvda",
"VirtualizationType": "hvm",
"AmiLaunchIndex": 0
}
]
}
bogon:~ yuanjicai$ aws ec2 describe-instances --query ‘Reservations[*].Instances[*].[PublicIpAddress, PrivateIpAddress,InstanceId]‘ --output text 查看ec2实例的IP和instance-id
52.66.31.169172.10.2.162i-01912a2add60e2f97
bogon:~ yuanjicai$ aws ec2 create-tags --resources i-01912a2add60e2f97 --tags Key=Name,Value=instance01-mb 将创建的实例标记为 instance01-mb
bogon:~ yuanjicai$ ssh -i Downloads/aws-mb-personal.pem ec2-user@52.66.31.169 利用本地的私钥访问ec2实例
The authenticity of host ‘52.66.31.169 (52.66.31.169)‘ can‘t be established.
ECDSA key fingerprint is SHA256:upiOwWm7/Zp9zWwze0IaKdy2MoT13xvUbdGsRxbvkK4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘52.66.31.169‘ (ECDSA) to the list of known hosts.
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-ami/2016.09-release-notes/
1 package(s) needed for security, out of 10 available
Run "sudo yum update" to apply all updates.
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
[ec2-user@ip-172-10-2-162 ~]$ sudo su -
[root@ip-172-10-2-162 ~]# exit
logout
[ec2-user@ip-172-10-2-162 ~]$ exit
logout
Connection to 52.66.31.169 closed.
bogon:~ yuanjicai$
bogon:~ yuanjicai$ aws ec2 stop-instances --instance-id i-01912a2add60e2f97 停止实例
{
"StoppingInstances": [
{
"InstanceId": "i-01912a2add60e2f97",
"CurrentState": {
"Code": 64,
"Name": "stopping"
},
"PreviousState": {
"Code": 16,
"Name": "running"
}
}
]
}
bogon:~ yuanjicai$ aws ec2 describe-instance-status --instance-id i-01912a2add60e2f97 查看实例状态
{
"InstanceStatuses": []
}
bogon:~ yuanjicai$ aws ec2 start-instances --instance-id i-01912a2add60e2f97 启动实例
{
"StartingInstances": [
{
"InstanceId": "i-01912a2add60e2f97",
"CurrentState": {
"Code": 0,
"Name": "pending"
},
"PreviousState": {
"Code": 80,
"Name": "stopped"
}
}
]
}
bogon:~ yuanjicai$
bogon:~ yuanjicai$ aws ec2 describe-instance-status --instance-id i-01912a2add60e2f97 再次查看实例状态
{
"InstanceStatuses": [
{
"InstanceId": "i-01912a2add60e2f97",
"InstanceState": {
"Code": 16,
"Name": "running"
},
"AvailabilityZone": "ap-south-1b",
"SystemStatus": {
"Status": "initializing",
"Details": [
{
"Status": "initializing",
"Name": "reachability"
}
]
},
"InstanceStatus": {
"Status": "initializing",
"Details": [
{
"Status": "initializing",
"Name": "reachability"
}
]
}
}
]
}
bogon:~ yuanjicai$
bogon:~ yuanjicai$ aws ec2 create-volume --size 50 --availability-zone ap-south-1b --volume-type gp2 创建50G gp2卷
{
"AvailabilityZone": "ap-south-1b",
"Encrypted": false,
"VolumeType": "gp2",
"VolumeId": "vol-02aaed26650c96fe5",
"State": "creating",
"Iops": 150,
"SnapshotId": "",
"CreateTime": "2016-10-18T06:20:43.510Z",
"Size": 50
}
bogon:~ yuanjicai$ aws ec2 create-tags --resources vol-02aaed26650c96fe5 --tags Key=Name,Value=attach-to-instance01-mb 将卷标记为“attach-to-instance01-mb”
bogon:~ yuanjicai$ aws ec2 describe-tags --filters "Name=resource-id,Values=vol-02aaed26650c96fe5" 查看卷
{
"Tags": [
{
"ResourceType": "volume",
"ResourceId": "vol-02aaed26650c96fe5",
"Value": "attach-to-instance01-mb",
"Key": "Name"
}
]
}
bogon:~ yuanjicai$ aws ec2 attach-volume --volume-id vol-02aaed26650c96fe5 --instance-id i-01912a2add60e2f97 --device /dev/sdf 将卷附件到指定的实例上
{
"AttachTime": "2016-10-18T06:28:35.886Z",
"InstanceId": "i-01912a2add60e2f97",
"VolumeId": "vol-02aaed26650c96fe5",
"State": "attaching",
"Device": "/dev/sdf"
}
bogon:~ yuanjicai$ aws ec2 describe-volumes --volume-id vol-02aaed26650c96fe5 查看卷信息
{
"Volumes": [
{
"AvailabilityZone": "ap-south-1b",
"Attachments": [
{
"AttachTime": "2016-10-18T06:28:35.000Z",
"InstanceId": "i-01912a2add60e2f97",
"VolumeId": "vol-02aaed26650c96fe5",
"State": "attached",
"DeleteOnTermination": false,
"Device": "/dev/sdf"
}
],
"Tags": [
{
"Value": "attach-to-instance01-mb",
"Key": "Name"
}
],
"Encrypted": false,
"VolumeType": "gp2",
"VolumeId": "vol-02aaed26650c96fe5",
"State": "in-use",
"Iops": 150,
"SnapshotId": "",
"CreateTime": "2016-10-18T06:20:43.510Z",
"Size": 50
}
]
}
bogon:~ yuanjicai$ aws ec2 detach-volume --volume-id vol-02aaed26650c96fe5 从指定的实例上分离指定的卷
{
"AttachTime": "2016-10-18T06:28:35.000Z",
"InstanceId": "i-01912a2add60e2f97",
"VolumeId": "vol-02aaed26650c96fe5",
"State": "detaching",
"Device": "/dev/sdf"
}
bogon:~ yuanjicai$ aws ec2 delete-volume --volume-id vol-02aaed26650c96fe5 删除指定的卷
bogon:~ yuanjicai$ aws ec2 stop-instances --instance-id i-01912a2add60e2f97 停止实例
{
"StoppingInstances": [
{
"InstanceId": "i-01912a2add60e2f97",
"CurrentState": {
"Code": 64,
"Name": "stopping"
},
"PreviousState": {
"Code": 16,
"Name": "running"
}
}
]
}
bogon:~ yuanjicai$
bogon:~ yuanjicai$ aws ec2 describe-instances | grep -i instanceid
"InstanceId": "i-01912a2add60e2f97",
bogon:~ yuanjicai$ aws ec2 terminate-instances --instance-id i-01912a2add60e2f97 终止指定的实例
{
"TerminatingInstances": [
{
"InstanceId": "i-01912a2add60e2f97",
"CurrentState": {
"Code": 48,
"Name": "terminated"
},
"PreviousState": {
"Code": 80,
"Name": "stopped"
}
}
]
}
bogon:~ yuanjicai$ aws ec2 describe-instances --region "ap-northeast-1" | grep -i instanceid
"InstanceId": "i-0b8fd935a1bdd8deb",
bogon:~ yuanjicai$
bogon:~ yuanjicai$ aws ec2 describe-instances --region "ap-northeast-1" | grep -i status
"Status": "in-use",
"Status": "attached",
"Status": "attached",
bogon:~ yuanjicai$
bogon:~ yuanjicai$ aws ec2 describe-instances --region "ap-northeast-1" | grep -i type
"RootDeviceType": "ebs",
"InstanceType": "t2.micro",
"VirtualizationType": "hvm",
bogon:~ yuanjicai$ aws ec2 modify-instance-attribute --instance-id i-0b8fd935a1bdd8deb --instance-type t2.medium --region "ap-northeast-1" 更改实例类型
bogon:~ yuanjicai$ aws ec2 describe-instances --region "ap-northeast-1" | grep -i type
"RootDeviceType": "ebs",
"InstanceType": "t2.medium",
"VirtualizationType": "hvm",
bogon:~ yuanjicai$
bogon:~ yuanjicai$ aws ec2 modify-instance-attribute --instance-id i-0b8fd935a1bdd8deb --groups sg-bf0008db sg-987480ff --region "ap-northeast-1" 更改安全组
bogon:~ yuanjicai$
本文出自 “11462293” 博客,谢绝转载!
原文地址:http://11472293.blog.51cto.com/11462293/1863038