chore: move schema repo in driftctl

main
Elie CHARRA 2022-07-21 15:08:43 +02:00
parent 1ece051636
commit f9065269e8
No known key found for this signature in database
GPG Key ID: 399AF69092C727B6
125 changed files with 836 additions and 544 deletions

View File

@ -5,8 +5,6 @@ import (
"github.com/hashicorp/go-version" "github.com/hashicorp/go-version"
"github.com/hashicorp/terraform/configs/configschema" "github.com/hashicorp/terraform/configs/configschema"
"github.com/hashicorp/terraform/providers"
"github.com/sirupsen/logrus"
) )
type AttributeSchema struct { type AttributeSchema struct {
@ -53,122 +51,3 @@ func (s *Schema) IsJsonStringField(path []string) bool {
} }
return metadata.JsonString return metadata.JsonString
} }
type SchemaRepositoryInterface interface {
GetSchema(resourceType string) (*Schema, bool)
SetFlags(typ string, flags ...Flags)
UpdateSchema(typ string, schemasMutators map[string]func(attributeSchema *AttributeSchema))
SetNormalizeFunc(typ string, normalizeFunc func(res *Resource))
SetHumanReadableAttributesFunc(typ string, humanReadableAttributesFunc func(res *Resource) map[string]string)
SetDiscriminantFunc(string, func(*Resource, *Resource) bool)
}
type SchemaRepository struct {
schemas map[string]*Schema
ProviderName string
ProviderVersion *version.Version
}
func NewSchemaRepository() *SchemaRepository {
return &SchemaRepository{
schemas: make(map[string]*Schema),
}
}
func (r *SchemaRepository) GetSchema(resourceType string) (*Schema, bool) {
schema, exist := r.schemas[resourceType]
return schema, exist
}
func (r *SchemaRepository) fetchNestedBlocks(root string, metadata map[string]AttributeSchema, block map[string]*configschema.NestedBlock) {
for s, nestedBlock := range block {
path := s
if root != "" {
path = strings.Join([]string{root, s}, ".")
}
for s2, attr := range nestedBlock.Attributes {
nestedPath := strings.Join([]string{path, s2}, ".")
metadata[nestedPath] = AttributeSchema{
ConfigSchema: *attr,
}
}
r.fetchNestedBlocks(path, metadata, nestedBlock.BlockTypes)
}
}
func (r *SchemaRepository) Init(providerName, providerVersion string, schema map[string]providers.Schema) error {
v, err := version.NewVersion(providerVersion)
if err != nil {
return err
}
r.ProviderVersion = v
r.ProviderName = providerName
for typ, sch := range schema {
attributeMetas := map[string]AttributeSchema{}
for s, attribute := range sch.Block.Attributes {
attributeMetas[s] = AttributeSchema{
ConfigSchema: *attribute,
}
}
r.fetchNestedBlocks("", attributeMetas, sch.Block.BlockTypes)
r.schemas[typ] = &Schema{
ProviderVersion: r.ProviderVersion,
SchemaVersion: sch.Version,
Attributes: attributeMetas,
}
}
return nil
}
func (r SchemaRepository) SetFlags(typ string, flags ...Flags) {
metadata, exist := r.GetSchema(typ)
if !exist {
logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set flags, no schema found")
return
}
for _, flag := range flags {
metadata.Flags.AddFlag(flag)
}
}
func (r *SchemaRepository) UpdateSchema(typ string, schemasMutators map[string]func(attributeSchema *AttributeSchema)) {
for s, f := range schemasMutators {
metadata, exist := r.GetSchema(typ)
if !exist {
logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set metadata, no schema found")
return
}
m := (*metadata).Attributes[s]
f(&m)
(*metadata).Attributes[s] = m
}
}
func (r *SchemaRepository) SetNormalizeFunc(typ string, normalizeFunc func(res *Resource)) {
metadata, exist := r.GetSchema(typ)
if !exist {
logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set normalize func, no schema found")
return
}
(*metadata).NormalizeFunc = normalizeFunc
}
func (r *SchemaRepository) SetHumanReadableAttributesFunc(typ string, humanReadableAttributesFunc func(res *Resource) map[string]string) {
metadata, exist := r.GetSchema(typ)
if !exist {
logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to add human readable attributes, no schema found")
return
}
(*metadata).HumanReadableAttributesFunc = humanReadableAttributesFunc
}
func (r *SchemaRepository) SetDiscriminantFunc(typ string, fn func(self, res *Resource) bool) {
metadata, exist := r.GetSchema(typ)
if !exist {
logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set discriminant function, no schema found")
return
}
(*metadata).DiscriminantFunc = fn
}

View File

@ -6,6 +6,8 @@ import (
"testing" "testing"
"time" "time"
dctlresource "github.com/snyk/driftctl/pkg/resource"
alerter2 "github.com/snyk/driftctl/enumeration/alerter" alerter2 "github.com/snyk/driftctl/enumeration/alerter"
"github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/filter"
@ -1264,7 +1266,7 @@ func TestAnalyze(t *testing.T) {
} }
} }
func addSchemaToRes(res *resource.Resource, repo resource.SchemaRepositoryInterface) { func addSchemaToRes(res *resource.Resource, repo dctlresource.SchemaRepositoryInterface) {
schema, _ := repo.GetSchema(res.ResourceType()) schema, _ := repo.GetSchema(res.ResourceType())
res.Sch = schema res.Sch = schema
} }

View File

