2020-12-09 15:31:34 +00:00
|
|
|
package aws
|
|
|
|
|
|
|
|
import (
|
2020-12-16 12:02:02 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/alerter"
|
2021-03-15 17:30:18 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/output"
|
2021-02-16 17:42:46 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/remote/aws/client"
|
|
|
|
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
|
2021-05-25 14:45:59 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/remote/cache"
|
2020-12-09 15:31:34 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/resource"
|
2021-03-26 08:44:55 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
2020-12-09 15:31:34 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
const RemoteAWSTerraform = "aws+tf"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize remote (configure credentials, launch tf providers and start gRPC clients)
|
|
|
|
* Required to use Scanner
|
|
|
|
*/
|
2021-05-21 14:09:45 +00:00
|
|
|
|
2021-06-03 09:43:15 +00:00
|
|
|
func Init(version string, alerter *alerter.Alerter,
|
2021-05-21 14:09:45 +00:00
|
|
|
providerLibrary *terraform.ProviderLibrary,
|
|
|
|
supplierLibrary *resource.SupplierLibrary,
|
|
|
|
progress output.Progress,
|
|
|
|
resourceSchemaRepository *resource.SchemaRepository,
|
|
|
|
factory resource.ResourceFactory) error {
|
|
|
|
|
2021-06-03 09:43:15 +00:00
|
|
|
provider, err := NewAWSTerraformProvider(version, progress)
|
2021-02-09 13:56:11 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = provider.Init()
|
2020-12-09 15:31:34 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-05-25 15:08:36 +00:00
|
|
|
repositoryCache := cache.New(100)
|
2021-05-25 14:45:59 +00:00
|
|
|
|
2021-02-16 17:42:46 +00:00
|
|
|
s3Repository := repository.NewS3Repository(client.NewAWSClientFactory(provider.session))
|
2021-05-31 15:39:16 +00:00
|
|
|
ec2repository := repository.NewEC2Repository(provider.session, repositoryCache)
|
|
|
|
route53repository := repository.NewRoute53Repository(provider.session)
|
|
|
|
lambdaRepository := repository.NewLambdaRepository(provider.session)
|
|
|
|
rdsRepository := repository.NewRDSRepository(provider.session)
|
|
|
|
sqsRepository := repository.NewSQSClient(provider.session)
|
|
|
|
snsRepository := repository.NewSNSClient(provider.session)
|
|
|
|
dynamoDBRepository := repository.NewDynamoDBRepository(provider.session)
|
|
|
|
cloudfrontRepository := repository.NewCloudfrontClient(provider.session)
|
|
|
|
kmsRepository := repository.NewKMSRepository(provider.session)
|
|
|
|
ecrRepository := repository.NewECRRepository(provider.session)
|
|
|
|
|
2021-05-21 14:09:45 +00:00
|
|
|
deserializer := resource.NewDeserializer(factory)
|
2021-01-22 17:06:17 +00:00
|
|
|
providerLibrary.AddProvider(terraform.AWS, provider)
|
|
|
|
|
2021-06-03 10:39:33 +00:00
|
|
|
supplierLibrary.AddSupplier(NewS3BucketSupplier(provider, s3Repository, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewS3BucketAnalyticSupplier(provider, s3Repository, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewS3BucketInventorySupplier(provider, s3Repository, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewS3BucketMetricSupplier(provider, s3Repository, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewS3BucketNotificationSupplier(provider, s3Repository, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewS3BucketPolicySupplier(provider, s3Repository, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewEC2EipSupplier(provider, ec2repository, deserializer))
|
2021-05-31 15:39:16 +00:00
|
|
|
supplierLibrary.AddSupplier(NewEC2EipAssociationSupplier(provider, deserializer, ec2repository))
|
|
|
|
supplierLibrary.AddSupplier(NewEC2EbsVolumeSupplier(provider, deserializer, ec2repository))
|
|
|
|
supplierLibrary.AddSupplier(NewEC2EbsSnapshotSupplier(provider, deserializer, ec2repository))
|
|
|
|
supplierLibrary.AddSupplier(NewRoute53ZoneSupplier(provider, deserializer, route53repository))
|
|
|
|
supplierLibrary.AddSupplier(NewRoute53RecordSupplier(provider, deserializer, route53repository))
|
|
|
|
supplierLibrary.AddSupplier(NewEC2InstanceSupplier(provider, deserializer, ec2repository))
|
|
|
|
supplierLibrary.AddSupplier(NewEC2AmiSupplier(provider, deserializer, ec2repository))
|
|
|
|
supplierLibrary.AddSupplier(NewEC2KeyPairSupplier(provider, deserializer, ec2repository))
|
|
|
|
supplierLibrary.AddSupplier(NewLambdaFunctionSupplier(provider, deserializer, lambdaRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewDBSubnetGroupSupplier(provider, deserializer, rdsRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewDBInstanceSupplier(provider, deserializer, rdsRepository))
|
2021-05-21 14:09:45 +00:00
|
|
|
supplierLibrary.AddSupplier(NewVPCSecurityGroupSupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewIamUserSupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewIamUserPolicySupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewIamUserPolicyAttachmentSupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewIamAccessKeySupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewIamRoleSupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewIamPolicySupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewIamRolePolicySupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewIamRolePolicyAttachmentSupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewVPCSecurityGroupRuleSupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewVPCSupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewSubnetSupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewRouteTableSupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewRouteSupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewRouteTableAssociationSupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewNatGatewaySupplier(provider, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewInternetGatewaySupplier(provider, deserializer))
|
2021-05-31 15:39:16 +00:00
|
|
|
supplierLibrary.AddSupplier(NewSqsQueueSupplier(provider, deserializer, sqsRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewSqsQueuePolicySupplier(provider, deserializer, sqsRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewSNSTopicSupplier(provider, deserializer, snsRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewSNSTopicPolicySupplier(provider, deserializer, snsRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewSNSTopicSubscriptionSupplier(provider, alerter, deserializer, snsRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewDynamoDBTableSupplier(provider, deserializer, dynamoDBRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewRoute53HealthCheckSupplier(provider, deserializer, route53repository))
|
|
|
|
supplierLibrary.AddSupplier(NewCloudfrontDistributionSupplier(provider, deserializer, cloudfrontRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewECRRepositorySupplier(provider, deserializer, ecrRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewKMSKeySupplier(provider, deserializer, kmsRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewKMSAliasSupplier(provider, deserializer, kmsRepository))
|
|
|
|
supplierLibrary.AddSupplier(NewLambdaEventSourceMappingSupplier(provider, deserializer, lambdaRepository))
|
2020-12-09 15:31:34 +00:00
|
|
|
|
2021-03-26 08:44:55 +00:00
|
|
|
resourceSchemaRepository.Init(provider.Schema())
|
|
|
|
aws.InitResourcesMetadata(resourceSchemaRepository)
|
|
|
|
|
2020-12-09 15:31:34 +00:00
|
|
|
return nil
|
|
|
|
}
|