diff --git a/pkg/controller/iam/role/controller.go b/pkg/controller/iam/role/controller.go index aadaa07bd1..2d1e1b21f2 100644 --- a/pkg/controller/iam/role/controller.go +++ b/pkg/controller/iam/role/controller.go @@ -137,7 +137,10 @@ func (e *external) Observe(ctx context.Context, mgd resource.Managed) (managed.E return managed.ExternalObservation{ ResourceExists: true, ResourceUpToDate: upToDate, - Diff: diff, + ConnectionDetails: managed.ConnectionDetails{ + "arn": []byte(cr.Status.AtProvider.ARN), + }, + Diff: diff, }, nil } diff --git a/pkg/controller/iam/role/controller_test.go b/pkg/controller/iam/role/controller_test.go index 0321358043..a587176a9b 100644 --- a/pkg/controller/iam/role/controller_test.go +++ b/pkg/controller/iam/role/controller_test.go @@ -44,6 +44,7 @@ var ( // an arbitrary managed resource unexpectedItem resource.Managed roleName = "some arbitrary name" + arn = "some arn" description = "some description" policy = `{ "Version": "2012-10-17", @@ -76,6 +77,10 @@ func withRoleName(s *string) roleModifier { return func(r *v1beta1.Role) { meta.SetExternalName(r, *s) } } +func withArn(s string) roleModifier { + return func(r *v1beta1.Role) { r.Status.AtProvider.ARN = s } +} + func withPolicy() roleModifier { return func(r *v1beta1.Role) { p, err := awsclient.CompactAndEscapeJSON(policy) @@ -136,7 +141,9 @@ func TestObserve(t *testing.T) { iam: &fake.MockRoleClient{ MockGetRole: func(ctx context.Context, input *awsiam.GetRoleInput, opts []func(*awsiam.Options)) (*awsiam.GetRoleOutput, error) { return &awsiam.GetRoleOutput{ - Role: &awsiamtypes.Role{}, + Role: &awsiamtypes.Role{ + Arn: awsclient.String(arn), + }, }, nil }, }, @@ -145,10 +152,14 @@ func TestObserve(t *testing.T) { want: want{ cr: role( withRoleName(&roleName), + withArn(arn), withConditions(xpv1.Available())), result: managed.ExternalObservation{ ResourceExists: true, ResourceUpToDate: true, + ConnectionDetails: map[string][]byte{ + "arn": []byte(arn), + }, }, }, },