8000 Fix aws_db_instance false-positives by lotoussa Β· Pull Request #545 Β· snyk/driftctl Β· GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix aws_db_instance false-positives #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix need to be applied to the new infrastructure design in main branch @lotoussa @wbeuil

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch will do it now !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done d427632

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
View file Open in desktop
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