@ -19,7 +19,6 @@ import (
"github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/alerter"
"github.com/snyk/driftctl/enumeration/remote" "github.com/snyk/driftctl/enumeration/remote"
"github.com/snyk/driftctl/enumeration/remote/common" "github.com/snyk/driftctl/enumeration/remote/common"
"github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/terraform"
"github.com/snyk/driftctl/enumeration/terraform/lock" "github.com/snyk/driftctl/enumeration/terraform/lock"
"github.com/snyk/driftctl/pkg/analyser" "github.com/snyk/driftctl/pkg/analyser"
@ -27,10 +26,7 @@ import (
"github.com/snyk/driftctl/pkg/iac/terraform/state" "github.com/snyk/driftctl/pkg/iac/terraform/state"
"github.com/snyk/driftctl/pkg/memstore" "github.com/snyk/driftctl/pkg/memstore"
dctlresource "github.com/snyk/driftctl/pkg/resource" dctlresource "github.com/snyk/driftctl/pkg/resource"
"github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/pkg/resource/schemas"
"github.com/snyk/driftctl/pkg/resource/azurerm"
"github.com/snyk/driftctl/pkg/resource/github"
"github.com/snyk/driftctl/pkg/resource/google"
"github.com/snyk/driftctl/pkg/telemetry" "github.com/snyk/driftctl/pkg/telemetry"
"github.com/snyk/driftctl/pkg/terraform/hcl" "github.com/snyk/driftctl/pkg/terraform/hcl"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -291,7 +287,7 @@ func scanRun(opts *pkg.ScanOptions) error {
iacProgress := globaloutput.NewProgress("Scanning states", "Scanned states", true) iacProgress := globaloutput.NewProgress("Scanning states", "Scanned states", true)
scanProgress := globaloutput.NewProgress("Scanning resources", "Scanned resources", false) scanProgress := globaloutput.NewProgress("Scanning resources", "Scanned resources", false)
resourceSchemaRepository := resource.NewSchemaRepository() resourceSchemaRepository := schemas.NewSchemaRepository()
resFactory := dctlresource.NewDriftctlResourceFactory(resourceSchemaRepository) resFactory := dctlresource.NewDriftctlResourceFactory(resourceSchemaRepository)
@ -300,17 +296,10 @@ func scanRun(opts *pkg.ScanOptions) error {
return err return err
} }
switch opts.To { providerName := common.RemoteParameter(opts.To).GetProviderAddress().Type
case common.RemoteAWSTerraform: err = resourceSchemaRepository.Init(providerName, opts.ProviderVersion, providerLibrary.Provider(opts.To).Schema())
aws.InitResourcesMetadata(resourceSchemaRepository) if err != nil {
case common.RemoteGithubTerraform: return err
github.InitResourcesMetadata(resourceSchemaRepository)
case common.RemoteGoogleTerraform:
google.InitResourcesMetadata(resourceSchemaRepository)
case common.RemoteAzureTerraform:
azurerm.InitResourcesMetadata(resourceSchemaRepository)
default:
return errors.Errorf("unsupported remote '%s'", opts.To)
} }
// Teardown // Teardown
@ -355,8 +344,8 @@ func scanRun(opts *pkg.ScanOptions) error {
return err return err
} }
analysis.ProviderVersion = resourceSchemaRepository.ProviderVersion.String() analysis.ProviderVersion = opts.ProviderVersion
analysis.ProviderName = resourceSchemaRepository.ProviderName analysis.ProviderName = opts.To
store.Bucket(memstore.TelemetryBucket).Set("provider_name", analysis.ProviderName) store.Bucket(memstore.TelemetryBucket).Set("provider_name", analysis.ProviderName)
validOutput := false validOutput := false
@ -377,7 +366,7 @@ func scanRun(opts *pkg.ScanOptions) error {
} }
globaloutput.Printf(color.WhiteString("Scan duration: %s\n", analysis.Duration.Round(time.Second))) globaloutput.Printf(color.WhiteString("Scan duration: %s\n", analysis.Duration.Round(time.Second)))
globaloutput.Printf(color.WhiteString("Provider version used to scan: %s. Use --tf-provider-version to use another version.\n"), resourceSchemaRepository.ProviderVersion.String()) globaloutput.Printf(color.WhiteString("Provider version used to scan: %s. Use --tf-provider-version to use another version.\n"), opts.ProviderVersion)
if !opts.DisableTelemetry { if !opts.DisableTelemetry {
tl := telemetry.NewTelemetry(&build.Build{}) tl := telemetry.NewTelemetry(&build.Build{})

View File

@ -4,21 +4,19 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/snyk/driftctl/enumeration/alerter"
resource2 "github.com/snyk/driftctl/pkg/resource"
"github.com/jmespath/go-jmespath" "github.com/jmespath/go-jmespath"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/snyk/driftctl/pkg/memstore" "github.com/snyk/driftctl/enumeration/alerter"
globaloutput "github.com/snyk/driftctl/pkg/output"
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/pkg/analyser" "github.com/snyk/driftctl/pkg/analyser"
"github.com/snyk/driftctl/pkg/cmd/scan/output" "github.com/snyk/driftctl/pkg/cmd/scan/output"
"github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/filter"
"github.com/snyk/driftctl/pkg/iac/config" "github.com/snyk/driftctl/pkg/iac/config"
"github.com/snyk/driftctl/pkg/iac/terraform/state/backend" "github.com/snyk/driftctl/pkg/iac/terraform/state/backend"
"github.com/snyk/driftctl/pkg/memstore"
"github.com/snyk/driftctl/pkg/middlewares" "github.com/snyk/driftctl/pkg/middlewares"
globaloutput "github.com/snyk/driftctl/pkg/output"
dctlresource "github.com/snyk/driftctl/pkg/resource"
) )
type FmtOptions struct { type FmtOptions struct {
@ -47,26 +45,26 @@ type ScanOptions struct {
type DriftCTL struct { type DriftCTL struct {
remoteSupplier resource.Supplier remoteSupplier resource.Supplier
iacSupplier resource2.IaCSupplier iacSupplier dctlresource.IaCSupplier
alerter alerter.AlerterInterface alerter alerter.AlerterInterface
analyzer *analyser.Analyzer analyzer *analyser.Analyzer
resourceFactory resource.ResourceFactory resourceFactory resource.ResourceFactory
scanProgress globaloutput.Progress scanProgress globaloutput.Progress
iacProgress globaloutput.Progress iacProgress globaloutput.Progress
resourceSchemaRepository resource.SchemaRepositoryInterface resourceSchemaRepository dctlresource.SchemaRepositoryInterface
opts *ScanOptions opts *ScanOptions
store memstore.Store store memstore.Store
} }
func NewDriftCTL(remoteSupplier resource.Supplier, func NewDriftCTL(remoteSupplier resource.Supplier,
iacSupplier resource2.IaCSupplier, iacSupplier dctlresource.IaCSupplier,
alerter *alerter.Alerter, alerter *alerter.Alerter,
analyzer *analyser.Analyzer, analyzer *analyser.Analyzer,
resFactory resource.ResourceFactory, resFactory resource.ResourceFactory,
opts *ScanOptions, opts *ScanOptions,
scanProgress globaloutput.Progress, scanProgress globaloutput.Progress,
iacProgress globaloutput.Progress, iacProgress globaloutput.Progress,
resourceSchemaRepository resource.SchemaRepositoryInterface, resourceSchemaRepository dctlresource.SchemaRepositoryInterface,
store memstore.Store) *DriftCTL { store memstore.Store) *DriftCTL {
return &DriftCTL{ return &DriftCTL{
remoteSupplier, remoteSupplier,

View File

@ -14,7 +14,6 @@ import (
"github.com/snyk/driftctl/pkg/output" "github.com/snyk/driftctl/pkg/output"
dctlresource "github.com/snyk/driftctl/pkg/resource" dctlresource "github.com/snyk/driftctl/pkg/resource"
"github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/pkg/resource/aws"
"github.com/snyk/driftctl/pkg/resource/github"
"github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test"
testresource "github.com/snyk/driftctl/test/resource" testresource "github.com/snyk/driftctl/test/resource"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -31,7 +30,7 @@ type TestCase struct {
provider *TestProvider provider *TestProvider
stateResources []*resource.Resource stateResources []*resource.Resource
remoteResources []*resource.Resource remoteResources []*resource.Resource
mocks func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) mocks func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface)
assert func(t *testing.T, result *test.ScanResult, err error) assert func(t *testing.T, result *test.ScanResult, err error)
assertStore func(*testing.T, memstore.Store) assertStore func(*testing.T, memstore.Store)
options *pkg.ScanOptions options *pkg.ScanOptions
@ -48,8 +47,6 @@ func runTest(t *testing.T, cases TestCases) {
} }
} }
repo := testresource.InitFakeSchemaRepository(c.provider.Name, c.provider.Version) repo := testresource.InitFakeSchemaRepository(c.provider.Name, c.provider.Version)
aws.InitResourcesMetadata(repo)
github.InitResourcesMetadata(repo)
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
testAlerter := alerter.NewAlerter() testAlerter := alerter.NewAlerter()
@ -363,7 +360,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
}, },
{ {
name: "we should ignore default AWS IAM role when strict mode is disabled", name: "we should ignore default AWS IAM role when strict mode is disabled",
mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) {
factory.(*dctlresource.MockResourceFactory).On( factory.(*dctlresource.MockResourceFactory).On(
"CreateAbstractResource", "CreateAbstractResource",
aws.AwsIamPolicyAttachmentResourceType, aws.AwsIamPolicyAttachmentResourceType,
@ -461,7 +458,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
}, },
{ {
name: "we should not ignore default AWS IAM role when strict mode is enabled", name: "we should not ignore default AWS IAM role when strict mode is enabled",
mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) {
factory.(*dctlresource.MockResourceFactory).On( factory.(*dctlresource.MockResourceFactory).On(
"CreateAbstractResource", "CreateAbstractResource",
aws.AwsIamPolicyAttachmentResourceType, aws.AwsIamPolicyAttachmentResourceType,
@ -559,7 +556,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
}, },
{ {
name: "we should not ignore default AWS IAM role when strict mode is enabled and a filter is specified", name: "we should not ignore default AWS IAM role when strict mode is enabled and a filter is specified",
mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) {
factory.(*dctlresource.MockResourceFactory).On( factory.(*dctlresource.MockResourceFactory).On(
"CreateAbstractResource", "CreateAbstractResource",
aws.AwsIamPolicyAttachmentResourceType, aws.AwsIamPolicyAttachmentResourceType,
@ -790,7 +787,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
}, },
}, },
}, },
mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) {
factory.(*dctlresource.MockResourceFactory).On( factory.(*dctlresource.MockResourceFactory).On(
"CreateAbstractResource", "CreateAbstractResource",
aws.AwsS3BucketPolicyResourceType, aws.AwsS3BucketPolicyResourceType,
@ -877,7 +874,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
}, },
}, },
}, },
mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) {
foo := resource.Resource{ foo := resource.Resource{
Id: "vol-018c5ae89895aca4c", Id: "vol-018c5ae89895aca4c",
Type: "aws_ebs_volume", Type: "aws_ebs_volume",
@ -992,7 +989,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
}, },
}, },
}, },
mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) {
factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table1080289494", mock.MatchedBy(func(input map[string]interface{}) bool { factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table1080289494", mock.MatchedBy(func(input map[string]interface{}) bool {
return matchByAttributes(input, map[string]interface{}{ return matchByAttributes(input, map[string]interface{}{
"destination_cidr_block": "0.0.0.0/0", "destination_cidr_block": "0.0.0.0/0",
@ -1070,7 +1067,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
}, },
}, },
}, },
mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) {
factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_sns_topic_policy", "foo", map[string]interface{}{ factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_sns_topic_policy", "foo", map[string]interface{}{
"id": "foo", "id": "foo",
"arn": "arn", "arn": "arn",
@ -1132,7 +1129,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
}, },
}, },
}, },
mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) {
factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", map[string]interface{}{ factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", map[string]interface{}{
"id": "foo", "id": "foo",
"queue_url": "foo", "queue_url": "foo",
@ -1344,7 +1341,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
}, },
}, },
}, },
mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) {
rule1 := resource.Resource{ rule1 := resource.Resource{
Type: aws.AwsSecurityGroupRuleResourceType, Type: aws.AwsSecurityGroupRuleResourceType,
Id: "sgrule-1707973622", Id: "sgrule-1707973622",
@ -1553,7 +1550,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
}, },
}, },
}, },
mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) {
factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "iduser1", map[string]interface{}{ factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "iduser1", map[string]interface{}{
"id": "iduser1", "id": "iduser1",
"policy_arn": "policy_arn1", "policy_arn": "policy_arn1",
@ -1784,7 +1781,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
runTest(t, cases) runTest(t, cases)
} }
func getSchema(repo resource.SchemaRepositoryInterface, resourceType string) *resource.Schema { func getSchema(repo dctlresource.SchemaRepositoryInterface, resourceType string) *resource.Schema {
sch, _ := repo.GetSchema(resourceType) sch, _ := repo.GetSchema(resourceType)
return sch return sch
} }

View File

@ -4,16 +4,17 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
"github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/pkg/resource/aws"
) )
// Explodes policy found in aws_sns_topic from state resources to aws_sns_topic_policy resources // Explodes policy found in aws_sns_topic from state resources to aws_sns_topic_policy resources
type AwsSNSTopicPolicyExpander struct { type AwsSNSTopicPolicyExpander struct {
resourceFactory resource.ResourceFactory resourceFactory resource.ResourceFactory
resourceSchemaRepository resource.SchemaRepositoryInterface resourceSchemaRepository dctlresource.SchemaRepositoryInterface
} }
func NewAwsSNSTopicPolicyExpander(resourceFactory resource.ResourceFactory, resourceSchemaRepository resource.SchemaRepositoryInterface) AwsSNSTopicPolicyExpander { func NewAwsSNSTopicPolicyExpander(resourceFactory resource.ResourceFactory, resourceSchemaRepository dctlresource.SchemaRepositoryInterface) AwsSNSTopicPolicyExpander {
return AwsSNSTopicPolicyExpander{ return AwsSNSTopicPolicyExpander{
resourceFactory, resourceFactory,
resourceSchemaRepository, resourceSchemaRepository,

View File

@ -3,16 +3,17 @@ package middlewares
import ( import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
"github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/pkg/resource/aws"
) )
// Explodes policy found in aws_sqs_queue.policy from state resources to dedicated resources // Explodes policy found in aws_sqs_queue.policy from state resources to dedicated resources
type AwsSQSQueuePolicyExpander struct { type AwsSQSQueuePolicyExpander struct {
resourceFactory resource.ResourceFactory resourceFactory resource.ResourceFactory
resourceSchemaRepository resource.SchemaRepositoryInterface resourceSchemaRepository dctlresource.SchemaRepositoryInterface
} }
func NewAwsSQSQueuePolicyExpander(resourceFactory resource.ResourceFactory, resourceSchemaRepository resource.SchemaRepositoryInterface) AwsSQSQueuePolicyExpander { func NewAwsSQSQueuePolicyExpander(resourceFactory resource.ResourceFactory, resourceSchemaRepository dctlresource.SchemaRepositoryInterface) AwsSQSQueuePolicyExpander {
return AwsSQSQueuePolicyExpander{ return AwsSQSQueuePolicyExpander{
resourceFactory, resourceFactory,
resourceSchemaRepository, resourceSchemaRepository,

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsAmiResourceType = "aws_ami" const AwsAmiResourceType = "aws_ami"
func initAwsAmiMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsAmiMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsAmiResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsAmiResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsApiGatewayV2MappingResourceType = "aws_apigatewayv2_api_mapping" const AwsApiGatewayV2MappingResourceType = "aws_apigatewayv2_api_mapping"
func initAwsApiGatewayV2MappingMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsApiGatewayV2MappingMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc( resourceSchemaRepository.SetHumanReadableAttributesFunc(
AwsApiGatewayV2MappingResourceType, AwsApiGatewayV2MappingResourceType,
func(res *resource.Resource) map[string]string { func(res *resource.Resource) map[string]string {

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsApiGatewayV2ModelResourceType = "aws_apigatewayv2_model" const AwsApiGatewayV2ModelResourceType = "aws_apigatewayv2_model"
func initAwsApiGatewayV2ModelMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsApiGatewayV2ModelMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc( resourceSchemaRepository.SetHumanReadableAttributesFunc(
AwsApiGatewayV2ModelResourceType, AwsApiGatewayV2ModelResourceType,
func(res *resource.Resource) map[string]string { func(res *resource.Resource) map[string]string {

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsAppAutoscalingPolicyResourceType = "aws_appautoscaling_policy" const AwsAppAutoscalingPolicyResourceType = "aws_appautoscaling_policy"
func initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingPolicyResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingPolicyResourceType, func(res *resource.Resource) map[string]string {
attrs := make(map[string]string) attrs := make(map[string]string)
if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" {

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsAppAutoscalingTargetResourceType = "aws_appautoscaling_target" const AwsAppAutoscalingTargetResourceType = "aws_appautoscaling_target"
func initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string {
attrs := make(map[string]string) attrs := make(map[string]string)
if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" {

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsCloudformationStackResourceType = "aws_cloudformation_stack" const AwsCloudformationStackResourceType = "aws_cloudformation_stack"
func initAwsCloudformationStackMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsCloudformationStackMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsCloudformationStackResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsCloudformationStackResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsCloudfrontDistributionResourceType = "aws_cloudfront_distribution" const AwsCloudfrontDistributionResourceType = "aws_cloudfront_distribution"
func initAwsCloudfrontDistributionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsCloudfrontDistributionMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsCloudfrontDistributionResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsCloudfrontDistributionResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"etag"}) val.SafeDelete([]string{"etag"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsDbInstanceResourceType = "aws_db_instance" const AwsDbInstanceResourceType = "aws_db_instance"
func initAwsDbInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsDbInstanceMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsDbInstanceResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsDbInstanceResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"delete_automated_backups"}) val.SafeDelete([]string{"delete_automated_backups"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsDbSubnetGroupResourceType = "aws_db_subnet_group" const AwsDbSubnetGroupResourceType = "aws_db_subnet_group"
func initAwsDbSubnetGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsDbSubnetGroupMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsDbSubnetGroupResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsDbSubnetGroupResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"name_prefix"}) val.SafeDelete([]string{"name_prefix"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsDefaultNetworkACLResourceType = "aws_default_network_acl" const AwsDefaultNetworkACLResourceType = "aws_default_network_acl"
func initAwsDefaultNetworkACLMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsDefaultNetworkACLMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsDefaultNetworkACLResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsDefaultNetworkACLResourceType, func(res *resource.Resource) {
res.Attrs.SafeDelete([]string{"default_network_acl_id"}) res.Attrs.SafeDelete([]string{"default_network_acl_id"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsDefaultRouteTableResourceType = "aws_default_route_table" const AwsDefaultRouteTableResourceType = "aws_default_route_table"
func initAwsDefaultRouteTableMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsDefaultRouteTableMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsDefaultRouteTableResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsDefaultRouteTableResourceType, resource.FlagDeepMode)
resourceSchemaRepository.SetNormalizeFunc(AwsDefaultRouteTableResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsDefaultRouteTableResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsDefaultSecurityGroupResourceType = "aws_default_security_group" const AwsDefaultSecurityGroupResourceType = "aws_default_security_group"
func initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsDefaultSecurityGroupResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsDefaultSecurityGroupResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"revoke_rules_on_delete"}) val.SafeDelete([]string{"revoke_rules_on_delete"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsDefaultSubnetResourceType = "aws_default_subnet" const AwsDefaultSubnetResourceType = "aws_default_subnet"
func initAwsDefaultSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsDefaultSubnetMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsDefaultSubnetResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsDefaultSubnetResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsDefaultVpcResourceType = "aws_default_vpc" const AwsDefaultVpcResourceType = "aws_default_vpc"
func initAwsDefaultVpcMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsDefaultVpcMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsDefaultVpcResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsDefaultVpcResourceType, resource.FlagDeepMode)
} }

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsDynamodbTableResourceType = "aws_dynamodb_table" const AwsDynamodbTableResourceType = "aws_dynamodb_table"
func initAwsDynamodbTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsDynamodbTableMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsDynamodbTableResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsDynamodbTableResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsEbsEncryptionByDefaultResourceType = "aws_ebs_encryption_by_default" const AwsEbsEncryptionByDefaultResourceType = "aws_ebs_encryption_by_default"
func initAwsEbsEncryptionByDefaultMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsEbsEncryptionByDefaultMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsEbsEncryptionByDefaultResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsEbsEncryptionByDefaultResourceType, resource.FlagDeepMode)
} }

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsEbsSnapshotResourceType = "aws_ebs_snapshot" const AwsEbsSnapshotResourceType = "aws_ebs_snapshot"
func initAwsEbsSnapshotMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsEbsSnapshotMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsEbsSnapshotResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsEbsSnapshotResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsEbsVolumeResourceType = "aws_ebs_volume" const AwsEbsVolumeResourceType = "aws_ebs_volume"
func initAwsEbsVolumeMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsEbsVolumeMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsEbsVolumeResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsEbsVolumeResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"arn"}) val.SafeDelete([]string{"arn"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsEcrRepositoryResourceType = "aws_ecr_repository" const AwsEcrRepositoryResourceType = "aws_ecr_repository"
func initAwsEcrRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsEcrRepositoryMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsEcrRepositoryResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsEcrRepositoryResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsEipResourceType = "aws_eip" const AwsEipResourceType = "aws_eip"
func initAwsEipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsEipMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsEipResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsEipResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsEipAssociationResourceType = "aws_eip_association" const AwsEipAssociationResourceType = "aws_eip_association"
func initAwsEipAssociationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsEipAssociationMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsEipAssociationResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsEipAssociationResourceType, resource.FlagDeepMode)
} }

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsIamAccessKeyResourceType = "aws_iam_access_key" const AwsIamAccessKeyResourceType = "aws_iam_access_key"
func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsIAMAccessKeyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
// As we can't read secrets from aws API once access_key created we need to set // As we can't read secrets from aws API once access_key created we need to set

View File

@ -3,11 +3,12 @@ package aws
import ( import (
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/pkg/helpers" "github.com/snyk/driftctl/pkg/helpers"
dctlresource "github.com/snyk/driftctl/pkg/resource"
) )
const AwsIamPolicyResourceType = "aws_iam_policy" const AwsIamPolicyResourceType = "aws_iam_policy"
func initAwsIAMPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsIAMPolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsIamPolicyResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsIamPolicyResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) jsonString, err := helpers.NormalizeJsonString((*val)["policy"])

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsIamPolicyAttachmentResourceType = "aws_iam_policy_attachment" const AwsIamPolicyAttachmentResourceType = "aws_iam_policy_attachment"
func initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsIamPolicyAttachmentResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsIamPolicyAttachmentResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"name"}) val.SafeDelete([]string{"name"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsIamRoleResourceType = "aws_iam_role" const AwsIamRoleResourceType = "aws_iam_role"
func initAwsIAMRoleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsIAMRoleMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsIamRoleResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsIamRoleResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"force_detach_policies"}) val.SafeDelete([]string{"force_detach_policies"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsIamRolePolicyResourceType = "aws_iam_role_policy" const AwsIamRolePolicyResourceType = "aws_iam_role_policy"
func initAwsIAMRolePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsIAMRolePolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.UpdateSchema(AwsIamRolePolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ resourceSchemaRepository.UpdateSchema(AwsIamRolePolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
"policy": func(attributeSchema *resource.AttributeSchema) { "policy": func(attributeSchema *resource.AttributeSchema) {
attributeSchema.JsonString = true attributeSchema.JsonString = true

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsIamRolePolicyAttachmentResourceType = "aws_iam_role_policy_attachment" const AwsIamRolePolicyAttachmentResourceType = "aws_iam_role_policy_attachment"
func initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsIamRolePolicyAttachmentResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsIamRolePolicyAttachmentResourceType, resource.FlagDeepMode)
} }

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsIamUserResourceType = "aws_iam_user" const AwsIamUserResourceType = "aws_iam_user"
func initAwsIAMUserMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsIAMUserMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsIamUserResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsIamUserResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
permissionsBoundary, exist := val.Get("permissions_boundary") permissionsBoundary, exist := val.Get("permissions_boundary")

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsIamUserPolicyResourceType = "aws_iam_user_policy" const AwsIamUserPolicyResourceType = "aws_iam_user_policy"
func initAwsIAMUserPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsIAMUserPolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.UpdateSchema(AwsIamUserPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ resourceSchemaRepository.UpdateSchema(AwsIamUserPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
"policy": func(attributeSchema *resource.AttributeSchema) { "policy": func(attributeSchema *resource.AttributeSchema) {
attributeSchema.JsonString = true attributeSchema.JsonString = true

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsIamUserPolicyAttachmentResourceType = "aws_iam_user_policy_attachment" const AwsIamUserPolicyAttachmentResourceType = "aws_iam_user_policy_attachment"
func initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsIamUserPolicyAttachmentResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsIamUserPolicyAttachmentResourceType, resource.FlagDeepMode)
} }

View File

@ -2,13 +2,13 @@ package aws
import ( import (
"github.com/hashicorp/go-version" "github.com/hashicorp/go-version"
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
) )
const AwsInstanceResourceType = "aws_instance" const AwsInstanceResourceType = "aws_instance"
func initAwsInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsInstanceMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsInstanceResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsInstanceResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsInternetGatewayResourceType = "aws_internet_gateway" const AwsInternetGatewayResourceType = "aws_internet_gateway"
func initAwsInternetGatewayMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsInternetGatewayMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsInternetGatewayResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsInternetGatewayResourceType, resource.FlagDeepMode)
} }

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsKeyPairResourceType = "aws_key_pair" const AwsKeyPairResourceType = "aws_key_pair"
func initAwsKeyPairMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsKeyPairMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsKeyPairResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsKeyPairResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"key_name_prefix"}) val.SafeDelete([]string{"key_name_prefix"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsKmsAliasResourceType = "aws_kms_alias" const AwsKmsAliasResourceType = "aws_kms_alias"
func initAwsKmsAliasMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsKmsAliasMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsKmsAliasResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsKmsAliasResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"name"}) val.SafeDelete([]string{"name"})

View File

@ -3,11 +3,12 @@ package aws
import ( import (
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/pkg/helpers" "github.com/snyk/driftctl/pkg/helpers"
dctlresource "github.com/snyk/driftctl/pkg/resource"
) )
const AwsKmsKeyResourceType = "aws_kms_key" const AwsKmsKeyResourceType = "aws_kms_key"
func initAwsKmsKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsKmsKeyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsKmsKeyResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsKmsKeyResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"deletion_window_in_days"}) val.SafeDelete([]string{"deletion_window_in_days"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsLambdaEventSourceMappingResourceType = "aws_lambda_event_source_mapping" const AwsLambdaEventSourceMappingResourceType = "aws_lambda_event_source_mapping"
func initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsLambdaEventSourceMappingResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsLambdaEventSourceMappingResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"state_transition_reason"}) val.SafeDelete([]string{"state_transition_reason"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsLambdaFunctionResourceType = "aws_lambda_function" const AwsLambdaFunctionResourceType = "aws_lambda_function"
func initAwsLambdaFunctionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsLambdaFunctionMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsLambdaFunctionResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsLambdaFunctionResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsLaunchTemplateResourceType = "aws_launch_template" const AwsLaunchTemplateResourceType = "aws_launch_template"
func initAwsLaunchTemplateMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsLaunchTemplateMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsLaunchTemplateResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsLaunchTemplateResourceType, resource.FlagDeepMode)
} }

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsLoadBalancerResourceType = "aws_lb" const AwsLoadBalancerResourceType = "aws_lb"
func initAwsLoadBalancerMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsLoadBalancerMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsLoadBalancerResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsLoadBalancerResourceType, func(res *resource.Resource) map[string]string {
return map[string]string{ return map[string]string{
"Name": *res.Attributes().GetString("name"), "Name": *res.Attributes().GetString("name"),

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsNatGatewayResourceType = "aws_nat_gateway" const AwsNatGatewayResourceType = "aws_nat_gateway"
func initNatGatewayMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initNatGatewayMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsNatGatewayResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsNatGatewayResourceType, resource.FlagDeepMode)
} }

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsNetworkACLResourceType = "aws_network_acl" const AwsNetworkACLResourceType = "aws_network_acl"
func initAwsNetworkACLMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsNetworkACLMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsNetworkACLResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsNetworkACLResourceType, resource.FlagDeepMode)
} }

View File

@ -3,6 +3,7 @@ package aws
import ( import (
"bytes" "bytes"
"fmt" "fmt"
dctlresource "github.com/snyk/driftctl/pkg/resource"
"strconv" "strconv"
"github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/hashcode"
@ -161,7 +162,7 @@ var protocolsNumbers = map[string]int{
"254": 254, "254": 254,
} }
func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsNetworkACLRuleMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) {
res.Attrs.DeleteIfDefault("icmp_code") res.Attrs.DeleteIfDefault("icmp_code")
res.Attrs.DeleteIfDefault("icmp_type") res.Attrs.DeleteIfDefault("icmp_type")

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsRDSClusterResourceType = "aws_rds_cluster" const AwsRDSClusterResourceType = "aws_rds_cluster"
func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsRDSClusterMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsRDSClusterResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsRDSClusterResourceType, func(res *resource.Resource) {
val := res.Attributes() val := res.Attributes()
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -2,15 +2,15 @@ package aws
import ( import (
"fmt" "fmt"
"github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/hashcode"
dctlresource "github.com/snyk/driftctl/pkg/resource"
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
) )
const AwsRouteResourceType = "aws_route" const AwsRouteResourceType = "aws_route"
func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsRouteMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsRouteResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsRouteResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -2,13 +2,13 @@ package aws
import ( import (
"fmt" "fmt"
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
) )
const AwsRoute53HealthCheckResourceType = "aws_route53_health_check" const AwsRoute53HealthCheckResourceType = "aws_route53_health_check"
func initAwsRoute53HealthCheckMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsRoute53HealthCheckMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53HealthCheckResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53HealthCheckResourceType, func(res *resource.Resource) map[string]string {
val := res.Attrs val := res.Attrs
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsRoute53RecordResourceType = "aws_route53_record" const AwsRoute53RecordResourceType = "aws_route53_record"
func initAwsRoute53RecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsRoute53RecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsRoute53RecordResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsRoute53RecordResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.DeleteIfDefault("health_check_id") val.DeleteIfDefault("health_check_id")

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsRoute53ZoneResourceType = "aws_route53_zone" const AwsRoute53ZoneResourceType = "aws_route53_zone"
func initAwsRoute53ZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsRoute53ZoneMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsRoute53ZoneResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsRoute53ZoneResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"force_destroy"}) val.SafeDelete([]string{"force_destroy"})

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsRouteTableResourceType = "aws_route_table" const AwsRouteTableResourceType = "aws_route_table"
func initAwsRouteTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsRouteTableMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsRouteTableResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsRouteTableResourceType, resource.FlagDeepMode)
resourceSchemaRepository.SetNormalizeFunc(AwsRouteTableResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsRouteTableResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsRouteTableAssociationResourceType = "aws_route_table_association" const AwsRouteTableAssociationResourceType = "aws_route_table_association"
func initAwsRouteTableAssociationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsRouteTableAssociationMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteTableAssociationResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteTableAssociationResourceType, func(res *resource.Resource) map[string]string {
val := res.Attrs val := res.Attrs
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsS3BucketResourceType = "aws_s3_bucket" const AwsS3BucketResourceType = "aws_s3_bucket"
func initAwsS3BucketMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsS3BucketMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsS3BucketResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsS3BucketResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"force_destroy"}) val.SafeDelete([]string{"force_destroy"})

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsS3BucketAnalyticsConfigurationResourceType = "aws_s3_bucket_analytics_configuration" const AwsS3BucketAnalyticsConfigurationResourceType = "aws_s3_bucket_analytics_configuration"
func initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsS3BucketAnalyticsConfigurationResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsS3BucketAnalyticsConfigurationResourceType, resource.FlagDeepMode)
} }

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsS3BucketInventoryResourceType = "aws_s3_bucket_inventory" const AwsS3BucketInventoryResourceType = "aws_s3_bucket_inventory"
func initAwsS3BucketInventoryMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsS3BucketInventoryMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsS3BucketInventoryResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsS3BucketInventoryResourceType, resource.FlagDeepMode)
} }

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsS3BucketMetricResourceType = "aws_s3_bucket_metric" const AwsS3BucketMetricResourceType = "aws_s3_bucket_metric"
func initAwsS3BucketMetricMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsS3BucketMetricMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsS3BucketMetricResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsS3BucketMetricResourceType, resource.FlagDeepMode)
} }

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsS3BucketNotificationResourceType = "aws_s3_bucket_notification" const AwsS3BucketNotificationResourceType = "aws_s3_bucket_notification"
func initAwsS3BucketNotificationMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsS3BucketNotificationMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsS3BucketNotificationResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsS3BucketNotificationResourceType, resource.FlagDeepMode)
} }

