mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #3167 from dwradcliffe/read_instance_role
provider/aws: read iam_instance_profile for instance and save to state
This commit is contained in:
commit
d937045afd
@ -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
Block a user