GSA / grace-inventory

Lambda function to create an inventory report of AWS services as an Excel spreadsheet in an S3 bucket. Includes Terraform code to deploy it.
Other
14 stars 9 forks source link

How to increase verbosity? #38

Open mehrenreich opened 4 years ago

mehrenreich commented 4 years ago

I've implemented the module as shown in the examples (using 'self' as well as within the organization from a master account). All resources have been created successfully, but when I invoke the Lambda function either manually or via Cron scheduler, no report is created.

An error message is shown in the Cloudwatch logs, but nothing I can really work with. Is there a way to increase the verbosity and/ or enable DEBUG information?

START RequestId: 8771c388-99c9-4df8-bfd0-c6c456ef25be Version: $LATEST
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryAccounts
2020/02/14 09:25:35 github.com/GSA/grace-inventory/handler/inv.(*Inv).queryAccounts took 176.360813ms
2020/02/14 09:25:35 Sheet "Accounts" has completed
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryLoadBalancers
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).querySecurityGroups
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryDBSnapshots
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).querySubscriptions
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryParameters
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryInstances
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryKeyPairs
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryConfigRules
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).querySnapshots
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).querySubnets
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryVpcs
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryAddresses
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryKeys
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryImages
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryRoles
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).querySecrets
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryTopics
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryUsers
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryVaults
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryDBInstances
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryBuckets
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryGroups
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryPolicies
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryVolumes
2020/02/14 09:25:35 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryAlarms
2020/02/14 09:25:36 calling github.com/GSA/grace-inventory/handler/inv.(*Inv).queryStacks
2020/02/14 09:25:36 github.com/GSA/grace-inventory/handler/inv.(*Inv).queryRoles took 981.014396ms
2020/02/14 09:25:36 Sheet "Roles" has completed
2020/02/14 09:25:36 github.com/GSA/grace-inventory/handler/inv.(*Inv).queryLoadBalancers took 1.143413201s
unknown type: errorString
null
2020/02/14 09:25:37 Unknown sheet type: *elbv2.LoadBalancer
END RequestId: 8771c388-99c9-4df8-bfd0-c6c456ef25be
REPORT RequestId: 8771c388-99c9-4df8-bfd0-c6c456ef25be  Duration: 2535.63 ms    Billed Duration: 2600 ms    Memory Size: 128 MB Max Memory Used: 74 MB  Init Duration: 167.55 ms
briankfitzwater commented 4 years ago

[GSA/grace-inventory] How to increase verbosity? (Issue #38)

bryanlalexander commented 4 years ago

Hey Michael, this appears to be a bug in our typeToSheet method where it seems we're missing *elbv2.LoadBalancer. We have future intent on refactoring this project to remove the need for a such a function, however, we can get this resolved fairly quickly.

briankfitzwater commented 4 years ago

@mehrenreich Thanks for opening this ticket and adding the logs. We were able to identify the problem pretty quickly with the log data you provided and are working on a fix which is being tracked in Issue #39. I've added the enhancement tag to this issue and we are going to put this in our backlog. We're currently using Go's standard log package which doesn't have leveled logs. We're going to be looking at some alternative logging packages that provide optional logging levels.

bryanlalexander commented 4 years ago

@mehrenreich v0.1.4 should contain the fix for this bug, if you want to give that release a shot and see if it works better.

mehrenreich commented 4 years ago

Hi @bryanlalexander ,

thanks for the update! I modified my config a bit to make the new version work, now I run into a completely different error:

START RequestId: c6ee7f6d-c3e0-4b02-9c1e-73d5eb87b5a4 Version: $LATEST
fork/exec /var/task/grace-inventory-lambda: permission denied: PathError
null
END RequestId: c6ee7f6d-c3e0-4b02-9c1e-73d5eb87b5a4
REPORT RequestId: c6ee7f6d-c3e0-4b02-9c1e-73d5eb87b5a4  Duration: 1.12 ms   Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 30 MB  Init Duration: 1.57 ms

main.tf:

module "inventory" {
  source              = "github.com/GSA/grace-inventory?ref=v0.1.4"
  source_file         = "files/grace-inventory-lambda.zip"
  appenv              = "production"
  project_name        = "XXX"
}
inventory git:master ❯ tree                                                                                                                                                                                                                                                                         .
├── files
│   └── grace-inventory-lambda.zip
└── main.tf

1 directory, 2 files
mehrenreich commented 4 years ago

Hi @bryanlalexander,

after building the artefacts manually and not using the downloaded zip file, it works now! Now there are only some permission issues, but nothing you should take care about.

Thanks for your help!

bryanlalexander commented 4 years ago

Thanks for the update @mehrenreich, yeah I bet I screwed up the release process. We'll get the binary updated tomorrow when everyone is back in the office. The permission issues may be related to the terraform, if you're seeing particular commands that aren't being allowed during the execution of the lambda. Feel free to post any of those you think are related to issues in this repository.

briankfitzwater commented 4 years ago

@bryanlalexander I re-released v0.1.4 with a re-compiled binary.