in src/mount_efs/__init__.py [0:0]
def publish_cloudwatch_log(cloudwatchlog_agent, message):
if not cloudwatchlog_agent or not cloudwatchlog_agent.get("client"):
return False
token = get_log_stream_next_token(cloudwatchlog_agent)
try:
cloudwatch_put_log_events_helper(cloudwatchlog_agent, message, token)
except ClientError as e:
exception = e.response["Error"]["Code"]
if exception == "InvalidSequenceTokenException":
logging.debug("The sequence token is not valid, %s" % e.response)
return False
elif exception == "InvalidParameterException":
logging.debug(
"One of the parameter to put log events is not valid, %s" % e.response
)
return False
elif exception == "DataAlreadyAcceptedException":
logging.debug("The event %s was already logged, %s" % (message, e.response))
return False
elif exception == "UnrecognizedClientException":
logging.debug(
"The most likely cause is an invalid AWS access key ID or secret Key, %s"
% e.response
)
return False
elif exception == "ResourceNotFoundException":
logging.error(
"Either log group %s or log stream %s does not exist, %s"
% (
cloudwatchlog_agent.get("log_group_name"),
cloudwatchlog_agent.get("log_stream_name"),
e.response,
)
)
return False
else:
logging.debug("Unexpected error: %s" % e)
return False
except NoCredentialsError as e:
logging.warning("Credentials are not properly configured, %s" % e)
return False
except EndpointConnectionError as e:
logging.warning("Could not connect to the endpoint, %s" % e)
return False
except Exception as e:
logging.warning("Unknown error, %s." % e)
return False
return True