snyk / driftctl

Detect, track and alert on infrastructure drift
Apache License 2.0
2.46k stars 155 forks source link

driftctl crashes with only-managed option #1552

Closed ghost closed 1 year ago

ghost commented 2 years ago

Description I'm getting an error when run scan with --only-managed

$ driftctl scan -f tfstate+s3://omitted --only-managed
Scanned states (1)
error scanning resource aws_cloudformation_stack.arn:aws:cloudformation:us-west-2:_omitted_:stack/amazon-ecs-cli-setup-ec2-nwg-ecs-poc/908ccc50-0b6d-11ec-9d54-06e586ba9c43: template body contains an invalid JSON or YAML: invalid character ':' after array element
$ driftctl scan -f tfstate+s3://omitted --only-managed
panic: rpc error: code = Canceled desc = context canceled

goroutine 1 [running]:
github.com/hashicorp/terraform/plugin.(*GRPCProvider).getSchema(0x14000390c80)
    github.com/hashicorp/terraform@v0.14.0/plugin/grpc_provider.go:80 +0x2b4
github.com/hashicorp/terraform/plugin.(*GRPCProvider).Configure(0x14000390c80, {{0x0, 0x0}, {{{0x106985b28, 0x1400022e490}}, {0x106457300, 0x1400021ec00}}})
    github.com/hashicorp/terraform@v0.14.0/plugin/grpc_provider.go:289 +0x64
github.com/snyk/driftctl/pkg/remote/terraform.(*TerraformProvider).configure(0x14000551d40, {0x140000420d3, 0x9})
    github.com/snyk/driftctl/pkg/remote/terraform/provider.go:126 +0x328
github.com/snyk/driftctl/pkg/remote/terraform.(*TerraformProvider).Init(0x14000551d40)
    github.com/snyk/driftctl/pkg/remote/terraform/provider.go:75 +0x148
github.com/snyk/driftctl/pkg/remote/aws.Init({0x14000044930?, 0x12f50e0b8?}, 0x140003840f0, 0x1400019c020, 0x14000088020, {0x106984fc8?, 0x140006c0050?}, 0x105c809b0?, {0x106975958?, 0x1400022fde0}, ...)
    github.com/snyk/driftctl/pkg/remote/aws/init.go:36 +0x80
github.com/snyk/driftctl/pkg/remote.Activate({0x105c864ff?, 0x14000000005?}, {0x14000044930?, 0x1?}, 0x1?, 0x106240a00?, 0x1400059f358?, {0x106984fc8?, 0x140006c0050?}, 0x105c91efb?, ...)
    github.com/snyk/driftctl/pkg/remote/remote.go:41 +0x98
github.com/snyk/driftctl/pkg/cmd.scanRun(0x14000238780)
    github.com/snyk/driftctl/pkg/cmd/scan.go:272 +0x4c4
github.com/snyk/driftctl/pkg/cmd.NewScanCmd.func2(0x1400039a000?, {0x140002cfc20?, 0x3?, 0x3?})
    github.com/snyk/driftctl/pkg/cmd/scan.go:118 +0x24
github.com/spf13/cobra.(*Command).execute(0x1400039a000, {0x140002cfbf0, 0x3, 0x3})
    github.com/spf13/cobra@v1.0.0/command.go:842 +0x4c4
github.com/spf13/cobra.(*Command).ExecuteC(0x1400029f340)
    github.com/spf13/cobra@v1.0.0/command.go:950 +0x34c
main.run()
    github.com/snyk/driftctl/main.go:75 +0x58c
main.main()
    github.com/snyk/driftctl/main.go:28 +0x20
$ driftctl scan -f tfstate+s3://omitted --only-managed
Scanned states (1)
error scanning resource aws_cloudformation_stack.arn:aws:cloudformation:us-west-2:omitted:stack/amazon-ecs-cli-setup-ec2-nwg-ecs-poc/908ccc50-0b6d-11ec-9d54-06e586ba9c43: template body contains an invalid JSON or YAML: invalid character ':' after array element

Environment

How to reproduce just run scan with --only-managed

ghost commented 2 years ago

hey guys, also a quick offtopic question, is this still the right way below to select everything with tag Terraform: true? It says Found 0 resource(s) tho I have a bunch of stuff with the tag.

$ driftctl scan -f tfstate+s3://omitted --filter "Attr.Tags.Terraform == 'true'"
Scanned states (1)
Found 0 resource(s)
 - 0% coverage
Congrats! Your infrastructure is fully in sync.
Scan duration: 10s
Provider version used to scan: 4.19.0. Use --tf-provider-version to use another version.
eliecharra commented 2 years ago

@stantruera You need to use --deep if you want to filter on Attr. , check documentation here https://docs.driftctl.com/0.34.0/usage/filtering/rules

image