Skip to content

Commit

Permalink
Merge pull request #545 from cloudskiff/issue_542_aws_db_instance
Browse files Browse the repository at this point in the history
Fix aws_db_instance false-positives
  • Loading branch information
wbeuil authored May 25, 2021
2 parents 91eb23b + 6dda84a commit b933a9b
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/resource/aws/aws_db_instance_ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ func (r *AwsDbInstance) NormalizeForState() (resource.Resource, error) {
if r.ApplyImmediately != nil && !*r.ApplyImmediately {
r.ApplyImmediately = nil
}
if r.CharacterSetName != nil && *r.CharacterSetName == "" {
r.CharacterSetName = nil
}
return r, nil
}

func (r *AwsDbInstance) NormalizeForProvider() (resource.Resource, error) {
if r.CharacterSetName != nil && *r.CharacterSetName == "" {
r.CharacterSetName = nil
}
return r, nil
}
29 changes: 29 additions & 0 deletions pkg/resource/aws/aws_db_instance_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package aws_test

import (
"testing"

"github.com/cloudskiff/driftctl/test"
"github.com/cloudskiff/driftctl/test/acceptance"
)

func TestAcc_AwsDbInstance(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
Paths: []string{"./testdata/acc/aws_db_instance"},
Args: []string{"scan", "--filter", "Type=='aws_db_instance'"},
Checks: []acceptance.AccCheck{
{
Env: map[string]string{
"AWS_REGION": "us-east-1",
},
Check: func(result *test.ScanResult, stdout string, err error) {
if err != nil {
t.Fatal(err)
}
result.AssertInfrastructureIsInSync()
result.AssertManagedCount(1)
},
},
},
})
}
21 changes: 21 additions & 0 deletions pkg/resource/aws/testdata/acc/aws_db_instance/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pkg/resource/aws/testdata/acc/aws_db_instance/db_instance.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
provider "aws" {
region = "us-east-1"
}

terraform {
required_providers {
aws = "3.19.0"
}
}

resource "aws_db_instance" "default" {
allocated_storage = 10
engine = "mysql"
engine_version = "5.7"
instance_class = "db.t3.micro"
name = "mydb"
username = "foo"
password = "foobarbaz"
parameter_group_name = "default.mysql5.7"
skip_final_snapshot = true
}

0 comments on commit b933a9b

Please sign in to comment.