Merge pull request #6851 from TeaBough/master
provider/aws: Handled case when instanceId is absent in network interfaces
This commit is contained in:
commit
6367bade03
|
@ -720,7 +720,9 @@ func expandPrivateIPAddresses(ips []interface{}) []*ec2.PrivateIpAddressSpecific
|
||||||
//Flattens network interface attachment into a map[string]interface
|
//Flattens network interface attachment into a map[string]interface
|
||||||
func flattenAttachment(a *ec2.NetworkInterfaceAttachment) map[string]interface{} {
|
func flattenAttachment(a *ec2.NetworkInterfaceAttachment) map[string]interface{} {
|
||||||
att := make(map[string]interface{})
|
att := make(map[string]interface{})
|
||||||
|
if a.InstanceId != nil {
|
||||||
att["instance"] = *a.InstanceId
|
att["instance"] = *a.InstanceId
|
||||||
|
}
|
||||||
att["device_index"] = *a.DeviceIndex
|
att["device_index"] = *a.DeviceIndex
|
||||||
att["attachment_id"] = *a.AttachmentId
|
att["attachment_id"] = *a.AttachmentId
|
||||||
return att
|
return att
|
||||||
|
|
|
@ -756,6 +756,23 @@ func TestFlattenAttachment(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFlattenAttachmentWhenNoInstanceId(t *testing.T) {
|
||||||
|
expanded := &ec2.NetworkInterfaceAttachment{
|
||||||
|
DeviceIndex: aws.Int64(int64(1)),
|
||||||
|
AttachmentId: aws.String("at-002"),
|
||||||
|
}
|
||||||
|
|
||||||
|
result := flattenAttachment(expanded)
|
||||||
|
|
||||||
|
if result == nil {
|
||||||
|
t.Fatal("expected result to have value, but got nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
if result["instance"] != nil {
|
||||||
|
t.Fatalf("expected instance to be nil, but got %s", result["instance"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestflattenStepAdjustments(t *testing.T) {
|
func TestflattenStepAdjustments(t *testing.T) {
|
||||||
expanded := []*autoscaling.StepAdjustment{
|
expanded := []*autoscaling.StepAdjustment{
|
||||||
&autoscaling.StepAdjustment{
|
&autoscaling.StepAdjustment{
|
||||||
|
|
Loading…
Reference in New Issue