jckuester / awsweeper

A tool for cleaning your AWS account
Mozilla Public License 2.0
469 stars 45 forks source link

aws_kms_alias invalid memory address #25

Closed bleiva closed 5 years ago

bleiva commented 5 years ago

I'm using MacOS and I'm testing the tool with all.yml, I think there is a bug with the option: aws_kms_alias. If I comment this option #aws_kms_alias works well.

Regards!

---
Type: aws_kms_alias
Found: 14
    Id: alias/aws/acm
    Id: alias/aws/connect
    Id: alias/aws/dynamodb
    Id: alias/aws/ebs
    Id: alias/aws/elasticfilesystem
    Id: alias/aws/es
    Id: alias/aws/glue
    Id: alias/aws/kinesisvideo
    Id: alias/aws/rds
    Id: alias/aws/lambda
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x26db73b]
goroutine 619 [running]:
github.com/cloudetc/awsweeper/vendor/github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsKmsAliasRead(0xc420298700, 0x300f2a0, 0xc4200b4a00, 0xc420298700, 0x0)
    /home/janck/go/src/github.com/cloudetc/awsweeper/vendor/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_kms_alias.go:122 +0x35b
github.com/cloudetc/awsweeper/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Refresh(0xc42038ff10, 0xc420502640, 0x300f2a0, 0xc4200b4a00, 0xc420462390, 0x1, 0x3286980)
    /home/janck/go/src/github.com/cloudetc/awsweeper/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:354 +0x167
github.com/cloudetc/awsweeper/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).Refresh(0xc42044b5e0, 0xc420502460, 0xc420502640, 0xa, 0xc420734ce8, 0x0)
    /home/janck/go/src/github.com/cloudetc/awsweeper/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:308 +0x9a
github.com/cloudetc/awsweeper/command.(*Wipe).wipe.func1(0xc4205e34a0, 0xc42052acf0, 0xc420502460, 0xc4208876e0, 0xc420510cc0)
    /home/janck/go/src/github.com/cloudetc/awsweeper/command/wipe.go:126 +0x26c
created by github.com/cloudetc/awsweeper/command.(*Wipe).wipe
    /home/janck/go/src/github.com/cloudetc/awsweeper/command/wipe.go:100 +0x210
jckuester commented 5 years ago

Thanks, I will look into it. Actually, I do not run the integration test for the KMS keys very often, as those cost money. So, I wasn't aware of this bug yet.

jckuester commented 5 years ago

I created a fix https://github.com/cloudetc/awsweeper/pull/30. Key aliases that start with alias/aws/ are not shown/filtered anymore, as those cannot be deleted anyway. They are managed by AWS.

jckuester commented 5 years ago

Fixed in https://github.com/cloudetc/awsweeper/releases/tag/v0.3.1