View File

@ -3,11 +3,12 @@ package aws
import ( import (
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/pkg/helpers" "github.com/snyk/driftctl/pkg/helpers"
dctlresource "github.com/snyk/driftctl/pkg/resource"
) )
const AwsS3BucketPolicyResourceType = "aws_s3_bucket_policy" const AwsS3BucketPolicyResourceType = "aws_s3_bucket_policy"
func initAwsS3BucketPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsS3BucketPolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsS3BucketPolicyResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsS3BucketPolicyResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) jsonString, err := helpers.NormalizeJsonString((*val)["policy"])

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsSecurityGroupResourceType = "aws_security_group" const AwsSecurityGroupResourceType = "aws_security_group"
func initAwsSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsSecurityGroupMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsSecurityGroupResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsSecurityGroupResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"revoke_rules_on_delete"}) val.SafeDelete([]string{"revoke_rules_on_delete"})

View File

@ -3,6 +3,7 @@ package aws
import ( import (
"bytes" "bytes"
"fmt" "fmt"
dctlresource "github.com/snyk/driftctl/pkg/resource"
"strings" "strings"
"github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/hashcode"
@ -11,7 +12,7 @@ import (
const AwsSecurityGroupRuleResourceType = "aws_security_group_rule" const AwsSecurityGroupRuleResourceType = "aws_security_group_rule"
func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.DeleteIfDefault("security_group_id") val.DeleteIfDefault("security_group_id")

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsSnsTopicResourceType = "aws_sns_topic" const AwsSnsTopicResourceType = "aws_sns_topic"
func initSnsTopicMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initSnsTopicMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.DeleteIfDefault("sqs_success_feedback_sample_rate") val.DeleteIfDefault("sqs_success_feedback_sample_rate")

View File

@ -3,11 +3,12 @@ package aws
import ( import (
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/pkg/helpers" "github.com/snyk/driftctl/pkg/helpers"
dctlresource "github.com/snyk/driftctl/pkg/resource"
) )
const AwsSnsTopicPolicyResourceType = "aws_sns_topic_policy" const AwsSnsTopicPolicyResourceType = "aws_sns_topic_policy"
func initSnsTopicPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initSnsTopicPolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicPolicyResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicPolicyResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"owner"}) val.SafeDelete([]string{"owner"})

View File

@ -3,11 +3,12 @@ package aws
import ( import (
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/pkg/helpers" "github.com/snyk/driftctl/pkg/helpers"
dctlresource "github.com/snyk/driftctl/pkg/resource"
) )
const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription" const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription"
func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initSnsTopicSubscriptionMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
jsonString, err := helpers.NormalizeJsonString((*val)["delivery_policy"]) jsonString, err := helpers.NormalizeJsonString((*val)["delivery_policy"])

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsSqsQueueResourceType = "aws_sqs_queue" const AwsSqsQueueResourceType = "aws_sqs_queue"
func initSqsQueueMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initSqsQueueMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsSqsQueueResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsSqsQueueResourceType, resource.FlagDeepMode)
} }

