@@ -180,11 +180,11 @@ def __add_metric_dimensions(self, name, unit, value, common_dims, dims):
180180 metric_dims .update (dim )
181181 self .dimensions .append (metric_dims )
182182
183- def send (self , verbose ):
183+ def send (self , verbose , awsProfile ):
184184 boto_debug = 2 if verbose else 0
185185
186186 # TODO add timeout
187- conn = boto .ec2 .cloudwatch .connect_to_region (self .region ,
187+ conn = boto .ec2 .cloudwatch .connect_to_region (self .region , profile_name = awsProfile ,
188188 debug = boto_debug )
189189
190190 if not conn :
@@ -344,6 +344,9 @@ def config_parser():
344344 parser .add_argument ('--version' ,
345345 action = 'store_true' ,
346346 help = 'Displays the version number and exits.' )
347+ parser .add_argument ('--aws-profile-name' ,
348+ action = 'store' ,
349+ help = 'Use AWS profile of this name when posting to CloudWatch.' )
347350
348351 return parser
349352
@@ -579,12 +582,17 @@ def main():
579582 if args .verbose :
580583 print ('Request:\n ' + str (metrics ))
581584
585+ # Check for AWS profile
586+ awsProfile = None
587+ if args .aws_profile_name :
588+ awsProfile = args .aws_profile_name
589+
582590 if args .verify :
583591 if not args .from_cron :
584592 print ('Verification completed successfully. '
585593 'No actual metrics sent to CloudWatch.' )
586594 else :
587- metrics .send (args .verbose )
595+ metrics .send (args .verbose , awsProfile )
588596 if not args .from_cron :
589597 print ('Successfully reported metrics to CloudWatch.' )
590598 except Exception as e :
0 commit comments