trek10inc / awsets

A utility for crawling an AWS account and exporting all its resources for further analysis.
MIT License
205 stars 25 forks source link

Only empty results are returned #3

Closed jrake-revelant closed 4 years ago

jrake-revelant commented 4 years ago

awsets list --regions eu-central-1 -o all.json --include ec2 yields an empty file:

❯ cat all.json
[]%
``

Verbose output:

❯ awsets list --regions eu-central-1 -o all.json --include ec2 -v regions: [eu-central-1] resource types: [ec2/eip ec2/flowlog ec2/image ec2/instance ec2/internetgateway ec2/keypair ec2/launchtemplate ec2/natgateway ec2/networkacl ec2/networkinterface ec2/routetable ec2/securitygroup ec2/snapshot ec2/subnet ec2/transitgateway ec2/volume ec2/vpc ec2/vpcpeering ec2/vpngateway] querying 0 combinations 9: finished worker 1: finished worker 2: finished worker 0: finished worker 7: finished worker 3: finished worker 4: finished worker 6: finished worker 5: finished worker 8: finished worker



I double checked and `aws ec2 describe-instances` works as expected. What could be the issue?
jcarter3 commented 4 years ago

can you do a awsets version and tell me what version is being used here? this was broke in the first release but should have been fixed after. If not, I'll have to investigate further

bciceron commented 4 years ago

same problem here using v0.2.0

$ go get github.com/trek10inc/awsets/cmd/awsets go: downloading github.com/trek10inc/awsets/cmd/awsets v0.0.0-20200908175407-c1723137ba70 go: downloading github.com/trek10inc/awsets v0.2.0 go: github.com/trek10inc/awsets/cmd/awsets upgrade => v0.0.0-20200908175407-c1723137ba70 go: downloading github.com/trek10inc/awsets v0.1.0 go: downloading github.com/emicklei/dot v0.11.0 go: downloading github.com/urfave/cli/v2 v2.2.0 go: downloading go.etcd.io/bbolt v1.3.5 go: downloading github.com/aws/aws-sdk-go-v2 v0.24.0 go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d go: downloading golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 go: downloading github.com/russross/blackfriday/v2 v2.0.1 go: downloading github.com/fatih/structs v1.1.0 go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0

$ awsets version awsets - version: dev commit: none date: unknown

but the cache does not seem empty: -rw-r--r-- 1 me staff 32768 Sep 8 18:32 .awsets_cache

