AWS CLI EC2 사용법

AWS EC2 기본 Command Line Interface

aws ec2 run-instances --image-id <<이미지id>> --count <<생성할갯수>> --instance-type <<인스턴스 타입>> --key-name <<키페어명>> --security-group-id <<시큐리티그룹 ID>> --subnet-id <<서브넷 ID>>

상기 내용을 바탕으로 만들어본 실행 명령어

aws ec2 run-instances 
  --image-id ami-0e999cbd62129e3b1 
  --count 1 
  --instance-type t2.micro 
  --key-name my-public-subnet 
  --security-group-id sg-00d2f470f06963603 
  --subnet-id subnet-000cca0e87c6baa1e

결과는 다음과 같이 나오면 된다

{
    "Instances": [
        {
            "Monitoring": {
                "State": "disabled"
            },
            "PublicDnsName": "",
            "StateReason": {
                "Message": "pending",
                "Code": "pending"
            },
            "State": {
                "Code": 0,
                "Name": "pending"
            },
            "EbsOptimized": false,
            "LaunchTime": "2021-02-13T02:51:38.000Z",
            "PrivateIpAddress": "10.0.0.13",
            "ProductCodes": [],
            "VpcId": "vpc-0e1688f816f93dfdd",
            "CpuOptions": {
                "CoreCount": 1,
                "ThreadsPerCore": 1
            },
            "StateTransitionReason": "",
            "InstanceId": "i-0bb1c23b4ce20989d",
            "EnaSupport": true,
            "ImageId": "ami-0e999cbd62129e3b1",
            "PrivateDnsName": "ip-10-0-0-13.us-west-2.compute.internal", 
            "EnclaveOptions": {
                "Enabled": false
            },
            "KeyName": "my-public-subnet", 
            "SecurityGroups": [
                {
                    "GroupName": "http-open",
                    "GroupId": "sg-00d2f470f06963603"
                }
            ],
            "ClientToken": "d63dfb12-bc4d-4288-8078-05a974b7dd5b",
            "SubnetId": "subnet-000cca0e87c6baa1e",
            "InstanceType": "t2.micro",
            "CapacityReservationSpecification": {
                "CapacityReservationPreference": "open"
            },
            "NetworkInterfaces": [
                {
                    "Status": "in-use",
                    "MacAddress": "02:9b:8e:61:a0:e9",
                    "SourceDestCheck": true,
                    "VpcId": "vpc-0e1688f816f93dfdd",
                    "Description": "",
                    "NetworkInterfaceId": "eni-0f121dcf58a3fdbac",
                    "PrivateIpAddresses": [
                        {
                            "PrivateDnsName": "ip-10-0-0-13.us-west-2.compute.internal",
                            "Primary": true,
                            "PrivateIpAddress": "10.0.0.13"
                        }
                    ],
                    "PrivateDnsName": "ip-10-0-0-13.us-west-2.compute.internal",
                    "InterfaceType": "interface",
                    "Attachment": {
                        "Status": "attaching",
                        "DeviceIndex": 0,
                        "AttachTime": "2021-02-13T02:51:38.000Z",
                        "DeleteOnTermination": true,
                        "AttachmentId": "eni-attach-0fda1c1680ebd0795",
                        "NetworkCardIndex": 0
                    },
                    "Groups": [
                        {
                            "GroupName": "http-open", 
                            "GroupId": "sg-00d2f470f06963603"
                        }
                    ],
                    "Ipv6Addresses": [],
                    "OwnerId": "144965779334",
                    "SubnetId": "subnet-000cca0e87c6baa1e",
                    "PrivateIpAddress": "10.0.0.13"
                }
            ],
            "SourceDestCheck": true,
            "Placement": {
                "Tenancy": "default",
                "GroupName": "",
                "AvailabilityZone": "us-west-2a"
            },
            "Hypervisor": "xen",
            "BlockDeviceMappings": [],
            "Architecture": "x86_64",
            "RootDeviceType": "ebs",
            "RootDeviceName": "/dev/xvda",
            "VirtualizationType": "hvm",
            "MetadataOptions": {
                "State": "pending",
                "HttpEndpoint": "enabled",
                "HttpTokens": "optional",
                "HttpPutResponseHopLimit": 1
            },
            "AmiLaunchIndex": 0
        }
    ],
    "ReservationId": "r-06a017348736209c9",
    "Groups": [],
    "OwnerId": "144965779334"
}

아주 혹시나 Security Group 이나 Subnet이 어디서 설정 되는지 모를 수 있음으로 관련 페이지를 아래와 같이 캡쳐해 본다.

Image ID

Instance-Type

Key-name

Security Group Id

Subnet Id

 

728x90
반응형

'AWS' 카테고리의 다른 글

Cloud9 Ports 오픈 하기  (0) 2021.03.01
EC2 Volume Size Extension  (0) 2021.03.01
cloud 9 AWS Resources Tab  (0) 2021.02.27
Amazon Linux Nodejs Install with Epel  (0) 2021.02.13
AWS default VPC 만들기 & ssh 접근 오류  (0) 2021.02.13