From 8d5fe931522105ed2791c5c4b88c4a72c1122638 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Tue, 4 Aug 2015 06:09:47 -0500 Subject: [PATCH] conditionally set InstanceInitiatedShutdownBehavior --- builtin/providers/aws/resource_aws_instance.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index 8d3c24e1f..c04f0ceb5 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -150,7 +150,6 @@ func resourceAwsInstance() *schema.Resource { "instance_initiated_shutdown_behavior": &schema.Schema{ Type: schema.TypeString, Optional: true, - Default: "stop", }, "monitoring": &schema.Schema{ @@ -922,11 +921,14 @@ func buildAwsInstanceOpts( conn := meta.(*AWSClient).ec2conn opts := &awsInstanceOpts{ - DisableAPITermination: aws.Bool(d.Get("disable_api_termination").(bool)), - EBSOptimized: aws.Bool(d.Get("ebs_optimized").(bool)), - ImageID: aws.String(d.Get("ami").(string)), - InstanceType: aws.String(d.Get("instance_type").(string)), - InstanceInitiatedShutdownBehavior: aws.String(d.Get("instance_initiated_shutdown_behavior").(string)), + DisableAPITermination: aws.Bool(d.Get("disable_api_termination").(bool)), + EBSOptimized: aws.Bool(d.Get("ebs_optimized").(bool)), + ImageID: aws.String(d.Get("ami").(string)), + InstanceType: aws.String(d.Get("instance_type").(string)), + } + + if v := d.Get("instance_initiated_shutdown_behavior").(string); v != "" { + opts.InstanceInitiatedShutdownBehavior = aws.String(v) } opts.Monitoring = &ec2.RunInstancesMonitoringEnabled{