Fix segmentation fault in "aws_api_gateway_base_path_mapping" resource (#8466)

It is possible for the `mapping.BasePath`, `mapping.RestApiId`, and
`mapping.Stage` to be nil when they have not been set for the
mapping.[1]  When this occurs a nil pointer is dereferenced and terraform
segmentation faults.

Here we remove the blind derefrences and trust in the behaviour of
(*ResourceData).Set() to handle the nil pointer safely.

[1] https://github.com/hashicorp/terraform/blob/master/vendor/github.com/aws/aws-sdk-go/service/apigateway/api.go#L4892-L4904
This commit is contained in:
Richard Clamp 2016-08-25 11:03:42 +01:00 committed by Paul Stack
parent c157a67085
commit 9be1ff5d53
1 changed files with 3 additions and 3 deletions

View File

@ -101,9 +101,9 @@ func resourceAwsApiGatewayBasePathMappingRead(d *schema.ResourceData, meta inter
return fmt.Errorf("Error reading Gateway base path mapping: %s", err)
}
d.Set("base_path", *mapping.BasePath)
d.Set("api_id", *mapping.RestApiId)
d.Set("stage_name", *mapping.Stage)
d.Set("base_path", mapping.BasePath)
d.Set("api_id", mapping.RestApiId)
d.Set("stage_name", mapping.Stage)
return nil
}