AWS Cloud discovery failing for pattern "Amazon AWS Datacenter discovery", Step "Get AWS regions", Error: JAVASCRIPT_CODE_FAILURE: java.util.NoSuchElementException: No value present

kushal_dangare
Tera Expert

Hi,

AWS Cloud discovery is giving below error

Pattern: Amazon AWS Datacenter discovery

Step: Get AWS regions

Error: Exception occurred while executing operation Cloud REST - add response to context. Custom operation Failed to run script due to the following error: JAVASCRIPT_CODE_FAILURE: java.util.NoSuchElementException: No value present. Custom operation Failed to run script due to the following error: JAVASCRIPT_CODE_FAILURE: java.util.NoSuchElementException: No value present

 

 

Complete Log:

Discovery Log
2022-02-27 05:31:26: Task is running on MID server Axxxxxxxxxxxxxx
2022-02-27 05:31:26: setAttribute(cmdb_ci_aws_datacenter,[{}])
2022-02-27 05:31:26: setAttribute(cmdb_ci_aws_datacenter,[{}])
Pre Pattern Execution
2022-02-27 05:31:26: Getting pre pattern execution data generated by script.
2022-02-27 05:31:26: setAttribute(service_account,[{account_id=0xxxxxxxxx, name=axxxxxxxxxxxxxxxx, datacenter_type=cmdb_ci_aws_datacenter}])
2022-02-27 05:31:26: setAttribute(pattern_runtime_mode,horizontal)
Selecting Pattern for Execution
2022-02-27 05:31:26: Pattern: Amazon AWS Datacenter discovery
2022-02-27 05:31:26: setAttribute(pattern,Amazon AWS Datacenter discovery)
Create Service Account From Input Params
2022-02-27 05:31:26: Library 'Create Service Account From Input Params' executing
Create service account table if doesn't exist
2022-02-27 05:31:26: Step condition is false. step not executed. False Condition(s): [($⁠{service_account} : value=[{account_id=0xxxxxxx, name=axxxxxxxxx, datacenter_type=cmdb_ci_aws_datacenter}]) IS EMPTY ]
2022-02-27 05:31:26: Execution time: 0 ms
Add credentials and account ID to service account table if don't exist
2022-02-27 05:31:26: Step condition is false. step not executed. False Condition(s): [($⁠{service_account[1].account_id} : value=0xxxxxxxx) IS EMPTY ]
2022-02-27 05:31:26: Execution time: 0 ms
Populate cmdb_ci_cloud_service_account
2022-02-27 05:31:26: setAttribute(cmdb_ci_cloud_service_account,[{name=axxxxxxxxxx, account_id=0xxxxxxx, datacenter_type=cmdb_ci_aws_datacenter, object_id=null}])
2022-02-27 05:31:26: Execution time: 0 ms
Get AWS Host
2022-02-27 05:31:26: setAttribute(awsHost,amazonaws.com)
2022-02-27 05:31:26: Execution time: 0 ms
Set Query URL
2022-02-27 05:31:26: setAttribute(amazonQueryURL,https://ec2.amazonaws.com/?Action=DescribeRegions&Version=2016-11-15)
2022-02-27 05:31:26: Execution time: 0 ms
Get AWS regions
2022-02-27 05:31:26: setAttribute(headers,)
2022-02-27 05:31:26: setAttribute(method,GET)
2022-02-27 05:31:26: setAttribute(formatted,true)
2022-02-27 05:31:26: setAttribute(arrayName,rest_resp_region)
2022-02-27 05:31:26: setAttribute(body,)
2022-02-27 05:31:26: setAttribute(url,https://ec2.amazonaws.com/?Action=DescribeRegions&Version=2016-11-15)
2022-02-27 05:31:26: setAttribute(body,null)
2022-02-27 05:31:26: setAttribute(headers,null)
2022-02-27 05:31:26: Exception occurred while executing operation Cloud REST - add response to context. Custom operation Failed to run script due to the following error: JAVASCRIPT_CODE_FAILURE: java.util.NoSuchElementException: No value present. Custom operation Failed to run script due to the following error: JAVASCRIPT_CODE_FAILURE: java.util.NoSuchElementException: No value present
2022-02-27 05:31:26: Execution time: 31 ms
Verify if we have any valid response
2022-02-27 05:31:26: Execution time: 0 ms
Target Cleanup
2022-02-27 05:31:26: Skipped file cleaning on target. In order to activate this behavior, please set "mid.sa.cleanup.clean_files_on_target" MID property
Check Processing Success
2022-02-26 21:31:27: Identification Engine: Discovery status is FAILURE, Identification sections in pattern failed: section: AWS Datacenter identification, error: Match step predicate is not matched. Failed Condition(s): [($⁠{rest_resp_region} : value=) IS NOT EMPTY ] .

 

6 REPLIES 6

Anshu_Anand_
Kilo Sage
Kilo Sage

Get AWS regions", Error: JAVASCRIPT_CODE_FAILURE: java.util.NoSuchElementException: No value present

 
 
It means discovery is not able to retrieve the AWS regions due to not enough privilege's provided to the IAM account. also check the aws credentials and test it when creating discovery schedule. 
 
Also check the AWS setup provided by servicenow
 
Hope its helpful
Regards,
Anshu

I am not using credentials. We have configured as mentioned in below link:

https://docs.servicenow.com/bundle/sandiego-it-operations-management/page/product/it-operations-management/task/aws-trusted-credential-less.html

We are able to validate the connection while creating cloud discovery.

So after you click on discover data center, are you able to see all the data centers loaded like below image

 

find_real_file.png

Regards,
Anshu

Yes, I see 17 datacenters