read iam_instance_profile and save to state
This commit is contained in:
parent
7d142134f2
commit
0b88177cf0
|
@ -469,6 +469,13 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("public_ip", instance.PublicIpAddress)
|
||||
d.Set("private_dns", instance.PrivateDnsName)
|
||||
d.Set("private_ip", instance.PrivateIpAddress)
|
||||
|
||||
if instance.IamInstanceProfile != nil {
|
||||
d.Set("iam_instance_profile", iamInstanceProfileArnToName(instance.IamInstanceProfile.Arn))
|
||||
} else if _, ok := d.GetOk("iam_instance_profile"); ok {
|
||||
d.Set("iam_instance_profile", "")
|
||||
}
|
||||
|
||||
if len(instance.NetworkInterfaces) > 0 {
|
||||
d.Set("subnet_id", instance.NetworkInterfaces[0].SubnetId)
|
||||
} else {
|
||||
|
@ -1070,3 +1077,7 @@ func awsTerminateInstance(conn *ec2.EC2, id string) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func iamInstanceProfileArnToName(arn *string) string {
|
||||
return strings.Split(*arn, "/")[1]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue