8000 Handle access denied exceptions on resource details fetching by sundowndev Β· Pull Request #882 Β· snyk/driftctl Β· GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Handle access denied exceptions on resource details fetching #882

New issue

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

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

Already on GitHub? Sign in to your account

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cmd/scan/output/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (c *Console) Write(analysis *analyser.Analysis) error {
for _, alerts := range analysis.Alerts() {
for _, alert := range alerts {
fmt.Println(color.YellowString(alert.Message()))
if alert, ok := alert.(*remote.EnumerationAccessDeniedAlert); ok && enumerationErrorMessage == "" {
if alert, ok := alert.(*remote.RemoteAccessDeniedAlert); ok && enumerationErrorMessage == "" {
enumerationErrorMessage = alert.GetProviderMessage()
}
}
Expand Down
9E7A
16 changes: 8 additions & 8 deletions pkg/cmd/scan/output/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ func fakeAnalysisWithAlerts() *analyser.Analysis {
a := fakeAnalysis()
a.SetAlerts(alerter.Alerts{
"": []alerter.Alert{
remote.NewEnumerationAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_vpc", "aws_vpc"),
remote.NewEnumerationAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_sqs", "aws_sqs"),
remote.NewEnumerationAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_sns", "aws_sns"),
remote.NewRemoteAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_vpc", "aws_vpc", remote.EnumerationPhase),
remote.NewRemoteAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_sqs", "aws_sqs", remote.EnumerationPhase),
remote.NewRemoteAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_sns", "aws_sns", remote.EnumerationPhase),
},
})
a.ProviderVersion = "3.19.0"
Expand Down Expand Up @@ -318,9 +318,9 @@ func fakeAnalysisWithAWSEnumerationError() *analyser.Analysis {
a := analyser.Analysis{}
a.SetAlerts(alerter.Alerts{
"": []alerter.Alert{
remote.NewEnumerationAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_vpc", "aws_vpc"),
remote.NewEnumerationAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_sqs", "aws_sqs"),
remote.NewEnumerationAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_sns", "aws_sns"),
remote.NewRemoteAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_vpc", "aws_vpc", remote.EnumerationPhase),
remote.NewRemoteAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_sqs", "aws_sqs", remote.EnumerationPhase),
remote.NewRemoteAccessDeniedAlert(aws.RemoteAWSTerraform, "aws_sns", "aws_sns", remote.EnumerationPhase),
},
})
a.ProviderName = "AWS"
Expand All @@ -332,8 +332,8 @@ func fakeAnalysisWithGithubEnumerationError() *analyser.Analysis {
a := analyser.Analysis{}
a.SetAlerts(alerter.Alerts{
"": []alerter.Alert{
remote.NewEnumerationAccessDeniedAlert(github.RemoteGithubTerraform, "github_team", "github_team"),
remote.NewEnumerationAccessDeniedAlert(github.RemoteGithubTerraform, "github_team_membership", "github_team"),
remote.NewRemoteAccessDeniedAlert(github.RemoteGithubTerraform, "github_team", "github_team", remote.EnumerationPhase),
remote.NewRemoteAccessDeniedAlert(github.RemoteGithubTerraform, "github_team_membership", "github_team", remote.EnumerationPhase),
},
})
a.ProviderName = "AWS"
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/cloudfront_distribution_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *CloudfrontDistributionEnumerator) SupportedType() resource.ResourceType
func (e *CloudfrontDistributionEnumerator) Enumerate() ([]resource.Resource, error) {
distributions, err := e.repository.ListAllDistributions()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(distributions))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/default_vpc_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (e *DefaultVPCEnumerator) SupportedType() resource.ResourceType {
func (e *DefaultVPCEnumerator) Enumerate() ([]resource.Resource, error) {
_, defaultVPCs, err := e.repo.ListAllVPCs()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsDefaultVpcResourceType)
return nil, remoteerror.NewResourceScanningError(err, aws.AwsDefaultVpcResourceType)
}

results := make([]resource.Resource, 0, len(defaultVPCs))
Expand Down
3 changes: 2 additions & 1 deletion pkg/remote/aws/dynamodb_table_details_fetcher.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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"
Expand All @@ -27,7 +28,7 @@ func (r *DynamoDBTableDetailsFetcher) ReadDetails(res resource.Resource) (resour
},
})
if err != nil {
return nil, err
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType())
}
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsDynamodbTableResourceType, *ctyVal)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/dynamodb_table_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *DynamoDBTableEnumerator) SupportedType() resource.ResourceType {
func (e *DynamoDBTableEnumerator) Enumerate() ([]resource.Resource, error) {
tables, err := e.repository.ListAllTables()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(tables))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_ami_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2AmiEnumerator) SupportedType() resource.ResourceType {
func (e *EC2AmiEnumerator) Enumerate() ([]resource.Resource, error) {
images, err := e.repository.ListAllImages()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(images))
Expand Down
3 changes: 2 additions & 1 deletion pkg/remote/aws/ec2_default_route_table_details_fetcher.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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"
Expand All @@ -27,7 +28,7 @@ func (r *EC2DefaultRouteTableDetailsFetcher) ReadDetails(res resource.Resource)
},
})
if err != nil {
return nil, err
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType())
}
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsDefaultRouteTableResourceType, *ctyVal)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_default_route_table_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2DefaultRouteTableEnumerator) SupportedType() resource.ResourceType {
func (e *EC2DefaultRouteTableEnumerator) Enumerate() ([]resource.Resource, error) {
routeTables, err := e.repository.ListAllRouteTables()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

var results []resource.Resource
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_default_subnet_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2DefaultSubnetEnumerator) SupportedType() resource.ResourceType {
func (e *EC2DefaultSubnetEnumerator) Enumerate() ([]resource.Resource, error) {
_, defaultSubnets, err := e.repository.ListAllSubnets()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(defaultSubnets))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_ebs_snapshot_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2EbsSnapshotEnumerator) SupportedType() resource.ResourceType {
func (e *EC2EbsSnapshotEnumerator) Enumerate() ([]resource.Resource, error) {
snapshots, err := e.repository.ListAllSnapshots()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(snapshots))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_ebs_volume_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2EbsVolumeEnumerator) SupportedType() resource.ResourceType {
func (e *EC2EbsVolumeEnumerator) Enumerate() ([]resource.Resource, error) {
volumes, err := e.repository.ListAllVolumes()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(volumes))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_eip_association_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2EipAssociationEnumerator) SupportedType() resource.ResourceType {
func (e *EC2EipAssociationEnumerator) Enumerate() ([]resource.Resource, error) {
addresses, err := e.repository.ListAllAddressesAssociation()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, 0, len(addresses))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_eip_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2EipEnumerator) SupportedType() resource.ResourceType {
func (e *EC2EipEnumerator) Enumerate() ([]resource.Resource, error) {
addresses, err := e.repository.ListAllAddresses()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(addresses))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_instance_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2InstanceEnumerator) SupportedType() resource.ResourceType {
func (e *EC2InstanceEnumerator) Enumerate() ([]resource.Resource, error) {
instances, err := e.repository.ListAllInstances()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(instances))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_internet_gateway_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2InternetGatewayEnumerator) SupportedType() resource.ResourceType {
func (e *EC2InternetGatewayEnumerator) Enumerate() ([]resource.Resource, error) {
internetGateways, err := e.repository.ListAllInternetGateways()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(internetGateways))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_key_pair_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2KeyPairEnumerator) SupportedType() resource.ResourceType {
func (e *EC2KeyPairEnumerator) Enumerate() ([]resource.Resource, error) {
keyPairs, err := e.repository.ListAllKeyPairs()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(keyPairs))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_nat_gateway_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2NatGatewayEnumerator) SupportedType() resource.ResourceType {
func (e *EC2NatGatewayEnumerator) Enumerate() ([]resource.Resource, error) {
natGateways, err := e.repository.ListAllNatGateways()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(natGateways))
10000 Expand Down
3 changes: 2 additions & 1 deletion pkg/remote/aws/ec2_route_details_fetcher.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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"
Expand Down Expand Up @@ -34,7 +35,7 @@ func (r *EC2RouteDetailsFetcher) ReadDetails(res resource.Resource) (resource.Re
Attributes: attributes,
})
if err != nil {
return nil, err
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType())
}
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsRouteResourceType, *ctyVal)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_route_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2RouteEnumerator) SupportedType() resource.ResourceType {
func (e *EC2RouteEnumerator) Enumerate() ([]resource.Resource, error) {
routeTables, err := e.repository.ListAllRouteTables()
if err != nil {
return nil, remoteerror.NewResourceEnumerationErrorWithType(err, string(e.SupportedType()), aws.AwsRouteTableResourceType)
return nil, remoteerror.NewResourceScanningErrorWithType(err, string(e.SupportedType()), aws.AwsRouteTableResourceType)
}

var results []resource.Resource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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"
Expand All @@ -27,7 +28,7 @@ func (r *EC2RouteTableAssociationDetailsFetcher) ReadDetails(res resource.Resour
},
})
if err != nil {
return nil, err
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType())
}
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsRouteTableAssociationResourceType, *ctyVal)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_route_table_association_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (e *EC2RouteTableAssociationEnumerator) SupportedType() resource.ResourceTy
func (e *EC2RouteTableAssociationEnumerator) Enumerate() ([]resource.Resource, error) {
routeTables, err := e.repository.ListAllRouteTables()
if err != nil {
return nil, remoteerror.NewResourceEnumerationErrorWithType(err, string(e.SupportedType()), aws.AwsRouteTableResourceType)
return nil, remoteerror.NewResourceScanningErrorWithType(err, string(e.SupportedType()), aws.AwsRouteTableResourceType)
}

var results []resource.Resource
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_route_table_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (e *EC2RouteTableEnumerator) SupportedType() resource.ResourceType {
func (e *EC2RouteTableEnumerator) Enumerate() ([]resource.Resource, error) {
routeTables, err := e.repository.ListAllRouteTables()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

var results []resource.Resource
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ec2_subnet_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *EC2SubnetEnumerator) SupportedType() resource.ResourceType {
func (e *EC2SubnetEnumerator) Enumerate() ([]resource.Resource, error) {
subnets, _, err := e.repository.ListAllSubnets()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(subnets))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/ecr_repository_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (e *ECRRepositoryEnumerator) SupportedType() resource.ResourceType {
func (e *ECRRepositoryEnumerator) Enumerate() ([]resource.Resource, error) {
repos, err := e.repository.ListAllRepositories()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(repos))
Expand Down
3 changes: 2 additions & 1 deletion pkg/remote/aws/iam_access_key_details_fetcher.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aws

import (
< 10000 span class='blob-code-inner blob-code-marker ' data-code-marker="+"> 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"
Expand All @@ -27,7 +28,7 @@ func (r *IamAccessKeyDetailsFetcher) ReadDetails(res resource.Resource) (resourc
},
})
if err != nil {
return nil, err
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType())
}
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsIamAccessKeyResourceType, *ctyVal)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/remote/aws/iam_access_key_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ func (e *IamAccessKeyEnumerator) SupportedType() resource.ResourceType {
func (e *IamAccessKeyEnumerator) Enumerate() ([]resource.Resource, error) {
users, err := e.repository.ListAllUsers()
if err != nil {
return nil, remoteerror.NewResourceEnumerationErrorWithType(err, string(e.SupportedType()), resourceaws.AwsIamUserResourceType)
return nil, remoteerror.NewResourceScanningErrorWithType(err, string(e.SupportedType()), resourceaws.AwsIamUserResourceType)
}

keys, err := e.repository.ListAllAccessKeys(users)
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsIamAccessKeyResourceType)
return nil, remoteerror.NewResourceScanningError(err, resourceaws.AwsIamAccessKeyResourceType)
}

results := make([]resource.Resource, 0)
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/iam_policy_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (e *IamPolicyEnumerator) SupportedType() resource.ResourceType {
func (e *IamPolicyEnumerator) Enumerate() ([]resource.Resource, error) {
policies, err := e.repository.ListAllPolicies()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, len(policies))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/iam_role_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func awsIamRoleShouldBeIgnored(roleName string) bool {
func (e *IamRoleEnumerator) Enumerate() ([]resource.Resource, error) {
roles, err := e.repository.ListAllRoles()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

results := make([]resource.Resource, 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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"
Expand Down Expand Up @@ -28,7 +29,7 @@ func (r *IamRolePolicyAttachmentDetailsFetcher) ReadDetails(res resource.Resourc
},
})
if err != nil {
return nil, err
return nil, remoteerror.NewResourceScanningError(err, res.TerraformType())
}
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsIamRolePolicyAttachmentResourceType, *ctyVal)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/remote/aws/iam_role_policy_attachment_enumerator.go
Original file line number Diff line num 10000 ber Diff line change
Expand Up @@ -29,7 +29,7 @@ func (e *IamRolePolicyAttachmentEnumerator) SupportedType() resource.ResourceTyp
func (e *IamRolePolicyAttachmentEnumerator) Enumerate() ([]resource.Resource, error) {
roles, err := e.repository.ListAllRoles()
if err != nil {
return nil, remoteerror.NewResourceEnumerationErrorWithType(err, string(e.SupportedType()), resourceaws.AwsIamRoleResourceType)
return nil, remoteerror.NewResourceScanningErrorWithType(err, string(e.SupportedType()), resourceaws.AwsIamRoleResourceType)
}

results := make([]resource.Resource, 0)
Expand All @@ -48,7 +48,7 @@ func (e *IamRolePolicyAttachmentEnumerator) Enumerate() ([]resource.Resource, er

policyAttachments, err := e.repository.ListAllRolePolicyAttachments(rolesNotIgnored)
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}

for _, attachedPol := range policyAttachments {
Expand Down
4 changes: 2 additions & 2 deletions pkg/remote/aws/iam_role_policy_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func (e *IamRolePolicyEnumerator) SupportedType() resource.ResourceType {
func (e *IamRolePolicyEnumerator) Enumerate() ([]resource.Resource, error) {
roles, err := e.repository.ListAllRoles()
if err != nil {
return nil, remoteerror.NewResourceEnumerationErrorWithType(err, resourceaws.AwsIamRolePolicyResourceType, resourceaws.AwsIamRoleResourceType)
return nil, remoteerror.NewResourceScanningErrorWithType(err, resourceaws.AwsIamRolePolicyResourceType, resourceaws.AwsIamRoleResourceType)
}

policies, err := e.repository.ListAllRolePolicies(roles)
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsIamRolePolicyResourceType)
return nil, remoteerror.NewResourceScanningError(err, resourceaws.AwsIamRolePolicyResourceType)
}

results := make([]resource.Resource, len(policies))
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/iam_user_enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (e *IamUserEnumerator) SupportedType() resource.ResourceType {
func (e *IamUserEnumerator) Enumerate() ([]resource.Resource, error) {
users, err := e.repository.ListAllUsers()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))
return nil, remoteerror.NewResourceScanningError(err, string(e.SupportedType()))
}
results := make([]resource.Resource, len(users))
Expand Down
Loading
0