Skip to content

Commit

Permalink
Merge pull request #14992 from hashicorp/b-fix-modify-instance-attribute
Browse files Browse the repository at this point in the history
provider/aws: Fix ModifyInstanceAttribute on new instances
  • Loading branch information
grubernaut authored Jun 1, 2017
2 parents 4e878aa + acb38e3 commit 802eae3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions builtin/providers/aws/resource_aws_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,14 +815,19 @@ func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
// SourceDestCheck can only be modified on an instance without manually specified network interfaces.
// SourceDestCheck, in that case, is configured at the network interface level
if _, ok := d.GetOk("network_interface"); !ok {
if d.HasChange("source_dest_check") || d.IsNewResource() {
// SourceDestCheck can only be set on VPC instances // AWS will return an error of InvalidParameterCombination if we attempt

// If we have a new resource and source_dest_check is still true, don't modify
sourceDestCheck := d.Get("source_dest_check").(bool)

if d.HasChange("source_dest_check") || d.IsNewResource() && !sourceDestCheck {
// SourceDestCheck can only be set on VPC instances
// AWS will return an error of InvalidParameterCombination if we attempt
// to modify the source_dest_check of an instance in EC2 Classic
log.Printf("[INFO] Modifying `source_dest_check` on Instance %s", d.Id())
_, err := conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{
InstanceId: aws.String(d.Id()),
SourceDestCheck: &ec2.AttributeBooleanValue{
Value: aws.Bool(d.Get("source_dest_check").(bool)),
Value: aws.Bool(sourceDestCheck),
},
})
if err != nil {
Expand Down

0 comments on commit 802eae3

Please sign in to comment.