resources: aws: ec2: Send IP addresses and InstanceID
This commit is contained in:
committed by
James Shubin
parent
032d0992d6
commit
c455ef2c62
@@ -176,6 +176,11 @@ type AwsEc2Res struct {
|
|||||||
awsChan chan *chanStruct // channel used to send events and errors to Watch()
|
awsChan chan *chanStruct // channel used to send events and errors to Watch()
|
||||||
closeChan chan struct{} // channel used to cancel context when it's time to shut down
|
closeChan chan struct{} // channel used to cancel context when it's time to shut down
|
||||||
wg *sync.WaitGroup // waitgroup for goroutines in Watch()
|
wg *sync.WaitGroup // waitgroup for goroutines in Watch()
|
||||||
|
|
||||||
|
// store read-only values for send/recv.
|
||||||
|
PublicIPv4 string
|
||||||
|
PrivateIPv4 string
|
||||||
|
InstanceID string
|
||||||
}
|
}
|
||||||
|
|
||||||
// chanStruct defines the type for a channel used to pass events and errors to watch.
|
// chanStruct defines the type for a channel used to pass events and errors to watch.
|
||||||
@@ -684,6 +689,14 @@ func (obj *AwsEc2Res) CheckApply(apply bool) (checkOK bool, err error) {
|
|||||||
return false, fmt.Errorf("instance is nil")
|
return false, fmt.Errorf("instance is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// store useful send/recv values when we return
|
||||||
|
defer func() {
|
||||||
|
// safely dereference the pointers (nil becomes "")
|
||||||
|
obj.PublicIPv4 = aws.StringValue(instance.PublicIpAddress)
|
||||||
|
obj.PrivateIPv4 = aws.StringValue(instance.PrivateIpAddress)
|
||||||
|
obj.InstanceID = aws.StringValue(instance.InstanceId)
|
||||||
|
}()
|
||||||
|
|
||||||
// If the instance is in a transitional state, Watch will send a new event
|
// If the instance is in a transitional state, Watch will send a new event
|
||||||
// when the instance finishes its transition. Since we can't apply the
|
// when the instance finishes its transition. Since we can't apply the
|
||||||
// desired state until the instance is stopped, running, or terminated, we
|
// desired state until the instance is stopped, running, or terminated, we
|
||||||
|
|||||||
Reference in New Issue
Block a user