Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
fixed public ip extraction for aws
Browse files Browse the repository at this point in the history
  • Loading branch information
DockToFuture committed May 22, 2020
1 parent 67abac8 commit 3346dda
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions pkg/cmd/ssh_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,20 +278,12 @@ func (a *AwsInstanceAttribute) createBastionHostInstance() {
checkError(err)
fmt.Println("Instance State: " + capturedOutput)
if strings.Trim(capturedOutput, "\n") == "running" {
arguments := "aws ec2 describe-instances --instance-id " + a.BastionInstanceID
arguments := "aws ec2 describe-instances --instance-id " + a.BastionInstanceID + " --query Reservations[*].Instances[*].PublicIpAddress"
captured := capture()
operate("aws", arguments)
capturedOutput, err := captured()
words := strings.Fields(capturedOutput)
checkError(err)
ip := ""
for _, value := range words {
if isIP(value) && !strings.HasPrefix(value, "10.") {
ip = value
break
}
}
a.BastionIP = ip
a.BastionIP = capturedOutput
return
}
time.Sleep(time.Second * 2)
Expand Down

0 comments on commit 3346dda

Please sign in to comment.