Added client error as error and formatted error message in site as alert-warning

This commit is contained in:
Shay Nehmad 2019-04-16 20:18:37 +03:00
parent e4e2948941
commit a38b5cf360
2 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import json
from botocore.exceptions import NoCredentialsError
from botocore.exceptions import NoCredentialsError, ClientError
from flask import request, jsonify, make_response
import flask_restful
@ -32,6 +32,10 @@ class RemoteRun(flask_restful.Resource):
# Probably, role hasn't been defined.
resp['error'] = e.message
return jsonify(resp)
except ClientError as e:
# Probably, role doesn't allow SSM.
resp['error'] = e.message
return jsonify(resp)
return jsonify(resp)
return {}

View File

@ -473,10 +473,10 @@ class RunMonkeyPageComponent extends AuthComponent {
{
this.state.isErrorWhileCollectingAwsMachines ?
<div style={{'marginTop': '1em'}}>
<p>
Error while collecting AWS machine data. Error message: {this.state.awsMachineCollectionErrorMsg}
Are you sure you've set the correct role? Not sure what this is? Not seeing your AWS EC2 instances? <a href="https://github.com/guardicore/monkey/wiki/Monkey-Island:-Running-the-monkey-on-AWS-EC2-instances">Read the documentation</a>!
<p class="alert alert-warning">
Error while collecting AWS machine data. Error message: <code>{this.state.awsMachineCollectionErrorMsg}</code><br/>
Are you sure you've set the correct role on your Island AWS machine?<br/>
Not sure what this is? <a href="https://github.com/guardicore/monkey/wiki/Monkey-Island:-Running-the-monkey-on-AWS-EC2-instances">Read the documentation</a>!
</p>
</div>
: