amazon web services - How to get the public DNS of EC2 instance from outside using AWS CLI? -
i have 1 instance , planning have more in near future if can manage them outside world. hence need remotely request new servers, start them or shut them down @ will. hence, since ip address change every time, need method query servers' public dns name. , of needs done via aws cli.
for ;ast few days trying hunt information down , here.
my server, outside ec2 cluster has aws cli installed. have "access key id" copied iam page , assigned proper variable on server
$ echo $aws_access_key xxxxxxxxxxxx4pexxxxx $ ec2-describe-instances sanity-check: system clock 302 seconds behind. <?xml version="1.0" encoding="utf-8"?> <describeinstancesresponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/"> <requestid>53eb7530-2147-4ab6-8d6c-d9ddbdeef290</requestid> <reservationset/> </describeinstancesresponse> $ ec2-describe-instances i-4xxxxxx0 sanity-check: system clock 302 seconds behind. +----------------------------+---------------------------------------------+ | code | message | +----------------------------+---------------------------------------------+ | invalidinstanceid.notfound | instance id 'i-4xxxxxx0' not exist | +----------------------------+---------------------------------------------+
the secret key , instance number both have been copied console , pasted terminal window. there no way there typo in either of them.
first need configure aws cli , baked in aws access key , secret has policy describe instance.
for more information on how setup aws-cli follow link http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
once done properly, can list ec2 instance in particular region passing region within query. ex :- describe ec2-instances in us-west-2 region.
aws ec2 describe-instances --region us-west-1
you can use "jq" pipe symbol, parsing json , public ip of ec2-instance.
Comments
Post a Comment