fix: fix aws_security_group_rules tests
parent
6c5e6787b0
commit
ab94124bab
|
@ -43,8 +43,8 @@ func (s *securityGroupRule) getAttrs() resource.Attributes {
|
|||
"type": s.Type,
|
||||
"security_group_id": s.SecurityGroupId,
|
||||
"protocol": s.Protocol,
|
||||
"from_port": s.FromPort,
|
||||
"to_port": s.ToPort,
|
||||
"from_port": int(s.FromPort),
|
||||
"to_port": int(s.ToPort),
|
||||
"self": s.Self,
|
||||
"source_security_group_id": s.SourceSecurityGroupId,
|
||||
"cidr_blocks": toInterfaceSlice(s.CidrBlocks),
|
||||
|
|
|
@ -3,6 +3,7 @@ package common
|
|||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform/flatmap"
|
||||
"github.com/sirupsen/logrus"
|
||||
remoteerror "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/resource"
|
||||
|
@ -34,12 +35,21 @@ func (f *GenericDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.R
|
|||
if b, ok := v.(bool); ok {
|
||||
attributes[k] = strconv.FormatBool(b)
|
||||
}
|
||||
if i, ok := v.(int); ok {
|
||||
attributes[k] = strconv.Itoa(i)
|
||||
}
|
||||
if i64, ok := v.(int64); ok {
|
||||
attributes[k] = strconv.FormatInt(i64, 10)
|
||||
}
|
||||
if str, ok := v.(string); ok {
|
||||
attributes[k] = str
|
||||
}
|
||||
if sliceOfInterface, ok := v.([]interface{}); ok {
|
||||
m := flatmap.Flatten(map[string]interface{}{k: sliceOfInterface})
|
||||
for k2, v2 := range m {
|
||||
attributes[k2] = v2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ctyVal, err := f.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
|
|
|
@ -13,11 +13,11 @@ const AwsSecurityGroupRuleResourceType = "aws_security_group_rule"
|
|||
func CreateSecurityGroupRuleIdHash(attrs *resource.Attributes) string {
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("security_group_id")))
|
||||
if attrs.GetInt("from_port") != nil && *attrs.GetInt("from_port") > 0 {
|
||||
buf.WriteString(fmt.Sprintf("%d-", *attrs.GetInt("from_port")))
|
||||
if (*attrs)["from_port"] != nil && (*attrs)["from_port"].(int) > 0 {
|
||||
buf.WriteString(fmt.Sprintf("%d-", (*attrs)["from_port"].(int)))
|
||||
}
|
||||
if attrs.GetInt("to_port") != nil && *attrs.GetInt("to_port") > 0 {
|
||||
buf.WriteString(fmt.Sprintf("%d-", *attrs.GetInt("to_port")))
|
||||
if (*attrs)["to_port"] != nil && (*attrs)["to_port"].(int) > 0 {
|
||||
buf.WriteString(fmt.Sprintf("%d-", (*attrs)["to_port"].(int)))
|
||||
}
|
||||
buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("protocol")))
|
||||
buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("type")))
|
||||
|
|
Loading…
Reference in New Issue