View File

@ -3,11 +3,12 @@ package aws
import ( import (
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/pkg/helpers" "github.com/snyk/driftctl/pkg/helpers"
dctlresource "github.com/snyk/driftctl/pkg/resource"
) )
const AwsSqsQueuePolicyResourceType = "aws_sqs_queue_policy" const AwsSqsQueuePolicyResourceType = "aws_sqs_queue_policy"
func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsSqsQueuePolicyResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsSqsQueuePolicyResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) jsonString, err := helpers.NormalizeJsonString((*val)["policy"])

View File

@ -1,10 +1,13 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsSubnetResourceType = "aws_subnet" const AwsSubnetResourceType = "aws_subnet"
func initAwsSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsSubnetMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AwsSubnetResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AwsSubnetResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"timeouts"})

View File

@ -1,9 +1,12 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AwsVpcResourceType = "aws_vpc" const AwsVpcResourceType = "aws_vpc"
func initAwsVpcMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAwsVpcMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetFlags(AwsVpcResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetFlags(AwsVpcResourceType, resource.FlagDeepMode)
} }

View File

@ -1,125 +1,126 @@
package aws package aws_test
import ( import (
"testing" "testing"
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/pkg/resource/aws"
testresource "github.com/snyk/driftctl/test/resource" testresource "github.com/snyk/driftctl/test/resource"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestAWS_Metadata_Flags(t *testing.T) { func TestAWS_Metadata_Flags(t *testing.T) {
testcases := map[string][]resource.Flags{ testcases := map[string][]resource.Flags{
AwsAmiResourceType: {resource.FlagDeepMode}, aws.AwsAmiResourceType: {resource.FlagDeepMode},
AwsApiGatewayAccountResourceType: {}, aws.AwsApiGatewayAccountResourceType: {},
AwsApiGatewayApiKeyResourceType: {}, aws.AwsApiGatewayApiKeyResourceType: {},
AwsApiGatewayAuthorizerResourceType: {}, aws.AwsApiGatewayAuthorizerResourceType: {},
AwsApiGatewayBasePathMappingResourceType: {}, aws.AwsApiGatewayBasePathMappingResourceType: {},
AwsApiGatewayDeploymentResourceType: {}, aws.AwsApiGatewayDeploymentResourceType: {},
AwsApiGatewayDomainNameResourceType: {}, aws.AwsApiGatewayDomainNameResourceType: {},
AwsApiGatewayGatewayResponseResourceType: {}, aws.AwsApiGatewayGatewayResponseResourceType: {},
AwsApiGatewayIntegrationResourceType: {}, aws.AwsApiGatewayIntegrationResourceType: {},
AwsApiGatewayIntegrationResponseResourceType: {}, aws.AwsApiGatewayIntegrationResponseResourceType: {},
AwsApiGatewayMethodResourceType: {}, aws.AwsApiGatewayMethodResourceType: {},
AwsApiGatewayMethodResponseResourceType: {}, aws.AwsApiGatewayMethodResponseResourceType: {},
AwsApiGatewayMethodSettingsResourceType: {}, aws.AwsApiGatewayMethodSettingsResourceType: {},
AwsApiGatewayModelResourceType: {}, aws.AwsApiGatewayModelResourceType: {},
AwsApiGatewayRequestValidatorResourceType: {}, aws.AwsApiGatewayRequestValidatorResourceType: {},
AwsApiGatewayResourceResourceType: {}, aws.AwsApiGatewayResourceResourceType: {},
AwsApiGatewayRestApiResourceType: {}, aws.AwsApiGatewayRestApiResourceType: {},
AwsApiGatewayRestApiPolicyResourceType: {}, aws.AwsApiGatewayRestApiPolicyResourceType: {},
AwsApiGatewayStageResourceType: {}, aws.AwsApiGatewayStageResourceType: {},
AwsApiGatewayVpcLinkResourceType: {}, aws.AwsApiGatewayVpcLinkResourceType: {},
AwsApiGatewayV2ApiResourceType: {}, aws.AwsApiGatewayV2ApiResourceType: {},
AwsApiGatewayV2RouteResourceType: {}, aws.AwsApiGatewayV2RouteResourceType: {},
AwsApiGatewayV2DeploymentResourceType: {}, aws.AwsApiGatewayV2DeploymentResourceType: {},
AwsApiGatewayV2VpcLinkResourceType: {}, aws.AwsApiGatewayV2VpcLinkResourceType: {},
AwsApiGatewayV2AuthorizerResourceType: {}, aws.AwsApiGatewayV2AuthorizerResourceType: {},
AwsApiGatewayV2RouteResponseResourceType: {}, aws.AwsApiGatewayV2RouteResponseResourceType: {},
AwsApiGatewayV2DomainNameResourceType: {}, aws.AwsApiGatewayV2DomainNameResourceType: {},
AwsApiGatewayV2ModelResourceType: {}, aws.AwsApiGatewayV2ModelResourceType: {},
AwsApiGatewayV2StageResourceType: {}, aws.AwsApiGatewayV2StageResourceType: {},
AwsApiGatewayV2MappingResourceType: {}, aws.AwsApiGatewayV2MappingResourceType: {},
AwsApiGatewayV2IntegrationResourceType: {}, aws.AwsApiGatewayV2IntegrationResourceType: {},
AwsApiGatewayV2IntegrationResponseResourceType: {}, aws.AwsApiGatewayV2IntegrationResponseResourceType: {},
AwsAppAutoscalingPolicyResourceType: {resource.FlagDeepMode}, aws.AwsAppAutoscalingPolicyResourceType: {resource.FlagDeepMode},
AwsAppAutoscalingScheduledActionResourceType: {}, aws.AwsAppAutoscalingScheduledActionResourceType: {},
AwsAppAutoscalingTargetResourceType: {resource.FlagDeepMode}, aws.AwsAppAutoscalingTargetResourceType: {resource.FlagDeepMode},
AwsCloudformationStackResourceType: {resource.FlagDeepMode}, aws.AwsCloudformationStackResourceType: {resource.FlagDeepMode},
AwsCloudfrontDistributionResourceType: {resource.FlagDeepMode}, aws.AwsCloudfrontDistributionResourceType: {resource.FlagDeepMode},
AwsDbInstanceResourceType: {resource.FlagDeepMode}, aws.AwsDbInstanceResourceType: {resource.FlagDeepMode},
AwsDbSubnetGroupResourceType: {resource.FlagDeepMode}, aws.AwsDbSubnetGroupResourceType: {resource.FlagDeepMode},
AwsDefaultNetworkACLResourceType: {resource.FlagDeepMode}, aws.AwsDefaultNetworkACLResourceType: {resource.FlagDeepMode},
AwsDefaultRouteTableResourceType: {resource.FlagDeepMode}, aws.AwsDefaultRouteTableResourceType: {resource.FlagDeepMode},
AwsDefaultSecurityGroupResourceType: {resource.FlagDeepMode}, aws.AwsDefaultSecurityGroupResourceType: {resource.FlagDeepMode},
AwsDefaultSubnetResourceType: {resource.FlagDeepMode}, aws.AwsDefaultSubnetResourceType: {resource.FlagDeepMode},
AwsDefaultVpcResourceType: {resource.FlagDeepMode}, aws.AwsDefaultVpcResourceType: {resource.FlagDeepMode},
AwsDynamodbTableResourceType: {resource.FlagDeepMode}, aws.AwsDynamodbTableResourceType: {resource.FlagDeepMode},
AwsEbsEncryptionByDefaultResourceType: {resource.FlagDeepMode}, aws.AwsEbsEncryptionByDefaultResourceType: {resource.FlagDeepMode},
AwsEbsSnapshotResourceType: {resource.FlagDeepMode}, aws.AwsEbsSnapshotResourceType: {resource.FlagDeepMode},
AwsEbsVolumeResourceType: {resource.FlagDeepMode}, aws.AwsEbsVolumeResourceType: {resource.FlagDeepMode},
AwsEcrRepositoryResourceType: {resource.FlagDeepMode}, aws.AwsEcrRepositoryResourceType: {resource.FlagDeepMode},
AwsEipResourceType: {resource.FlagDeepMode}, aws.AwsEipResourceType: {resource.FlagDeepMode},
AwsEipAssociationResourceType: {resource.FlagDeepMode}, aws.AwsEipAssociationResourceType: {resource.FlagDeepMode},
AwsElastiCacheClusterResourceType: {}, aws.AwsElastiCacheClusterResourceType: {},
AwsIamAccessKeyResourceType: {resource.FlagDeepMode}, aws.AwsIamAccessKeyResourceType: {resource.FlagDeepMode},
AwsIamPolicyResourceType: {resource.FlagDeepMode}, aws.AwsIamPolicyResourceType: {resource.FlagDeepMode},
AwsIamPolicyAttachmentResourceType: {resource.FlagDeepMode}, aws.AwsIamPolicyAttachmentResourceType: {resource.FlagDeepMode},
AwsIamRoleResourceType: {resource.FlagDeepMode}, aws.AwsIamRoleResourceType: {resource.FlagDeepMode},
AwsIamRolePolicyResourceType: {resource.FlagDeepMode}, aws.AwsIamRolePolicyResourceType: {resource.FlagDeepMode},
AwsIamRolePolicyAttachmentResourceType: {resource.FlagDeepMode}, aws.AwsIamRolePolicyAttachmentResourceType: {resource.FlagDeepMode},
AwsIamUserResourceType: {resource.FlagDeepMode}, aws.AwsIamUserResourceType: {resource.FlagDeepMode},
AwsIamUserPolicyResourceType: {resource.FlagDeepMode}, aws.AwsIamUserPolicyResourceType: {resource.FlagDeepMode},
AwsIamUserPolicyAttachmentResourceType: {resource.FlagDeepMode}, aws.AwsIamUserPolicyAttachmentResourceType: {resource.FlagDeepMode},
AwsIamGroupPolicyResourceType: {}, aws.AwsIamGroupPolicyResourceType: {},
AwsIamGroupPolicyAttachmentResourceType: {}, aws.AwsIamGroupPolicyAttachmentResourceType: {},
AwsInstanceResourceType: {resource.FlagDeepMode}, aws.AwsInstanceResourceType: {resource.FlagDeepMode},
AwsInternetGatewayResourceType: {resource.FlagDeepMode}, aws.AwsInternetGatewayResourceType: {resource.FlagDeepMode},
AwsKeyPairResourceType: {resource.FlagDeepMode}, aws.AwsKeyPairResourceType: {resource.FlagDeepMode},
AwsKmsAliasResourceType: {resource.FlagDeepMode}, aws.AwsKmsAliasResourceType: {resource.FlagDeepMode},
AwsKmsKeyResourceType: {resource.FlagDeepMode}, aws.AwsKmsKeyResourceType: {resource.FlagDeepMode},
AwsLambdaEventSourceMappingResourceType: {resource.FlagDeepMode}, aws.AwsLambdaEventSourceMappingResourceType: {resource.FlagDeepMode},
AwsLambdaFunctionResourceType: {resource.FlagDeepMode}, aws.AwsLambdaFunctionResourceType: {resource.FlagDeepMode},
AwsNatGatewayResourceType: {resource.FlagDeepMode}, aws.AwsNatGatewayResourceType: {resource.FlagDeepMode},
AwsNetworkACLResourceType: {resource.FlagDeepMode}, aws.AwsNetworkACLResourceType: {resource.FlagDeepMode},
AwsRDSClusterResourceType: {resource.FlagDeepMode}, aws.AwsRDSClusterResourceType: {resource.FlagDeepMode},
AwsRDSClusterInstanceResourceType: {}, aws.AwsRDSClusterInstanceResourceType: {},
AwsRouteResourceType: {resource.FlagDeepMode}, aws.AwsRouteResourceType: {resource.FlagDeepMode},
AwsRoute53HealthCheckResourceType: {resource.FlagDeepMode}, aws.AwsRoute53HealthCheckResourceType: {resource.FlagDeepMode},
AwsRoute53RecordResourceType: {resource.FlagDeepMode}, aws.AwsRoute53RecordResourceType: {resource.FlagDeepMode},
AwsRoute53ZoneResourceType: {resource.FlagDeepMode}, aws.AwsRoute53ZoneResourceType: {resource.FlagDeepMode},
AwsRouteTableResourceType: {resource.FlagDeepMode}, aws.AwsRouteTableResourceType: {resource.FlagDeepMode},
AwsRouteTableAssociationResourceType: {resource.FlagDeepMode}, aws.AwsRouteTableAssociationResourceType: {resource.FlagDeepMode},
AwsS3BucketResourceType: {resource.FlagDeepMode}, aws.AwsS3BucketResourceType: {resource.FlagDeepMode},
AwsS3BucketAnalyticsConfigurationResourceType: {resource.FlagDeepMode}, aws.AwsS3BucketAnalyticsConfigurationResourceType: {resource.FlagDeepMode},
AwsS3BucketInventoryResourceType: {resource.FlagDeepMode}, aws.AwsS3BucketInventoryResourceType: {resource.FlagDeepMode},
AwsS3BucketMetricResourceType: {resource.FlagDeepMode}, aws.AwsS3BucketMetricResourceType: {resource.FlagDeepMode},
AwsS3BucketNotificationResourceType: {resource.FlagDeepMode}, aws.AwsS3BucketNotificationResourceType: {resource.FlagDeepMode},
AwsS3BucketPolicyResourceType: {resource.FlagDeepMode}, aws.AwsS3BucketPolicyResourceType: {resource.FlagDeepMode},
AwsS3BucketPublicAccessBlockResourceType: {}, aws.AwsS3BucketPublicAccessBlockResourceType: {},
AwsSecurityGroupResourceType: {resource.FlagDeepMode}, aws.AwsSecurityGroupResourceType: {resource.FlagDeepMode},
AwsSnsTopicResourceType: {resource.FlagDeepMode}, aws.AwsSnsTopicResourceType: {resource.FlagDeepMode},
AwsSnsTopicPolicyResourceType: {resource.FlagDeepMode}, aws.AwsSnsTopicPolicyResourceType: {resource.FlagDeepMode},
AwsSnsTopicSubscriptionResourceType: {resource.FlagDeepMode}, aws.AwsSnsTopicSubscriptionResourceType: {resource.FlagDeepMode},
AwsSqsQueueResourceType: {resource.FlagDeepMode}, aws.AwsSqsQueueResourceType: {resource.FlagDeepMode},
AwsSqsQueuePolicyResourceType: {resource.FlagDeepMode}, aws.AwsSqsQueuePolicyResourceType: {resource.FlagDeepMode},
AwsSubnetResourceType: {resource.FlagDeepMode}, aws.AwsSubnetResourceType: {resource.FlagDeepMode},
AwsVpcResourceType: {resource.FlagDeepMode}, aws.AwsVpcResourceType: {resource.FlagDeepMode},
AwsSecurityGroupRuleResourceType: {resource.FlagDeepMode}, aws.AwsSecurityGroupRuleResourceType: {resource.FlagDeepMode},
AwsNetworkACLRuleResourceType: {resource.FlagDeepMode}, aws.AwsNetworkACLRuleResourceType: {resource.FlagDeepMode},
AwsLaunchTemplateResourceType: {resource.FlagDeepMode}, aws.AwsLaunchTemplateResourceType: {resource.FlagDeepMode},
AwsLaunchConfigurationResourceType: {}, aws.AwsLaunchConfigurationResourceType: {},
AwsLoadBalancerResourceType: {}, aws.AwsLoadBalancerResourceType: {},
AwsApplicationLoadBalancerResourceType: {}, aws.AwsApplicationLoadBalancerResourceType: {},
AwsClassicLoadBalancerResourceType: {}, aws.AwsClassicLoadBalancerResourceType: {},
AwsLoadBalancerListenerResourceType: {}, aws.AwsLoadBalancerListenerResourceType: {},
AwsApplicationLoadBalancerListenerResourceType: {}, aws.AwsApplicationLoadBalancerListenerResourceType: {},
AwsIamGroupResourceType: {}, aws.AwsIamGroupResourceType: {},
AwsEcrRepositoryPolicyResourceType: {}, aws.AwsEcrRepositoryPolicyResourceType: {},
} }
schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0")
InitResourcesMetadata(schemaRepository) aws.InitResourcesMetadata(schemaRepository)
for ty, flags := range testcases { for ty, flags := range testcases {
t.Run(ty, func(tt *testing.T) { t.Run(ty, func(tt *testing.T) {

View File

@ -1,6 +1,8 @@
package aws package aws
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/pkg/resource"
)
func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) {
initAwsAmiMetaData(resourceSchemaRepository) initAwsAmiMetaData(resourceSchemaRepository)

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzureContainerRegistryResourceType = "azurerm_container_registry" const AzureContainerRegistryResourceType = "azurerm_container_registry"
func initAzureContainerRegistryMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzureContainerRegistryMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureContainerRegistryResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureContainerRegistryResourceType, func(res *resource.Resource) map[string]string {
val := res.Attrs val := res.Attrs
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzureFirewallResourceType = "azurerm_firewall" const AzureFirewallResourceType = "azurerm_firewall"
func initAzureFirewallMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzureFirewallMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureFirewallResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureFirewallResourceType, func(res *resource.Resource) map[string]string {
val := res.Attrs val := res.Attrs
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzureImageResourceType = "azurerm_image" const AzureImageResourceType = "azurerm_image"
func initAzureImageMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzureImageMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureImageResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureImageResourceType, func(res *resource.Resource) map[string]string {
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzureLoadBalancerResourceType = "azurerm_lb" const AzureLoadBalancerResourceType = "azurerm_lb"
func initAzureLoadBalancerMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzureLoadBalancerMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureLoadBalancerResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureLoadBalancerResourceType, func(res *resource.Resource) map[string]string {
val := res.Attrs val := res.Attrs
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzureLoadBalancerRuleResourceType = "azurerm_lb_rule" const AzureLoadBalancerRuleResourceType = "azurerm_lb_rule"
func initAzureLoadBalancerRuleMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzureLoadBalancerRuleMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"timeouts"})
}) })

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzureNetworkSecurityGroupResourceType = "azurerm_network_security_group" const AzureNetworkSecurityGroupResourceType = "azurerm_network_security_group"
func initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AzureNetworkSecurityGroupResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AzureNetworkSecurityGroupResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"timeouts"})
}) })

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzurePostgresqlDatabaseResourceType = "azurerm_postgresql_database" const AzurePostgresqlDatabaseResourceType = "azurerm_postgresql_database"
func initAzurePostgresqlDatabaseMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzurePostgresqlDatabaseMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePostgresqlDatabaseResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePostgresqlDatabaseResourceType, func(res *resource.Resource) map[string]string {
val := res.Attrs val := res.Attrs
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzurePostgresqlServerResourceType = "azurerm_postgresql_server" const AzurePostgresqlServerResourceType = "azurerm_postgresql_server"
func initAzurePostgresqlServerMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzurePostgresqlServerMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePostgresqlServerResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePostgresqlServerResourceType, func(res *resource.Resource) map[string]string {
val := res.Attrs val := res.Attrs
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzurePrivateDNSARecordResourceType = "azurerm_private_dns_a_record" const AzurePrivateDNSARecordResourceType = "azurerm_private_dns_a_record"
func initAzurePrivateDNSARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzurePrivateDNSARecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSARecordResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSARecordResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"timeouts"})
}) })

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzurePrivateDNSAAAARecordResourceType = "azurerm_private_dns_aaaa_record" const AzurePrivateDNSAAAARecordResourceType = "azurerm_private_dns_aaaa_record"
func initAzurePrivateDNSAAAARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzurePrivateDNSAAAARecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSAAAARecordResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSAAAARecordResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"timeouts"})
}) })

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzurePrivateDNSCNameRecordResourceType = "azurerm_private_dns_cname_record" const AzurePrivateDNSCNameRecordResourceType = "azurerm_private_dns_cname_record"
func initAzurePrivateDNSCNameRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzurePrivateDNSCNameRecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSCNameRecordResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSCNameRecordResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"timeouts"})
}) })

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzurePrivateDNSMXRecordResourceType = "azurerm_private_dns_mx_record" const AzurePrivateDNSMXRecordResourceType = "azurerm_private_dns_mx_record"
func initAzurePrivateDNSMXRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzurePrivateDNSMXRecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"timeouts"})
}) })

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzurePrivateDNSPTRRecordResourceType = "azurerm_private_dns_ptr_record" const AzurePrivateDNSPTRRecordResourceType = "azurerm_private_dns_ptr_record"
func initAzurePrivateDNSPTRRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzurePrivateDNSPTRRecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSPTRRecordResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSPTRRecordResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"timeouts"})
}) })

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzurePrivateDNSSRVRecordResourceType = "azurerm_private_dns_srv_record" const AzurePrivateDNSSRVRecordResourceType = "azurerm_private_dns_srv_record"
func initAzurePrivateDNSSRVRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzurePrivateDNSSRVRecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSSRVRecordResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSSRVRecordResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"timeouts"})
}) })

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzurePrivateDNSTXTRecordResourceType = "azurerm_private_dns_txt_record" const AzurePrivateDNSTXTRecordResourceType = "azurerm_private_dns_txt_record"
func initAzurePrivateDNSTXTRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzurePrivateDNSTXTRecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSTXTRecordResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSTXTRecordResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"timeouts"})
}) })

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzurePrivateDNSZoneResourceType = "azurerm_private_dns_zone" const AzurePrivateDNSZoneResourceType = "azurerm_private_dns_zone"
func initAzurePrivateDNSZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzurePrivateDNSZoneMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSZoneResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSZoneResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"number_of_record_sets"}) res.Attributes().SafeDelete([]string{"number_of_record_sets"})
res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"timeouts"})

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzurePublicIPResourceType = "azurerm_public_ip" const AzurePublicIPResourceType = "azurerm_public_ip"
func initAzurePublicIPMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzurePublicIPMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePublicIPResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePublicIPResourceType, func(res *resource.Resource) map[string]string {
val := res.Attrs val := res.Attrs
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzureResourceGroupResourceType = "azurerm_resource_group" const AzureResourceGroupResourceType = "azurerm_resource_group"
func initAzureResourceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzureResourceGroupMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureResourceGroupResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureResourceGroupResourceType, func(res *resource.Resource) map[string]string {
val := res.Attrs val := res.Attrs
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzureRouteResourceType = "azurerm_route" const AzureRouteResourceType = "azurerm_route"
func initAzureRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzureRouteMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureRouteResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureRouteResourceType, func(res *resource.Resource) map[string]string {
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzureRouteTableResourceType = "azurerm_route_table" const AzureRouteTableResourceType = "azurerm_route_table"
func initAzureRouteTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzureRouteTableMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureRouteTableResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureRouteTableResourceType, func(res *resource.Resource) map[string]string {
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzureSSHPublicKeyResourceType = "azurerm_ssh_public_key" const AzureSSHPublicKeyResourceType = "azurerm_ssh_public_key"
func initAzureSSHPublicKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzureSSHPublicKeyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(AzureSSHPublicKeyResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(AzureSSHPublicKeyResourceType, func(res *resource.Resource) {
res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"timeouts"})
}) })

View File

@ -1,10 +1,13 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
)
const AzureVirtualNetworkResourceType = "azurerm_virtual_network" const AzureVirtualNetworkResourceType = "azurerm_virtual_network"
func initAzureVirtualNetworkMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initAzureVirtualNetworkMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureVirtualNetworkResourceType, func(res *resource.Resource) map[string]string { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureVirtualNetworkResourceType, func(res *resource.Resource) map[string]string {
attrs := make(map[string]string) attrs := make(map[string]string)

View File

@ -1,6 +1,8 @@
package azurerm package azurerm
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/pkg/resource"
)
func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) {
initAzureContainerRegistryMetadata(resourceSchemaRepository) initAzureContainerRegistryMetadata(resourceSchemaRepository)

View File

@ -1,44 +1,45 @@
package azurerm package azurerm_test
import ( import (
"testing" "testing"
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/pkg/resource/azurerm"
testresource "github.com/snyk/driftctl/test/resource" testresource "github.com/snyk/driftctl/test/resource"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestAzureMetadata_Flags(t *testing.T) { func TestAzureMetadata_Flags(t *testing.T) {
testcases := map[string][]resource.Flags{ testcases := map[string][]resource.Flags{
AzureContainerRegistryResourceType: {}, azurerm.AzureContainerRegistryResourceType: {},
AzureFirewallResourceType: {}, azurerm.AzureFirewallResourceType: {},
AzurePostgresqlServerResourceType: {}, azurerm.AzurePostgresqlServerResourceType: {},
AzurePostgresqlDatabaseResourceType: {}, azurerm.AzurePostgresqlDatabaseResourceType: {},
AzurePublicIPResourceType: {}, azurerm.AzurePublicIPResourceType: {},
AzureResourceGroupResourceType: {}, azurerm.AzureResourceGroupResourceType: {},
AzureRouteResourceType: {}, azurerm.AzureRouteResourceType: {},
AzureRouteTableResourceType: {}, azurerm.AzureRouteTableResourceType: {},
AzureStorageAccountResourceType: {}, azurerm.AzureStorageAccountResourceType: {},
AzureStorageContainerResourceType: {}, azurerm.AzureStorageContainerResourceType: {},
AzureSubnetResourceType: {}, azurerm.AzureSubnetResourceType: {},
AzureVirtualNetworkResourceType: {}, azurerm.AzureVirtualNetworkResourceType: {},
AzureNetworkSecurityGroupResourceType: {resource.FlagDeepMode}, azurerm.AzureNetworkSecurityGroupResourceType: {resource.FlagDeepMode},
AzureLoadBalancerResourceType: {}, azurerm.AzureLoadBalancerResourceType: {},
AzurePrivateDNSZoneResourceType: {resource.FlagDeepMode}, azurerm.AzurePrivateDNSZoneResourceType: {resource.FlagDeepMode},
AzurePrivateDNSARecordResourceType: {resource.FlagDeepMode}, azurerm.AzurePrivateDNSARecordResourceType: {resource.FlagDeepMode},
AzurePrivateDNSAAAARecordResourceType: {resource.FlagDeepMode}, azurerm.AzurePrivateDNSAAAARecordResourceType: {resource.FlagDeepMode},
AzurePrivateDNSCNameRecordResourceType: {resource.FlagDeepMode}, azurerm.AzurePrivateDNSCNameRecordResourceType: {resource.FlagDeepMode},
AzurePrivateDNSPTRRecordResourceType: {resource.FlagDeepMode}, azurerm.AzurePrivateDNSPTRRecordResourceType: {resource.FlagDeepMode},
AzurePrivateDNSMXRecordResourceType: {resource.FlagDeepMode}, azurerm.AzurePrivateDNSMXRecordResourceType: {resource.FlagDeepMode},
AzurePrivateDNSSRVRecordResourceType: {resource.FlagDeepMode}, azurerm.AzurePrivateDNSSRVRecordResourceType: {resource.FlagDeepMode},
AzurePrivateDNSTXTRecordResourceType: {resource.FlagDeepMode}, azurerm.AzurePrivateDNSTXTRecordResourceType: {resource.FlagDeepMode},
AzureImageResourceType: {}, azurerm.AzureImageResourceType: {},
AzureSSHPublicKeyResourceType: {resource.FlagDeepMode}, azurerm.AzureSSHPublicKeyResourceType: {resource.FlagDeepMode},
AzureLoadBalancerRuleResourceType: {resource.FlagDeepMode}, azurerm.AzureLoadBalancerRuleResourceType: {resource.FlagDeepMode},
} }
schemaRepository := testresource.InitFakeSchemaRepository("azurerm", "2.71.0") schemaRepository := testresource.InitFakeSchemaRepository("azurerm", "2.71.0")
InitResourcesMetadata(schemaRepository) azurerm.InitResourcesMetadata(schemaRepository)
for ty, flags := range testcases { for ty, flags := range testcases {
t.Run(ty, func(tt *testing.T) { t.Run(ty, func(tt *testing.T) {

View File

@ -1,16 +1,18 @@
package resource package resource
import "github.com/snyk/driftctl/enumeration/resource" import (
"github.com/snyk/driftctl/enumeration/resource"
)
type ResourceFactory interface { type ResourceFactory interface {
CreateAbstractResource(ty, id string, data map[string]interface{}) *resource.Resource CreateAbstractResource(ty, id string, data map[string]interface{}) *resource.Resource
} }
type DriftctlResourceFactory struct { type DriftctlResourceFactory struct {
resourceSchemaRepository resource.SchemaRepositoryInterface resourceSchemaRepository SchemaRepositoryInterface
} }
func NewDriftctlResourceFactory(resourceSchemaRepository resource.SchemaRepositoryInterface) *DriftctlResourceFactory { func NewDriftctlResourceFactory(resourceSchemaRepository SchemaRepositoryInterface) *DriftctlResourceFactory {
return &DriftctlResourceFactory{ return &DriftctlResourceFactory{
resourceSchemaRepository: resourceSchemaRepository, resourceSchemaRepository: resourceSchemaRepository,
} }
@ -28,7 +30,7 @@ func (r *DriftctlResourceFactory) CreateAbstractResource(ty, id string, data map
Sch: schema, Sch: schema,
} }
schema, exist := r.resourceSchemaRepository.(*resource.SchemaRepository).GetSchema(ty) schema, exist := r.resourceSchemaRepository.GetSchema(ty)
if exist && schema.NormalizeFunc != nil { if exist && schema.NormalizeFunc != nil {
schema.NormalizeFunc(&res) schema.NormalizeFunc(&res)
} }

View File

@ -2,13 +2,13 @@ package github
import ( import (
"encoding/base64" "encoding/base64"
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
) )
const GithubBranchProtectionResourceType = "github_branch_protection" const GithubBranchProtectionResourceType = "github_branch_protection"
func initGithubBranchProtectionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initGithubBranchProtectionMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(GithubBranchProtectionResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(GithubBranchProtectionResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"repository_id"}) // Terraform provider is always returning nil val.SafeDelete([]string{"repository_id"}) // Terraform provider is always returning nil

View File

@ -2,11 +2,12 @@ package github
import ( import (
"github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource"
dctlresource "github.com/snyk/driftctl/pkg/resource"
) )
const GithubMembershipResourceType = "github_membership" const GithubMembershipResourceType = "github_membership"
func initGithubMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { func initGithubMembershipMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) {
resourceSchemaRepository.SetNormalizeFunc(GithubMembershipResourceType, func(res *resource.Resource) { resourceSchemaRepository.SetNormalizeFunc(GithubMembershipResourceType, func(res *resource.Resource) {
val := res.Attrs val := res.Attrs
val.SafeDelete([]string{"etag"}) val.SafeDelete([]string{"etag"})

Some files were not shown because too many files have changed in this diff Show More