Skip to content

Commit

Permalink
r/aws_launch_configuration: support security groups and user data for…
Browse files Browse the repository at this point in the history
… import
  • Loading branch information
xiaowei.wang committed Apr 9, 2018
1 parent dddc588 commit f9eac46
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion aws/import_aws_launch_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestAccAWSLaunchConfiguration_importBasic(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"associate_public_ip_address", "user_data"},
ImportStateVerifyIgnore: []string{"associate_public_ip_address"},
},
},
})
Expand Down
12 changes: 10 additions & 2 deletions aws/resource_aws_launch_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ func resourceAwsLaunchConfigurationRead(d *schema.ResourceData, meta interface{}
}

lc := describConfs.LaunchConfigurations[0]
log.Printf("[DEBUG] launch configuration output: %s", lc)

d.Set("key_name", lc.KeyName)
d.Set("image_id", lc.ImageId)
Expand All @@ -526,11 +527,18 @@ func resourceAwsLaunchConfigurationRead(d *schema.ResourceData, meta interface{}
d.Set("ebs_optimized", lc.EbsOptimized)
d.Set("spot_price", lc.SpotPrice)
d.Set("enable_monitoring", lc.InstanceMonitoring.Enabled)
d.Set("security_groups", lc.SecurityGroups)
d.Set("associate_public_ip_address", lc.AssociatePublicIpAddress)
if err := d.Set("security_groups", flattenStringList(lc.SecurityGroups)); err != nil {
return fmt.Errorf("error setting security_groups: %s", err)
}
if aws.StringValue(lc.UserData) != "" {
d.Set("user_data", userDataHashSum(*lc.UserData))
}

d.Set("vpc_classic_link_id", lc.ClassicLinkVPCId)
d.Set("vpc_classic_link_security_groups", lc.ClassicLinkVPCSecurityGroups)
if err := d.Set("vpc_classic_link_security_groups", flattenStringList(lc.ClassicLinkVPCSecurityGroups)); err != nil {
return fmt.Errorf("error setting vpc_classic_link_security_groups: %s", err)
}

if err := readLCBlockDevices(d, lc, ec2conn); err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions aws/resource_aws_launch_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ func TestAccAWSLaunchConfiguration_withVpcClassicLink(t *testing.T) {
testAccCheckAWSSecurityGroupExists("aws_security_group.foo", &group),
),
},
{
ResourceName: "aws_launch_configuration.foo",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down

0 comments on commit f9eac46

Please sign in to comment.