1- use crate :: error:: { self , Result } ;
1+ use crate :: error:: { self , Error , Result } ;
22use aws_sdk_iam:: error:: SdkError as IamSdkError ;
33use aws_sdk_ssm:: types:: { InstanceInformation , InstanceInformationStringFilter , Tag } ;
44use log:: info;
@@ -40,15 +40,16 @@ pub async fn ensure_ssm_service_role(iam_client: &aws_sdk_iam::Client) -> Result
4040 . assume_role_policy_document ( & assume_role_doc)
4141 . send ( )
4242 . 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 ( ) ,
4546 role_policy : assume_role_doc,
4647 } ) ?;
4748 }
4849 e => {
49- return Err ( error :: Error :: GetSSMRole {
50+ return Err ( Error :: GetSSMRole {
5051 role_name : SSM_MANAGED_INSTANCE_SERVICE_ROLE_NAME . to_string ( ) ,
51- source : e ,
52+ source : Box :: new ( e ) ,
5253 } ) ;
5354 }
5455 }
@@ -61,9 +62,10 @@ pub async fn ensure_ssm_service_role(iam_client: &aws_sdk_iam::Client) -> Result
6162 . policy_arn ( SSM_MANAGED_INSTANCE_POLICY_ARN )
6263 . send ( )
6364 . 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 ( ) ,
6769 } ) ?;
6870
6971 Ok ( ( ) )
@@ -87,7 +89,9 @@ pub async fn create_ssm_activation(
8789 )
8890 . send ( )
8991 . await
90- . context ( error:: CreateSsmActivationSnafu { } ) ?;
92+ . map_err ( |source| Error :: CreateSsmActivation {
93+ source : Box :: new ( source) ,
94+ } ) ?;
9195 let activation_id = activations. activation_id . context ( error:: MissingSnafu {
9296 what : "activation id" ,
9397 from : "activations" ,
@@ -118,7 +122,9 @@ pub async fn wait_for_ssm_ready(
118122 )
119123 . send ( )
120124 . await
121- . context ( error:: GetManagedInstanceInfoSnafu { } ) ?;
125+ . map_err ( |source| Error :: GetManagedInstanceInfo {
126+ source : Box :: new ( source) ,
127+ } ) ?;
122128 if let Some ( info) = instance_info
123129 . instance_information_list ( )
124130 . iter ( )
0 commit comments