fix(remote): aws s3 bucket analytic supplier
Add filter on resources based on regionmain
parent
038116e7bf
commit
1bebec138d
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
|
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
|
||||||
"github.com/cloudskiff/driftctl/pkg/remote/deserializer"
|
"github.com/cloudskiff/driftctl/pkg/remote/deserializer"
|
||||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||||
|
tf "github.com/cloudskiff/driftctl/pkg/remote/terraform"
|
||||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||||
awsdeserializer "github.com/cloudskiff/driftctl/pkg/resource/aws/deserializer"
|
awsdeserializer "github.com/cloudskiff/driftctl/pkg/resource/aws/deserializer"
|
||||||
|
@ -19,6 +20,7 @@ type S3BucketAnalyticSupplier struct {
|
||||||
deserializer deserializer.CTYDeserializer
|
deserializer deserializer.CTYDeserializer
|
||||||
repository repository.S3Repository
|
repository repository.S3Repository
|
||||||
runner *terraform.ParallelResourceReader
|
runner *terraform.ParallelResourceReader
|
||||||
|
providerConfig tf.TerraformProviderConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewS3BucketAnalyticSupplier(provider *AWSTerraformProvider, repository repository.S3Repository) *S3BucketAnalyticSupplier {
|
func NewS3BucketAnalyticSupplier(provider *AWSTerraformProvider, repository repository.S3Repository) *S3BucketAnalyticSupplier {
|
||||||
|
@ -27,6 +29,7 @@ func NewS3BucketAnalyticSupplier(provider *AWSTerraformProvider, repository repo
|
||||||
awsdeserializer.NewS3BucketAnalyticDeserializer(),
|
awsdeserializer.NewS3BucketAnalyticDeserializer(),
|
||||||
repository,
|
repository,
|
||||||
terraform.NewParallelResourceReader(provider.Runner().SubRunner()),
|
terraform.NewParallelResourceReader(provider.Runner().SubRunner()),
|
||||||
|
provider.Config,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +45,7 @@ func (s *S3BucketAnalyticSupplier) Resources() ([]resource.Resource, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if region == "" {
|
if region == "" || region != s.providerConfig.DefaultAlias {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := s.listBucketAnalyticConfiguration(&bucket, region); err != nil {
|
if err := s.listBucketAnalyticConfiguration(&bucket, region); err != nil {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/cloudskiff/driftctl/pkg/remote/aws/client"
|
"github.com/cloudskiff/driftctl/pkg/remote/aws/client"
|
||||||
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
|
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
|
||||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||||
|
tf "github.com/cloudskiff/driftctl/pkg/remote/terraform"
|
||||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||||
resourceaws "github.com/cloudskiff/driftctl/pkg/resource/aws"
|
resourceaws "github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||||
awsdeserializer "github.com/cloudskiff/driftctl/pkg/resource/aws/deserializer"
|
awsdeserializer "github.com/cloudskiff/driftctl/pkg/resource/aws/deserializer"
|
||||||
|
@ -124,14 +125,14 @@ func TestS3BucketAnalyticSupplier_Resources(t *testing.T) {
|
||||||
"GetBucketLocation",
|
"GetBucketLocation",
|
||||||
&s3.Bucket{Name: awssdk.String("bucket-martin-test-drift")},
|
&s3.Bucket{Name: awssdk.String("bucket-martin-test-drift")},
|
||||||
).Return(
|
).Return(
|
||||||
"eu-west-1",
|
"eu-west-3",
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
repository.On(
|
repository.On(
|
||||||
"ListBucketAnalyticsConfigurations",
|
"ListBucketAnalyticsConfigurations",
|
||||||
&s3.Bucket{Name: awssdk.String("bucket-martin-test-drift")},
|
&s3.Bucket{Name: awssdk.String("bucket-martin-test-drift")},
|
||||||
"eu-west-1",
|
"eu-west-3",
|
||||||
).Return(
|
).Return(
|
||||||
nil,
|
nil,
|
||||||
awserr.NewRequestFailure(nil, 403, ""),
|
awserr.NewRequestFailure(nil, 403, ""),
|
||||||
|
@ -169,6 +170,10 @@ func TestS3BucketAnalyticSupplier_Resources(t *testing.T) {
|
||||||
deserializer,
|
deserializer,
|
||||||
&mock,
|
&mock,
|
||||||
terraform.NewParallelResourceReader(parallel.NewParallelRunner(context.TODO(), 10)),
|
terraform.NewParallelResourceReader(parallel.NewParallelRunner(context.TODO(), 10)),
|
||||||
|
tf.TerraformProviderConfig{
|
||||||
|
Name: "test",
|
||||||
|
DefaultAlias: "eu-west-3",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
got, err := s.Resources()
|
got, err := s.Resources()
|
||||||
assert.Equal(t, err, tt.wantErr)
|
assert.Equal(t, err, tt.wantErr)
|
||||||
|
|
|
@ -52,113 +52,5 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"bucket": "bucket-martin-test-drift",
|
|
||||||
"filter": [],
|
|
||||||
"id": "bucket-martin-test-drift:Analytics_Bucket1",
|
|
||||||
"name": "Analytics_Bucket1",
|
|
||||||
"storage_class_analysis": [
|
|
||||||
{
|
|
||||||
"data_export": [
|
|
||||||
{
|
|
||||||
"destination": [
|
|
||||||
{
|
|
||||||
"s3_bucket_destination": [
|
|
||||||
{
|
|
||||||
"bucket_account_id": "",
|
|
||||||
"bucket_arn": "arn:aws:s3:::bucket-martin-test-drift",
|
|
||||||
"format": "CSV",
|
|
||||||
"prefix": ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"output_schema_version": "V_1"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bucket": "bucket-martin-test-drift",
|
|
||||||
"filter": [],
|
|
||||||
"id": "bucket-martin-test-drift:Analytics2_Bucket1",
|
|
||||||
"name": "Analytics2_Bucket1",
|
|
||||||
"storage_class_analysis": [
|
|
||||||
{
|
|
||||||
"data_export": [
|
|
||||||
{
|
|
||||||
"destination": [
|
|
||||||
{
|
|
||||||
"s3_bucket_destination": [
|
|
||||||
{
|
|
||||||
"bucket_account_id": "",
|
|
||||||
"bucket_arn": "arn:aws:s3:::bucket-martin-test-drift",
|
|
||||||
"format": "CSV",
|
|
||||||
"prefix": ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"output_schema_version": "V_1"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bucket": "bucket-martin-test-drift3",
|
|
||||||
"filter": [],
|
|
||||||
"id": "bucket-martin-test-drift3:Analytics2_Bucket3",
|
|
||||||
"name": "Analytics2_Bucket3",
|
|
||||||
"storage_class_analysis": [
|
|
||||||
{
|
|
||||||
"data_export": [
|
|
||||||
{
|
|
||||||
"destination": [
|
|
||||||
{
|
|
||||||
"s3_bucket_destination": [
|
|
||||||
{
|
|
||||||
"bucket_account_id": "",
|
|
||||||
"bucket_arn": "arn:aws:s3:::bucket-martin-test-drift3",
|
|
||||||
"format": "CSV",
|
|
||||||
"prefix": ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"output_schema_version": "V_1"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bucket": "bucket-martin-test-drift3",
|
|
||||||
"filter": [],
|
|
||||||
"id": "bucket-martin-test-drift3:Analytics_Bucket3",
|
|
||||||
"name": "Analytics_Bucket3",
|
|
||||||
"storage_class_analysis": [
|
|
||||||
{
|
|
||||||
"data_export": [
|
|
||||||
{
|
|
||||||
"destination": [
|
|
||||||
{
|
|
||||||
"s3_bucket_destination": [
|
|
||||||
{
|
|
||||||
"bucket_account_id": "",
|
|
||||||
"bucket_arn": "arn:aws:s3:::bucket-martin-test-drift3",
|
|
||||||
"format": "CSV",
|
|
||||||
"prefix": ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"output_schema_version": "V_1"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
Loading…
Reference in New Issue