1
- use crate :: error:: { self , Result } ;
1
+ use crate :: error:: { self , Error , Result } ;
2
2
use aws_sdk_iam:: error:: SdkError as IamSdkError ;
3
3
use aws_sdk_ssm:: types:: { InstanceInformation , InstanceInformationStringFilter , Tag } ;
4
4
use log:: info;
@@ -40,15 +40,16 @@ pub async fn ensure_ssm_service_role(iam_client: &aws_sdk_iam::Client) -> Result
40
40
. assume_role_policy_document ( & assume_role_doc)
41
41
. send ( )
42
42
. await
43
- . context ( error:: CreateRoleSnafu {
44
- role_name : SSM_MANAGED_INSTANCE_SERVICE_ROLE_NAME ,
43
+ . map_err ( |source| Error :: CreateRole {
44
+ source : Box :: new ( source) ,
45
+ role_name : SSM_MANAGED_INSTANCE_SERVICE_ROLE_NAME . to_string ( ) ,
45
46
role_policy : assume_role_doc,
46
47
} ) ?;
47
48
}
48
49
e => {
49
- return Err ( error :: Error :: GetSSMRole {
50
+ return Err ( Error :: GetSSMRole {
50
51
role_name : SSM_MANAGED_INSTANCE_SERVICE_ROLE_NAME . to_string ( ) ,
51
- source : e ,
52
+ source : Box :: new ( e ) ,
52
53
} ) ;
53
54
}
54
55
}
@@ -61,9 +62,10 @@ pub async fn ensure_ssm_service_role(iam_client: &aws_sdk_iam::Client) -> Result
61
62
. policy_arn ( SSM_MANAGED_INSTANCE_POLICY_ARN )
62
63
. send ( )
63
64
. await
64
- . context ( error:: AttachRolePolicySnafu {
65
- role_name : SSM_MANAGED_INSTANCE_SERVICE_ROLE_NAME ,
66
- policy_arn : SSM_MANAGED_INSTANCE_POLICY_ARN ,
65
+ . map_err ( |source| Error :: AttachRolePolicy {
66
+ source : Box :: new ( source) ,
67
+ role_name : SSM_MANAGED_INSTANCE_SERVICE_ROLE_NAME . to_string ( ) ,
68
+ policy_arn : SSM_MANAGED_INSTANCE_POLICY_ARN . to_string ( ) ,
67
69
} ) ?;
68
70
69
71
Ok ( ( ) )
@@ -87,7 +89,9 @@ pub async fn create_ssm_activation(
87
89
)
88
90
. send ( )
89
91
. await
90
- . context ( error:: CreateSsmActivationSnafu { } ) ?;
92
+ . map_err ( |source| Error :: CreateSsmActivation {
93
+ source : Box :: new ( source) ,
94
+ } ) ?;
91
95
let activation_id = activations. activation_id . context ( error:: MissingSnafu {
92
96
what : "activation id" ,
93
97
from : "activations" ,
@@ -118,7 +122,9 @@ pub async fn wait_for_ssm_ready(
118
122
)
119
123
. send ( )
120
124
. await
121
- . context ( error:: GetManagedInstanceInfoSnafu { } ) ?;
125
+ . map_err ( |source| Error :: GetManagedInstanceInfo {
126
+ source : Box :: new ( source) ,
127
+ } ) ?;
122
128
if let Some ( info) = instance_info
123
129
. instance_information_list ( )
124
130
. iter ( )
0 commit comments