@@ -41,6 +41,7 @@ func ResourceIBMIAMTrustedProfilePolicy() *schema.Resource {
4141 "profile_id" : {
4242 Type : schema .TypeString ,
4343 Optional : true ,
44+ Computed : true ,
4445 Description : "UUID of Trusted Profile" ,
4546 ForceNew : true ,
4647 Deprecated : "This field is deprecated and will be removed starting with this 1.82.0 release. Please use iam_id field instead." ,
@@ -50,6 +51,7 @@ func ResourceIBMIAMTrustedProfilePolicy() *schema.Resource {
5051 "iam_id" : {
5152 Type : schema .TypeString ,
5253 Optional : true ,
54+ Computed : true ,
5355 Description : "IAM ID of Trusted Profile" ,
5456 ForceNew : true ,
5557 },
@@ -452,17 +454,15 @@ func resourceIBMIAMTrustedProfilePolicyCreate(d *schema.ResourceData, meta inter
452454 }
453455 if err != nil {
454456 if v , ok := d .GetOk ("profile_id" ); ok && v != nil {
455- profileIDUUID := v .(string )
456- d .SetId (fmt .Sprintf ("%s/%s" , profileIDUUID , policyID ))
457+ d .SetId (fmt .Sprintf ("%s/%s" , "iam-" + v .(string ), policyID ))
457458 } else if v , ok := d .GetOk ("iam_id" ); ok && v != nil {
458459 iamID := v .(string )
459460 d .SetId (fmt .Sprintf ("%s/%s" , iamID , policyID ))
460461 }
461462 return fmt .Errorf ("[ERROR] Error fetching trusted profile policy: %s" , err )
462463 }
463464 if v , ok := d .GetOk ("profile_id" ); ok && v != nil {
464- profileIDUUID := v .(string )
465- d .SetId (fmt .Sprintf ("%s/%s" , profileIDUUID , policyID ))
465+ d .SetId (fmt .Sprintf ("%s/%s" , "iam-" + v .(string ), policyID ))
466466 } else if v , ok := d .GetOk ("iam_id" ); ok && v != nil {
467467 iamID := v .(string )
468468 d .SetId (fmt .Sprintf ("%s/%s" , iamID , policyID ))
@@ -514,8 +514,12 @@ func resourceIBMIAMTrustedProfilePolicyRead(d *schema.ResourceData, meta interfa
514514 }
515515 if strings .HasPrefix (profileIDUUID , "iam-" ) {
516516 d .Set ("iam_id" , profileIDUUID )
517+ d .Set ("profile_id" , strings .TrimPrefix (profileIDUUID , "iam-" ))
518+ d .SetId (fmt .Sprintf ("%s/%s" , profileIDUUID , trustedProfilePolicyID ))
517519 } else {
518520 d .Set ("profile_id" , profileIDUUID )
521+ d .Set ("iam_id" , fmt .Sprintf ("iam-%s" , profileIDUUID ))
522+ d .SetId (fmt .Sprintf ("%s/%s" , fmt .Sprintf ("iam-%s" , profileIDUUID ), trustedProfilePolicyID ))
519523 }
520524
521525 roles , err := flex .GetRoleNamesFromPolicyResponse (* trustedProfilePolicy , d , meta )
@@ -569,22 +573,6 @@ func resourceIBMIAMTrustedProfilePolicyUpdate(d *schema.ResourceData, meta inter
569573 trustedProfilePolicyID := parts [1 ]
570574
571575 var iamID string
572- if v , ok := d .GetOk ("profile_id" ); ok && v != nil {
573- profileIDUUID := v .(string )
574-
575- iamClient , err := meta .(conns.ClientSession ).IAMIdentityV1API ()
576- if err != nil {
577- return err
578- }
579- getProfileIDOptions := iamidentityv1.GetProfileOptions {
580- ProfileID : & profileIDUUID ,
581- }
582- profileID , resp , err := iamClient .GetProfile (& getProfileIDOptions )
583- if err != nil {
584- return fmt .Errorf ("[ERROR] Error] Error getting trusted profile ID %s %s" , err , resp )
585- }
586- iamID = * profileID .IamID
587- }
588576 if v , ok := d .GetOk ("iam_id" ); ok && v != nil {
589577 iamID = v .(string )
590578 }
0 commit comments