Merge pull request #924 from cloudskiff/remove_useless_detail_fetcher
Remove useless details fetchersmain
commit
2f575018f6
|
@ -1,39 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type DynamoDBTableDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewDynamoDBTableDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *DynamoDBTableDetailsFetcher {
|
||||
return &DynamoDBTableDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *DynamoDBTableDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: resource.ResourceType(res.TerraformType()),
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"table_name": res.TerraformId(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsDynamodbTableResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type EC2DefaultRouteTableDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewEC2DefaultRouteTableDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *EC2DefaultRouteTableDetailsFetcher {
|
||||
return &EC2DefaultRouteTableDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *EC2DefaultRouteTableDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsDefaultRouteTableResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"vpc_id": *res.Attributes().GetString("vpc_id"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsDefaultRouteTableResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type EC2RouteDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewEC2RouteDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *EC2RouteDetailsFetcher {
|
||||
return &EC2RouteDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *EC2RouteDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
attributes := map[string]string{
|
||||
"route_table_id": *res.Attributes().GetString("route_table_id"),
|
||||
}
|
||||
if ipv4 := res.Attributes().GetString("destination_cidr_block"); ipv4 != nil && *ipv4 != "" {
|
||||
attributes["destination_cidr_block"] = *ipv4
|
||||
}
|
||||
if ipv6 := res.Attributes().GetString("destination_ipv6_cidr_block"); ipv6 != nil && *ipv6 != "" {
|
||||
attributes["destination_ipv6_cidr_block"] = *ipv6
|
||||
}
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsRouteResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: attributes,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsRouteResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type EC2RouteTableAssociationDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewEC2RouteTableAssociationDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *EC2RouteTableAssociationDetailsFetcher {
|
||||
return &EC2RouteTableAssociationDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *EC2RouteTableAssociationDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsRouteTableAssociationResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"route_table_id": *res.Attributes().GetString("route_table_id"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsRouteTableAssociationResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type IamAccessKeyDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewIamAccessKeyDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *IamAccessKeyDetailsFetcher {
|
||||
return &IamAccessKeyDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *IamAccessKeyDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsIamAccessKeyResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"user": *res.Attributes().GetString("user"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsIamAccessKeyResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type IamRolePolicyAttachmentDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewIamRolePolicyAttachmentDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *IamRolePolicyAttachmentDetailsFetcher {
|
||||
return &IamRolePolicyAttachmentDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *IamRolePolicyAttachmentDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsIamRolePolicyAttachmentResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"role": *res.Attributes().GetString("role"),
|
||||
"policy_arn": *res.Attributes().GetString("policy_arn"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsIamRolePolicyAttachmentResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type IamUserPolicyAttachmentDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewIamUserPolicyAttachmentDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *IamUserPolicyAttachmentDetailsFetcher {
|
||||
return &IamUserPolicyAttachmentDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *IamUserPolicyAttachmentDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsIamUserPolicyAttachmentResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"user": *res.Attributes().GetString("user"),
|
||||
"policy_arn": *res.Attributes().GetString("policy_arn"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsIamUserPolicyAttachmentResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -56,17 +56,17 @@ func Init(version string, alerter *alerter.Alerter,
|
|||
providerLibrary.AddProvider(terraform.AWS, provider)
|
||||
|
||||
remoteLibrary.AddEnumerator(NewS3BucketEnumerator(s3Repository, factory, provider.Config, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketResourceType, NewS3BucketDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewS3BucketInventoryEnumerator(s3Repository, factory, provider.Config, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketInventoryResourceType, NewS3BucketInventoryDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketInventoryResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketInventoryResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewS3BucketNotificationEnumerator(s3Repository, factory, provider.Config, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketNotificationResourceType, NewS3BucketNotificationDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketNotificationResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketNotificationResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewS3BucketMetricsEnumerator(s3Repository, factory, provider.Config, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketMetricResourceType, NewS3BucketMetricsDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketMetricResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketMetricResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewS3BucketPolicyEnumerator(s3Repository, factory, provider.Config, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketPolicyResourceType, NewS3BucketPolicyDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketPolicyResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewS3BucketAnalyticEnumerator(s3Repository, factory, provider.Config, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketAnalyticsConfigurationResourceType, NewS3BucketAnalyticDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketAnalyticsConfigurationResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketAnalyticsConfigurationResourceType, provider, deserializer))
|
||||
|
||||
remoteLibrary.AddEnumerator(NewEC2EbsVolumeEnumerator(ec2repository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsEbsVolumeResourceType, common.NewGenericDetailsFetcher(aws.AwsEbsVolumeResourceType, provider, deserializer))
|
||||
|
@ -91,9 +91,9 @@ func Init(version string, alerter *alerter.Alerter,
|
|||
remoteLibrary.AddEnumerator(NewEC2RouteTableEnumerator(ec2repository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsRouteTableResourceType, common.NewGenericDetailsFetcher(aws.AwsRouteTableResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewEC2DefaultRouteTableEnumerator(ec2repository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsDefaultRouteTableResourceType, NewEC2DefaultRouteTableDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsDefaultRouteTableResourceType, common.NewGenericDetailsFetcher(aws.AwsDefaultRouteTableResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewEC2RouteTableAssociationEnumerator(ec2repository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsRouteTableAssociationResourceType, NewEC2RouteTableAssociationDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsRouteTableAssociationResourceType, common.NewGenericDetailsFetcher(aws.AwsRouteTableAssociationResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewEC2SubnetEnumerator(ec2repository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsSubnetResourceType, common.NewGenericDetailsFetcher(aws.AwsSubnetResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewEC2DefaultSubnetEnumerator(ec2repository, factory))
|
||||
|
@ -105,9 +105,9 @@ func Init(version string, alerter *alerter.Alerter,
|
|||
remoteLibrary.AddEnumerator(NewEC2NatGatewayEnumerator(ec2repository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsNatGatewayResourceType, common.NewGenericDetailsFetcher(aws.AwsNatGatewayResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewEC2RouteEnumerator(ec2repository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsRouteResourceType, NewEC2RouteDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsRouteResourceType, common.NewGenericDetailsFetcher(aws.AwsRouteResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewVPCSecurityGroupRuleEnumerator(ec2repository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsSecurityGroupRuleResourceType, NewVPCSecurityGroupRuleDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsSecurityGroupRuleResourceType, common.NewGenericDetailsFetcher(aws.AwsSecurityGroupRuleResourceType, provider, deserializer))
|
||||
|
||||
remoteLibrary.AddEnumerator(NewKMSKeyEnumerator(kmsRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsKmsKeyResourceType, common.NewGenericDetailsFetcher(aws.AwsKmsKeyResourceType, provider, deserializer))
|
||||
|
@ -135,20 +135,20 @@ func Init(version string, alerter *alerter.Alerter,
|
|||
remoteLibrary.AddDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, provider, deserializer))
|
||||
|
||||
remoteLibrary.AddEnumerator(NewSNSTopicEnumerator(snsRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicResourceType, NewSNSTopicDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicResourceType, common.NewGenericDetailsFetcher(aws.AwsSnsTopicResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewSNSTopicPolicyEnumerator(snsRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicPolicyResourceType, NewSNSTopicPolicyDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsSnsTopicPolicyResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewSNSTopicSubscriptionEnumerator(snsRepository, factory, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicSubscriptionResourceType, NewSNSTopicSubscriptionDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicSubscriptionResourceType, common.NewGenericDetailsFetcher(aws.AwsSnsTopicSubscriptionResourceType, provider, deserializer))
|
||||
|
||||
remoteLibrary.AddEnumerator(NewDynamoDBTableEnumerator(dynamoDBRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsDynamodbTableResourceType, NewDynamoDBTableDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsDynamodbTableResourceType, common.NewGenericDetailsFetcher(aws.AwsDynamodbTableResourceType, provider, deserializer))
|
||||
|
||||
remoteLibrary.AddEnumerator(NewIamPolicyEnumerator(iamRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsIamPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsIamPolicyResourceType, provider, deserializer))
|
||||
|
||||
remoteLibrary.AddEnumerator(NewLambdaFunctionEnumerator(lambdaRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsLambdaFunctionResourceType, NewLambdaFunctionDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsLambdaFunctionResourceType, common.NewGenericDetailsFetcher(aws.AwsLambdaFunctionResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewLambdaEventSourceMappingEnumerator(lambdaRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsLambdaEventSourceMappingResourceType, common.NewGenericDetailsFetcher(aws.AwsLambdaEventSourceMappingResourceType, provider, deserializer))
|
||||
|
||||
|
@ -159,13 +159,13 @@ func Init(version string, alerter *alerter.Alerter,
|
|||
remoteLibrary.AddEnumerator(NewIamRoleEnumerator(iamRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsIamRoleResourceType, common.NewGenericDetailsFetcher(aws.AwsIamRoleResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewIamAccessKeyEnumerator(iamRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsIamAccessKeyResourceType, NewIamAccessKeyDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsIamAccessKeyResourceType, common.NewGenericDetailsFetcher(aws.AwsIamAccessKeyResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewIamRolePolicyAttachmentEnumerator(iamRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsIamRolePolicyAttachmentResourceType, NewIamRolePolicyAttachmentDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsIamRolePolicyAttachmentResourceType, common.NewGenericDetailsFetcher(aws.AwsIamRolePolicyAttachmentResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewIamRolePolicyEnumerator(iamRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsIamRolePolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsIamRolePolicyResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewIamUserPolicyAttachmentEnumerator(iamRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsIamUserPolicyAttachmentResourceType, NewIamUserPolicyAttachmentDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsIamUserPolicyAttachmentResourceType, common.NewGenericDetailsFetcher(aws.AwsIamUserPolicyAttachmentResourceType, provider, deserializer))
|
||||
|
||||
remoteLibrary.AddEnumerator(NewECRRepositoryEnumerator(ecrRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsEcrRepositoryResourceType, common.NewGenericDetailsFetcher(aws.AwsEcrRepositoryResourceType, provider, deserializer))
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
resourceaws "github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type LambdaFunctionDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewLambdaFunctionDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *LambdaFunctionDetailsFetcher {
|
||||
return &LambdaFunctionDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *LambdaFunctionDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
val, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
ID: res.TerraformId(),
|
||||
Ty: resourceaws.AwsLambdaFunctionResourceType,
|
||||
Attributes: map[string]string{
|
||||
"function_name": res.TerraformId(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return nil, remoteerror.NewResourceScanningError(err, resourceaws.AwsLambdaFunctionResourceType, res.TerraformId())
|
||||
}
|
||||
return r.deserializer.DeserializeOne(resourceaws.AwsLambdaFunctionResourceType, *val)
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type S3BucketAnalyticDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewS3BucketAnalyticDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *S3BucketAnalyticDetailsFetcher {
|
||||
return &S3BucketAnalyticDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *S3BucketAnalyticDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsS3BucketAnalyticsConfigurationResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsS3BucketAnalyticsConfigurationResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type S3BucketDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewS3BucketDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *S3BucketDetailsFetcher {
|
||||
return &S3BucketDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *S3BucketDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsS3BucketResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsS3BucketResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type S3BucketInventoryDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewS3BucketInventoryDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *S3BucketInventoryDetailsFetcher {
|
||||
return &S3BucketInventoryDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *S3BucketInventoryDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsS3BucketInventoryResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsS3BucketInventoryResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type S3BucketMetricsDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewS3BucketMetricsDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *S3BucketMetricsDetailsFetcher {
|
||||
return &S3BucketMetricsDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *S3BucketMetricsDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsS3BucketMetricResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsS3BucketMetricResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type S3BucketNotificationDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewS3BucketNotificationDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *S3BucketNotificationDetailsFetcher {
|
||||
return &S3BucketNotificationDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *S3BucketNotificationDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsS3BucketNotificationResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsS3BucketNotificationResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type S3BucketPolicyDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewS3BucketPolicyDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *S3BucketPolicyDetailsFetcher {
|
||||
return &S3BucketPolicyDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *S3BucketPolicyDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsS3BucketPolicyResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsS3BucketPolicyResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type SNSTopicDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewSNSTopicDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *SNSTopicDetailsFetcher {
|
||||
return &SNSTopicDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *SNSTopicDetailsFetcher) ReadDetails(topic *resource.Resource) (*resource.Resource, error) {
|
||||
val, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
ID: topic.TerraformId(),
|
||||
Ty: aws.AwsSnsTopicResourceType,
|
||||
Attributes: map[string]string{
|
||||
"topic_arn": topic.TerraformId(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return nil, remoteerror.NewResourceScanningError(err, topic.TerraformType(), topic.TerraformId())
|
||||
}
|
||||
return r.deserializer.DeserializeOne(aws.AwsSnsTopicResourceType, *val)
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type SNSTopicPolicyDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewSNSTopicPolicyDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *SNSTopicPolicyDetailsFetcher {
|
||||
return &SNSTopicPolicyDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *SNSTopicPolicyDetailsFetcher) ReadDetails(topic *resource.Resource) (*resource.Resource, error) {
|
||||
val, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
ID: topic.TerraformId(),
|
||||
Ty: aws.AwsSnsTopicPolicyResourceType,
|
||||
Attributes: map[string]string{
|
||||
"topic_arn": topic.TerraformId(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return nil, remoteerror.NewResourceScanningError(err, topic.TerraformType(), topic.TerraformId())
|
||||
}
|
||||
return r.deserializer.DeserializeOne(aws.AwsSnsTopicPolicyResourceType, *val)
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
)
|
||||
|
||||
type SNSTopicSubscriptionDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewSNSTopicSubscriptionDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *SNSTopicSubscriptionDetailsFetcher {
|
||||
return &SNSTopicSubscriptionDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *SNSTopicSubscriptionDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
ID: res.TerraformId(),
|
||||
Ty: aws.AwsSnsTopicSubscriptionResourceType,
|
||||
Attributes: map[string]string{
|
||||
"SubscriptionId": res.TerraformId(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsSnsTopicSubscriptionResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
"github.com/hashicorp/terraform/flatmap"
|
||||
)
|
||||
|
||||
type VPCSecurityGroupRuleDetailsFetcher struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer *resource.Deserializer
|
||||
}
|
||||
|
||||
func NewVPCSecurityGroupRuleDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *VPCSecurityGroupRuleDetailsFetcher {
|
||||
return &VPCSecurityGroupRuleDetailsFetcher{
|
||||
reader: provider,
|
||||
deserializer: deserializer,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *VPCSecurityGroupRuleDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) {
|
||||
attrs := make(map[string]interface{})
|
||||
|
||||
if v, ok := res.Attributes().Get("type"); ok {
|
||||
attrs["type"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("protocol"); ok {
|
||||
attrs["protocol"] = v
|
||||
}
|
||||
if v := res.Attributes().GetInt("from_port"); v != nil {
|
||||
attrs["from_port"] = *v
|
||||
}
|
||||
if v := res.Attributes().GetInt("to_port"); v != nil {
|
||||
attrs["to_port"] = *v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("security_group_id"); ok {
|
||||
attrs["security_group_id"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("self"); ok {
|
||||
attrs["self"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("cidr_blocks"); ok {
|
||||
attrs["cidr_blocks"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("ipv6_cidr_blocks"); ok {
|
||||
attrs["ipv6_cidr_blocks"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("prefix_list_ids"); ok {
|
||||
attrs["prefix_list_ids"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("source_security_group_id"); ok {
|
||||
attrs["source_security_group_id"] = v
|
||||
}
|
||||
|
||||
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: aws.AwsSecurityGroupRuleResourceType,
|
||||
ID: res.TerraformId(),
|
||||
Attributes: flatmap.Flatten(attrs),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType(), res.TerraformId())
|
||||
}
|
||||
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsSecurityGroupRuleResourceType, *ctyVal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deserializedRes, nil
|
||||
}
|
|
@ -102,7 +102,7 @@ func TestDynamoDBTable(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewDynamoDBTableEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, aws.NewDynamoDBTableDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
|
|
@ -1132,14 +1132,14 @@ func TestEC2RouteTableAssociation(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewEC2RouteTableAssociationEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, aws.NewEC2RouteTableAssociationDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
||||
s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter)
|
||||
got, err := s.Resources()
|
||||
assert.Equal(tt, err, c.wantErr)
|
||||
assert.Equal(tt, c.wantErr, err)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -1566,7 +1566,7 @@ func TestEC2DefaultRouteTable(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewEC2DefaultRouteTableEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, aws.NewEC2DefaultRouteTableDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -2025,7 +2025,7 @@ func TestEC2Route(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewEC2RouteEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteResourceType, aws.NewEC2RouteDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -2211,7 +2211,7 @@ func TestVpcSecurityGroupRule(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewVPCSecurityGroupRuleEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, aws.NewVPCSecurityGroupRuleDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
|
|
@ -635,7 +635,7 @@ func TestIamRolePolicyAttachment(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(remoteaws.NewIamRolePolicyAttachmentEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, remoteaws.NewIamRolePolicyAttachmentDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -765,7 +765,7 @@ func TestIamAccessKey(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(remoteaws.NewIamAccessKeyEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, remoteaws.NewIamAccessKeyDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -970,7 +970,7 @@ func TestIamUserPolicyAttachment(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(remoteaws.NewIamUserPolicyAttachmentEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, remoteaws.NewIamUserPolicyAttachmentDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -1100,7 +1100,7 @@ func TestIamRolePolicy(t *testing.T) {
|
|||
|
||||
s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter)
|
||||
got, err := s.Resources()
|
||||
assert.Equal(tt, err, c.wantErr)
|
||||
assert.Equal(tt, c.wantErr, err)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ func TestScanLambdaFunction(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewLambdaFunctionEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, aws.NewLambdaFunctionDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
|
|
@ -126,7 +126,7 @@ func TestS3Bucket(t *testing.T) {
|
|||
Name: "test",
|
||||
DefaultAlias: "eu-west-3",
|
||||
}, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketResourceType, aws.NewS3BucketDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -279,7 +279,7 @@ func TestS3BucketInventory(t *testing.T) {
|
|||
Name: "test",
|
||||
DefaultAlias: "eu-west-3",
|
||||
}, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, aws.NewS3BucketInventoryDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -458,7 +458,7 @@ func TestS3BucketNotification(t *testing.T) {
|
|||
Name: "test",
|
||||
DefaultAlias: "eu-west-3",
|
||||
}, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, aws.NewS3BucketNotificationDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -613,7 +613,7 @@ func TestS3BucketMetrics(t *testing.T) {
|
|||
Name: "test",
|
||||
DefaultAlias: "eu-west-3",
|
||||
}, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, aws.NewS3BucketMetricsDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -767,7 +767,7 @@ func TestS3BucketPolicy(t *testing.T) {
|
|||
Name: "test",
|
||||
DefaultAlias: "eu-west-3",
|
||||
}, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, aws.NewS3BucketPolicyDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -924,7 +924,7 @@ func TestS3BucketAnalytic(t *testing.T) {
|
|||
Name: "test",
|
||||
DefaultAlias: "eu-west-3",
|
||||
}, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, aws.NewS3BucketAnalyticDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
|
|
@ -109,7 +109,7 @@ func TestScanSNSTopic(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewSNSTopicEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicResourceType, aws.NewSNSTopicDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -205,7 +205,7 @@ func TestSNSTopicPolicyScan(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewSNSTopicPolicyEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, aws.NewSNSTopicPolicyDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
@ -328,7 +328,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) {
|
|||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewSNSTopicSubscriptionEnumerator(repo, factory, alerter))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, aws.NewSNSTopicSubscriptionDetailsFetcher(provider, deserializer))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsDefaultRouteTableResourceType = "aws_default_route_table"
|
||||
|
||||
func initAwsDefaultRouteTableMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsDefaultRouteTableResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"vpc_id": *res.Attributes().GetString("vpc_id"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -7,6 +7,11 @@ import (
|
|||
const AwsDynamodbTableResourceType = "aws_dynamodb_table"
|
||||
|
||||
func initAwsDynamodbTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsDynamodbTableResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"table_name": res.TerraformId(),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.SetNormalizeFunc(AwsDynamodbTableResourceType, func(res *resource.Resource) {
|
||||
val := res.Attrs
|
||||
val.SafeDelete([]string{"timeouts"})
|
||||
|
|
|
@ -7,6 +7,13 @@ import (
|
|||
const AwsIamAccessKeyResourceType = "aws_iam_access_key"
|
||||
|
||||
func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"user": *res.Attributes().GetString("user"),
|
||||
}
|
||||
})
|
||||
|
||||
resourceSchemaRepository.SetNormalizeFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) {
|
||||
val := res.Attrs
|
||||
// As we can't read secrets from aws API once access_key created we need to set
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsIamRolePolicyAttachmentResourceType = "aws_iam_role_policy_attachment"
|
||||
|
||||
func initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsIamRolePolicyAttachmentResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"role": *res.Attributes().GetString("role"),
|
||||
"policy_arn": *res.Attributes().GetString("policy_arn"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsIamUserPolicyAttachmentResourceType = "aws_iam_user_policy_attachment"
|
||||
|
||||
func initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsIamUserPolicyAttachmentResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"user": *res.Attributes().GetString("user"),
|
||||
"policy_arn": *res.Attributes().GetString("policy_arn"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -7,6 +7,13 @@ import (
|
|||
const AwsLambdaFunctionResourceType = "aws_lambda_function"
|
||||
|
||||
func initAwsLambdaFunctionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsLambdaFunctionResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"function_name": res.TerraformId(),
|
||||
}
|
||||
})
|
||||
|
||||
resourceSchemaRepository.SetNormalizeFunc(AwsLambdaFunctionResourceType, func(res *resource.Resource) {
|
||||
val := res.Attrs
|
||||
val.SafeDelete([]string{"timeouts"})
|
||||
|
|
|
@ -10,6 +10,18 @@ import (
|
|||
const AwsRouteResourceType = "aws_route"
|
||||
|
||||
func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsRouteResourceType, func(res *resource.Resource) map[string]string {
|
||||
attributes := map[string]string{
|
||||
"route_table_id": *res.Attributes().GetString("route_table_id"),
|
||||
}
|
||||
if ipv4 := res.Attributes().GetString("destination_cidr_block"); ipv4 != nil && *ipv4 != "" {
|
||||
attributes["destination_cidr_block"] = *ipv4
|
||||
}
|
||||
if ipv6 := res.Attributes().GetString("destination_ipv6_cidr_block"); ipv6 != nil && *ipv6 != "" {
|
||||
attributes["destination_ipv6_cidr_block"] = *ipv6
|
||||
}
|
||||
return attributes
|
||||
})
|
||||
resourceSchemaRepository.SetNormalizeFunc(AwsRouteResourceType, func(res *resource.Resource) {
|
||||
val := res.Attrs
|
||||
val.SafeDelete([]string{"timeouts"})
|
||||
|
|
|
@ -5,6 +5,13 @@ import "github.com/cloudskiff/driftctl/pkg/resource"
|
|||
const AwsRouteTableAssociationResourceType = "aws_route_table_association"
|
||||
|
||||
func initAwsRouteTableAssociationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsRouteTableAssociationResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"route_table_id": *res.Attributes().GetString("route_table_id"),
|
||||
}
|
||||
})
|
||||
|
||||
resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteTableAssociationResourceType, func(res *resource.Resource) map[string]string {
|
||||
val := res.Attrs
|
||||
attrs := make(map[string]string)
|
||||
|
|
|
@ -7,6 +7,11 @@ import (
|
|||
const AwsS3BucketResourceType = "aws_s3_bucket"
|
||||
|
||||
func initAwsS3BucketMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.UpdateSchema(AwsS3BucketResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
|
||||
"policy": func(attributeSchema *resource.AttributeSchema) {
|
||||
attributeSchema.JsonString = true
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsS3BucketAnalyticsConfigurationResourceType = "aws_s3_bucket_analytics_configuration"
|
||||
|
||||
func initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketAnalyticsConfigurationResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsS3BucketInventoryResourceType = "aws_s3_bucket_inventory"
|
||||
|
||||
func initAwsS3BucketInventoryMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketInventoryResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsS3BucketMetricResourceType = "aws_s3_bucket_metric"
|
||||
|
||||
func initAwsS3BucketMetricMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketMetricResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsS3BucketNotificationResourceType = "aws_s3_bucket_notification"
|
||||
|
||||
func initAwsS3BucketNotificationMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketNotificationResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -8,6 +8,11 @@ import (
|
|||
const AwsS3BucketPolicyResourceType = "aws_s3_bucket_policy"
|
||||
|
||||
func initAwsS3BucketPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketPolicyResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"alias": *res.Attributes().GetString("region"),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.UpdateSchema(AwsS3BucketPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
|
||||
"policy": func(attributeSchema *resource.AttributeSchema) {
|
||||
attributeSchema.JsonString = true
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/cloudskiff/driftctl/pkg/helpers"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/hashicorp/terraform/flatmap"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
)
|
||||
|
||||
|
@ -55,6 +56,40 @@ func CreateSecurityGroupRuleIdHash(attrs *resource.Attributes) string {
|
|||
}
|
||||
|
||||
func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) map[string]string {
|
||||
attrs := make(map[string]interface{})
|
||||
if v, ok := res.Attributes().Get("type"); ok {
|
||||
attrs["type"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("protocol"); ok {
|
||||
attrs["protocol"] = v
|
||||
}
|
||||
if v := res.Attributes().GetInt("from_port"); v != nil {
|
||||
attrs["from_port"] = *v
|
||||
}
|
||||
if v := res.Attributes().GetInt("to_port"); v != nil {
|
||||
attrs["to_port"] = *v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("security_group_id"); ok {
|
||||
attrs["security_group_id"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("self"); ok {
|
||||
attrs["self"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("cidr_blocks"); ok {
|
||||
attrs["cidr_blocks"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("ipv6_cidr_blocks"); ok {
|
||||
attrs["ipv6_cidr_blocks"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("prefix_list_ids"); ok {
|
||||
attrs["prefix_list_ids"] = v
|
||||
}
|
||||
if v, ok := res.Attributes().Get("source_security_group_id"); ok {
|
||||
attrs["source_security_group_id"] = v
|
||||
}
|
||||
return flatmap.Flatten(attrs)
|
||||
})
|
||||
resourceSchemaRepository.SetNormalizeFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) {
|
||||
val := res.Attrs
|
||||
val.DeleteIfDefault("security_group_id")
|
||||
|
|
|
@ -5,6 +5,11 @@ import "github.com/cloudskiff/driftctl/pkg/resource"
|
|||
const AwsSnsTopicResourceType = "aws_sns_topic"
|
||||
|
||||
func initSnsTopicMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"topic_arn": res.TerraformId(),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.UpdateSchema(AwsSnsTopicResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
|
||||
"delivery_policy": func(attributeSchema *resource.AttributeSchema) {
|
||||
attributeSchema.JsonString = true
|
||||
|
|
|
@ -8,6 +8,12 @@ import (
|
|||
const AwsSnsTopicPolicyResourceType = "aws_sns_topic_policy"
|
||||
|
||||
func initSnsTopicPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicPolicyResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"topic_arn": res.TerraformId(),
|
||||
}
|
||||
})
|
||||
|
||||
resourceSchemaRepository.UpdateSchema(AwsSnsTopicPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
|
||||
"policy": func(attributeSchema *resource.AttributeSchema) {
|
||||
attributeSchema.JsonString = true
|
||||
|
|
|
@ -8,6 +8,12 @@ import (
|
|||
const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription"
|
||||
|
||||
func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"SubscriptionId": res.TerraformId(),
|
||||
}
|
||||
})
|
||||
|
||||
resourceSchemaRepository.UpdateSchema(AwsSnsTopicSubscriptionResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
|
||||
"delivery_policy": func(attributeSchema *resource.AttributeSchema) {
|
||||
attributeSchema.JsonString = true
|
||||
|
|
|
@ -9,6 +9,7 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt
|
|||
initAwsDbSubnetGroupMetaData(resourceSchemaRepository)
|
||||
initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository)
|
||||
initAwsDefaultSubnetMetaData(resourceSchemaRepository)
|
||||
initAwsDefaultRouteTableMetadata(resourceSchemaRepository)
|
||||
initAwsDynamodbTableMetaData(resourceSchemaRepository)
|
||||
initAwsEbsSnapshotMetaData(resourceSchemaRepository)
|
||||
initAwsInstanceMetaData(resourceSchemaRepository)
|
||||
|
@ -16,6 +17,10 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt
|
|||
initAwsEipMetaData(resourceSchemaRepository)
|
||||
initAwsS3BucketMetaData(resourceSchemaRepository)
|
||||
initAwsS3BucketPolicyMetaData(resourceSchemaRepository)
|
||||
initAwsS3BucketInventoryMetadata(resourceSchemaRepository)
|
||||
initAwsS3BucketMetricMetadata(resourceSchemaRepository)
|
||||
initAwsS3BucketNotificationMetadata(resourceSchemaRepository)
|
||||
initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository)
|
||||
initAwsEcrRepositoryMetaData(resourceSchemaRepository)
|
||||
initAwsRouteMetaData(resourceSchemaRepository)
|
||||
initAwsRouteTableAssociationMetaData(resourceSchemaRepository)
|
||||
|
@ -30,6 +35,8 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt
|
|||
initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository)
|
||||
initAwsIAMRoleMetaData(resourceSchemaRepository)
|
||||
initAwsIAMRolePolicyMetaData(resourceSchemaRepository)
|
||||
initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository)
|
||||
initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository)
|
||||
initAwsIAMUserMetaData(resourceSchemaRepository)
|
||||
initAwsIAMUserPolicyMetaData(resourceSchemaRepository)
|
||||
initAwsKeyPairMetaData(resourceSchemaRepository)
|
||||
|
|
Loading…
Reference in New Issue