in source/Check_Status_RFC.py [0:0]
def lambda_handler(event, context):
# parse values passed to the function from the step function
try:
ams_app_id= event['app_account_id']
app_acct_role = event['app_acct_role']
member_account_session = get_session(
str(ams_app_id), str(app_acct_role), "check_rfc_status", ExternalId
)
except Exception as RFC_Load_Error:
print("Error loading configurations passed by the step function" + " "+ str(RFC_Load_Error))
sys.exit("Configurations were not loaded successfully")
try:
# get a session in the destination account
cm = member_account_session.client("amscm")
# get the RFC ID
rfcIdtemp = event['rfcId']
RFC_Status_Code=cm.get_rfc(RfcId=rfcIdtemp)
RFC_Status = (RFC_Status_Code['Rfc']['Status']['Name'])
RFC_Mode = (RFC_Status_Code['Rfc']['AutomationStatus']['Id'])
# Check status of the RFC and return back to the Step function
if RFC_Status == "Success":
jobStatus = "SUCCEEDED"
elif RFC_Status =="PendingApproval":
# Check if this is a manual RFC like MOO
if RFC_Mode == "Manual":
jobStatus ="MANUAL"
else:
jobStatus = "IN PROGRESS"
elif RFC_Status =="InProgress":
jobStatus = "IN PROGRESS"
elif RFC_Status in ("Failure","Rejected"):
jobStatus = "FAILED"
else:
RFC_Status_Code=cm.get_rfc(RfcId=rfcIdtemp)
RFC_Status = (RFC_Status_Code['Rfc']['Status']['Name'])
jobStatus=RFC_Status
return jobStatus
except Exception as AMS_Check_Error:
print("Error getting RFC status" + " "+ str(AMS_Check_Error))