$ awsets list -v regions: [ap-south-1 eu-west-2 ap-southeast-1 ap-southeast-2 us-east-2 eu-west-3 us-west-2 eu-west-1 ap-northeast-2 ca-central-1 eu-central-1 us-east-1 eu-north-1 ap-northeast-1 sa-east-1 us-west-1] resource types: [accessanalyzer/analyzer acm/certificate apig/apikey apig/authorizer apig/basepathmapping apig/deployment apig/domainname apig/model apig/resource apig/restapi apig/stage apig/usageplan apig/usageplankey apigv2/api apigv2/apimapping apigv2/authorizer apigv2/deployment apigv2/domainname apigv2/integration appmesh/mesh appmesh/route appmesh/virtualnode appmesh/virtualrouter appmesh/virtualservice appsync/apikey appsync/datasource appsync/graphqlapi athena/namedquery athena/workgroup autoscaling/group autoscaling/launchconfig autoscaling/lifecyclehook autoscaling/policy autoscaling/scheduledaction backup/plan backup/selection backup/vault batch/computeenvironment batch/jobdefinition batch/jobqueue budgets/budget cloud9/environment cloudformation/stack cloudformation/stackset cloudfront/distribution cloudfront/originaccessidentity cloudfront/streamingdistribution cloudtrail/trail cloudwatch/alarm cloudwatch/dashboard codebuild/project codecommit/repository codepipeline/pipeline codepipeline/webhook cognito/userpool cognito/userpoolclient cognito/userpoolgroup cognito/userpoolidentityprovider cognito/userpoolresourceserver config/aggregationauthorizer config/configurationaggregator config/configurationrecorder config/deliverychannel config/rule dax/parametergroup dax/subnetgroup ddb/table dms/endpoint dms/replicationinstance dms/replicationsubnetgroup dms/replicationtask docdb/cluster docdb/instance docdb/parametergroup docdb/subnetgroup ec2/eip ec2/flowlog ec2/image ec2/instance ec2/internetgateway ec2/keypair ec2/launchtemplate ec2/natgateway ec2/networkacl ec2/networkinterface ec2/routetable ec2/securitygroup ec2/snapshot ec2/subnet ec2/transitgateway ec2/volume ec2/vpc ec2/vpcpeering ec2/vpngateway ecr/repository ecs/cluster ecs/service ecs/task ecs/taskdefinition efs/filesystem efs/mounttarget eks/cluster elasticache/cluster elasticache/parametergroup elasticache/replicationgroup elasticache/securitygroup elasticache/snapshot elasticache/subnetgroup elasticbeanstalk/application elasticbeanstalk/environment elasticsearch/domain elb/loadbalancer elbv2/listener elbv2/loadbalancer elbv2/targetgroup emr/cluster emr/instancefleetconfig emr/instancegroupconfig emr/securityconfiguration events/eventbus events/rule firehose/stream fsx/backup fsx/filesystem glue/database glue/table greengrass/connectordefinition greengrass/connectordefinitionversion greengrass/coredefinition greengrass/coredefinitionversion greengrass/devicedefinition greengrass/devicedefinitionversion greengrass/functiondefinition greengrass/functiondefinitionversion greengrass/group greengrass/groupversion greengrass/loggerdefinition greengrass/resourcedefinition greengrass/resourcedefinitionversion greengrass/subscriptiondefinition greengrass/subscriptiondefinitionversion iam/group iam/instanceprofile iam/policy iam/role iam/user iot/cacertificate iot/certificate iot/policy iot/thing iot/thinggroup iot/thingtype iot/topicrule kafka/cluster kinesis/stream kms/alias kms/key lambda/alias lambda/eventsourcemapping lambda/function lambda/layer lambda/layerversion lambda/version logs/loggroup logs/metricfilter logs/subsciptionfilter mq/broker mq/brokerconfiguration neptune/dbcluster neptune/dbclusterparametergroup neptune/dbclustersnapshot neptune/dbinstance neptune/dbparametergroup neptune/dbsubnetgroup qldb/ledger rds/dbcluster rds/dbclusterparametergroup rds/dbclustersnapshot rds/dbinstance rds/dbparametergroup rds/dbsnapshot rds/dbsubnetgroup redshift/cluster redshift/parametergroup redshift/securitygroup redshift/snapshot redshift/subnetgroup route53/healthcheck route53/hostedzone route53/recordset s3/bucket secretmanager/secret servicecatalog/acceptedportfolioshare servicecatalog/portfolio sns/subscription sns/topic sqs/queue ssm/document ssm/parameter stepfunction/statemachine waf/bytematchset waf/ipset waf/rule waf/sizeconstraintset waf/sqlinjectionmatchset waf/webacl waf/xssmatchset wafregional/bytematchset wafregional/geomatchset wafregional/ipset wafregional/ratebasedrule wafregional/regexpatternset wafregional/rule wafregional/sizeconstraintset wafregional/sqlinjectionmatchset wafregional/webacl wafregional/xssmatchset] querying 0 combinations 2: finished worker 4: finished worker 5: finished worker 1: finished worker 6: finished worker 9: finished worker 0: finished worker 3: finished worker 8: finished worker 7: finished worker []

jcarter3 commented 4 years ago

I've narrowed down the problem, trying to come up with the "right" way to fix it. Installs done via go get are broke, but the distributed binaries are working. The issue is in the go.mod file, specifically these 2 lines:

https://github.com/trek10inc/awsets/blob/master/cmd/awsets/go.mod#L6 https://github.com/trek10inc/awsets/blob/master/cmd/awsets/go.mod#L14

When building the binaries, the replace directive makes sure the CLI build always uses the latest "library" portion of the code, and so overrides the v0.1.0 version of awsets that is specified on Line 6. When doing a go get, the replace doesn't happen and it's pulling in the old/broke version of the library.

jcarter3 commented 4 years ago

I came across this which seems to be the root of the problem: https://github.com/golang/go/issues/30354

In the short term, it looks like my options are to either:

In the short term I'll likely do the first one while exploring the second, but I'm open to other ideas as well.

jcarter3 commented 4 years ago

I've added support for it to be installed via Homebrew:

brew tap trek10inc/tap
brew install awsets

and also updated the Readme to have "build from source" instructions to get around the current issue. I'll mark this as closed for now.