aws-solutions / workload-discovery-on-aws

Workload Discovery on AWS is a solution to visualize AWS Cloud workloads. With it you can build, customize, and share architecture diagrams of your workloads based on live data from AWS. The solution maintains an inventory of the AWS resources across your accounts and regions, mapping their relationships and displaying them in the user interface.
https://aws.amazon.com/solutions/implementations/workload-discovery-on-aws/
Apache License 2.0
727 stars 88 forks source link

workload discovery logs. #529

Closed mrpackethead closed 4 months ago

mrpackethead commented 5 months ago

I'm Getting this error in my /ecs/workload-discovery logs. I'm not seeing any accounts being Imported. I'm running in an organisations mode.

{ "msg": "Cannot read properties of undefined (reading 'AllAwsRegions')", "stack": "TypeError: Cannot read properties of undefined (reading 'AllAwsRegions')\n at /code/src/lib/apiClient/index.js:143:56\n at Array.map ()\n at getOrgAccounts (/code/src/lib/apiClient/index.js:134:10)\n at async Object.getAccounts (/code/src/lib/utils.js:174:24)\n at async Promise.all (index 0)\n at async discoverResources (/code/src/lib/index.js:19:69)\n at async discover (/code/src/index.js:14:3)", "level": "error", "message": "Error in Discovery process.", "timestamp": "2024-06-19T06:46:23.317Z" }

@AWS folks.. case number 171874402100195

svozza commented 5 months ago

Looks like a problem with getting information about the Config aggregator. When you deployed, did you provide the name of an existing aggregator at deployment? Can you run the following CLI command: aws configservice describe-configuration-aggregators --configuration-aggregator-names <your-aggregator-name> and paste the output here?

mrpackethead commented 5 months ago

[cloudshell-user@ip-10-132-68-168 ~]$ aws configservice describe-configuration-aggregators --configuration-aggregator-names name { "ConfigurationAggregators": [ { "ConfigurationAggregatorName": "name", "ConfigurationAggregatorArn": "arn:aws:config:ap-southeast-2:9xxxxxx0:config-aggregator/config-aggregator-utxgcwgw", "AccountAggregationSources": [ { "AccountIds": [ "xxxxx" ], "AllAwsRegions": false, "AwsRegions": [ "ap-southeast-2" ] } ], "CreationTime": "2024-06-18T00:27:07.889000+00:00", "LastUpdatedTime": "2024-06-18T00:27:07.890000+00:00" } ] } [cloudshell-user@ip-10-132-68-168 ~]$

mrpackethead commented 5 months ago

I replaed 'name' for aggreagator name, and can confirm it was ok. ( just to obfiscate real accounts ) lookign at the order of how i deployed things, it may be possible that the config aggregator was not operational before the solution was deployed.

svozza commented 5 months ago

As soon as the aggregator became operational the discovery process should have picked it up on its next run. Can you go the discovery process logs and search for a line in the logs with the following string: Organization source info and paste that line in here. The steps to find the ECS logs are:

To retrieve the logs for the discovery component:

  1. Sign in to the AWS Management Console in the account you deployed Workload Discovery on AWS in.
  2. Choose Services.
  3. From the collection of services, choose CloudWatch.
  4. Under the Log section, select Log Groups.
  5. Search for the log group /ecs/workload-discovery-task.
  6. Select the latest Log Stream tab.
mrpackethead commented 5 months ago

{ "level": "info", "message": "Organization source info.", "timestamp": "2024-06-19T10:46:28.081Z" }

mrpackethead commented 5 months ago

Its crashing out on this code.

https://github.com/aws-solutions/workload-discovery-on-aws/blob/b78b70db3e92debb5b0bb15209b17db6868e7908/source/backend/discovery/src/lib/apiClient/index.js#L143

svozza commented 5 months ago

It looks like the aggregator you've created is not an an organization-wide aggregator. Either create a new aggregator of the required type or the just set the ConfigAggregatorName CFN paramter in the WD template to be blank and one will be created for you.

mrpackethead commented 4 months ago

ok, i've created a new one, that is an org-wide aggreagtor and its not erroring now. Just have to see how the collection is going.

mrpackethead commented 4 months ago

Seems to be doing the job. Thanks for your help.

svozza commented 4 months ago

Nice! I think we can make the error message here better, it shouldn't fail silently if that field is missing so I've added that to the backlog.

svozza commented 4 months ago

I'm going to leave this open until I've released the the change to the error message

mrpackethead commented 4 months ago

Yes, helpful error messages really help..

svozza commented 4 months ago

This has been fixed in v2.1.9 that was released yesterday.