Merge branch 'fix/filterS3' of github.com:cloudskiff/driftctl into fix/filterS3

main
sundowndev 2021-03-18 11:09:51 +01:00
commit a113ab5032
47 changed files with 191 additions and 109 deletions

View File

@ -146,6 +146,15 @@
"contributions": [
"doc"
]
},
{
"login": "sundowndev",
"name": "Raphaël",
"avatar_url": "https://avatars.githubusercontent.com/u/16480203?v=4",
"profile": "https://crvx.fr/",
"contributions": [
"code"
]
}
]
}

View File

@ -21,6 +21,7 @@ Thank you to all the people who have already contributed to driftctl.
<td align="center"><a href="https://github.com/herbygillot"><img src="https://avatars.githubusercontent.com/u/618376?v=4?s=80" width="80px;" alt=""/><br /><sub><b>Herby Gillot</b></sub></a><br /><a href="#tool-herbygillot" title="Tools">🔧</a></td>
<td align="center"><a href="http://louistoussaint.fr"><img src="https://avatars.githubusercontent.com/u/66522867?v=4?s=80" width="80px;" alt=""/><br /><sub><b>Toussaint Louis</b></sub></a><br /><a href="https://github.com/cloudskiff/driftctl/commits?author=lotoussa" title="Code">💻</a> <a href="https://github.com/cloudskiff/driftctl/commits?author=lotoussa" title="Documentation">📖</a></td>
<td align="center"><a href="https://dev.to/psedge"><img src="https://avatars.githubusercontent.com/u/5781397?v=4?s=80" width="80px;" alt=""/><br /><sub><b>Peter Sedgewick</b></sub></a><br /><a href="https://github.com/cloudskiff/driftctl/commits?author=psedge" title="Documentation">📖</a></td>
<td align="center"><a href="https://crvx.fr/"><img src="https://avatars.githubusercontent.com/u/16480203?v=4?s=80" width="80px;" alt=""/><br /><sub><b>Raphaël</b></sub></a><br /><a href="https://github.com/cloudskiff/driftctl/commits?author=sundowndev" title="Code">💻</a></td>
</tr>
</table>

View File

@ -29,7 +29,7 @@ func NewCloudfrontDistributionSupplier(provider *AWSTerraformProvider) *Cloudfro
}
}
func (s CloudfrontDistributionSupplier) Resources() ([]resource.Resource, error) {
func (s *CloudfrontDistributionSupplier) Resources() ([]resource.Resource, error) {
distributions, err := s.client.ListAllDistributions()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsCloudfrontDistributionResourceType)
@ -50,7 +50,7 @@ func (s CloudfrontDistributionSupplier) Resources() ([]resource.Resource, error)
return s.deserializer.Deserialize(resources)
}
func (s CloudfrontDistributionSupplier) readCloudfrontDistribution(distribution cloudfront.DistributionSummary) (cty.Value, error) {
func (s *CloudfrontDistributionSupplier) readCloudfrontDistribution(distribution cloudfront.DistributionSummary) (cty.Value, error) {
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
ID: *distribution.Id,
Ty: aws.AwsCloudfrontDistributionResourceType,

View File

@ -29,7 +29,7 @@ func NewDBInstanceSupplier(provider *AWSTerraformProvider) *DBInstanceSupplier {
}
}
func (s DBInstanceSupplier) Resources() ([]resource.Resource, error) {
func (s *DBInstanceSupplier) Resources() ([]resource.Resource, error) {
resourceList, err := s.client.ListAllDBInstances()

View File

@ -32,7 +32,7 @@ func NewDBSubnetGroupSupplier(provider *AWSTerraformProvider) *DBSubnetGroupSupp
}
}
func (s DBSubnetGroupSupplier) Resources() ([]resource.Resource, error) {
func (s *DBSubnetGroupSupplier) Resources() ([]resource.Resource, error) {
subnetGroups, err := s.client.ListAllDbSubnetGroups()
@ -53,7 +53,7 @@ func (s DBSubnetGroupSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(ctyValues)
}
func (s DBSubnetGroupSupplier) readSubnetGroup(subnetGroup rds.DBSubnetGroup) (cty.Value, error) {
func (s *DBSubnetGroupSupplier) readSubnetGroup(subnetGroup rds.DBSubnetGroup) (cty.Value, error) {
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
ID: *subnetGroup.DBSubnetGroupName,
Ty: aws.AwsDbSubnetGroupResourceType,

View File

@ -29,7 +29,7 @@ func NewDynamoDBTableSupplier(provider *AWSTerraformProvider) *DynamoDBTableSupp
}
}
func (s DynamoDBTableSupplier) Resources() ([]resource.Resource, error) {
func (s *DynamoDBTableSupplier) Resources() ([]resource.Resource, error) {
tables, err := s.repository.ListAllTables()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsDynamodbTableResourceType)
@ -50,7 +50,7 @@ func (s DynamoDBTableSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(retrieve)
}
func (s DynamoDBTableSupplier) readTable(tableName *string) (cty.Value, error) {
func (s *DynamoDBTableSupplier) readTable(tableName *string) (cty.Value, error) {
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
ID: *tableName,
Ty: aws.AwsDynamodbTableResourceType,

View File

@ -31,7 +31,7 @@ func NewEC2AmiSupplier(provider *AWSTerraformProvider) *EC2AmiSupplier {
}
}
func (s EC2AmiSupplier) Resources() ([]resource.Resource, error) {
func (s *EC2AmiSupplier) Resources() ([]resource.Resource, error) {
images, err := s.client.ListAllImages()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsAmiResourceType)
@ -52,7 +52,7 @@ func (s EC2AmiSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s EC2AmiSupplier) readAMI(id string) (cty.Value, error) {
func (s *EC2AmiSupplier) readAMI(id string) (cty.Value, error) {
resImage, err := s.reader.ReadResource(terraform.ReadResourceArgs{
Ty: resourceaws.AwsAmiResourceType,
ID: id,

View File

@ -32,7 +32,7 @@ func NewEC2EbsSnapshotSupplier(provider *AWSTerraformProvider) *EC2EbsSnapshotSu
}
}
func (s EC2EbsSnapshotSupplier) Resources() ([]resource.Resource, error) {
func (s *EC2EbsSnapshotSupplier) Resources() ([]resource.Resource, error) {
snapshots, err := s.client.ListAllSnapshots()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsEbsSnapshotResourceType)
@ -53,7 +53,7 @@ func (s EC2EbsSnapshotSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s EC2EbsSnapshotSupplier) readEbsSnapshot(snapshot ec2.Snapshot) (cty.Value, error) {
func (s *EC2EbsSnapshotSupplier) readEbsSnapshot(snapshot ec2.Snapshot) (cty.Value, error) {
id := aws.StringValue(snapshot.SnapshotId)
resSnapshot, err := s.reader.ReadResource(terraform.ReadResourceArgs{
Ty: resourceaws.AwsEbsSnapshotResourceType,

View File

@ -32,7 +32,7 @@ func NewEC2EbsVolumeSupplier(provider *AWSTerraformProvider) *EC2EbsVolumeSuppli
}
}
func (s EC2EbsVolumeSupplier) Resources() ([]resource.Resource, error) {
func (s *EC2EbsVolumeSupplier) Resources() ([]resource.Resource, error) {
volumes, err := s.client.ListAllVolumes()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsEbsVolumeResourceType)
@ -53,7 +53,7 @@ func (s EC2EbsVolumeSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s EC2EbsVolumeSupplier) readEbsVolume(volume ec2.Volume) (cty.Value, error) {
func (s *EC2EbsVolumeSupplier) readEbsVolume(volume ec2.Volume) (cty.Value, error) {
id := aws.StringValue(volume.VolumeId)
resVolume, err := s.reader.ReadResource(terraform.ReadResourceArgs{
Ty: resourceaws.AwsEbsVolumeResourceType,

View File

@ -29,7 +29,7 @@ func NewEC2EipAssociationSupplier(provider *AWSTerraformProvider) *EC2EipAssocia
terraform.NewParallelResourceReader(provider.Runner().SubRunner())}
}
func (s EC2EipAssociationSupplier) Resources() ([]resource.Resource, error) {
func (s *EC2EipAssociationSupplier) Resources() ([]resource.Resource, error) {
associationIds, err := s.client.ListAllAddressesAssociation()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsEipAssociationResourceType)
@ -50,7 +50,7 @@ func (s EC2EipAssociationSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s EC2EipAssociationSupplier) readEIPAssociation(assocId string) (cty.Value, error) {
func (s *EC2EipAssociationSupplier) readEIPAssociation(assocId string) (cty.Value, error) {
resAssoc, err := s.reader.ReadResource(terraform.ReadResourceArgs{
Ty: resourceaws.AwsEipAssociationResourceType,
ID: assocId,

View File

@ -32,7 +32,7 @@ func NewEC2EipSupplier(provider *AWSTerraformProvider) *EC2EipSupplier {
}
}
func (s EC2EipSupplier) Resources() ([]resource.Resource, error) {
func (s *EC2EipSupplier) Resources() ([]resource.Resource, error) {
addresses, err := s.client.ListAllAddresses()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsEipResourceType)
@ -53,7 +53,7 @@ func (s EC2EipSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s EC2EipSupplier) readEIP(address ec2.Address) (cty.Value, error) {
func (s *EC2EipSupplier) readEIP(address ec2.Address) (cty.Value, error) {
id := aws.StringValue(address.AllocationId)
resAddress, err := s.reader.ReadResource(terraform.ReadResourceArgs{
Ty: resourceaws.AwsEipResourceType,

View File

@ -31,7 +31,7 @@ func NewEC2InstanceSupplier(provider *AWSTerraformProvider) *EC2InstanceSupplier
}
}
func (s EC2InstanceSupplier) Resources() ([]resource.Resource, error) {
func (s *EC2InstanceSupplier) Resources() ([]resource.Resource, error) {
instances, err := s.client.ListAllInstances()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsInstanceResourceType)
@ -53,7 +53,7 @@ func (s EC2InstanceSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s EC2InstanceSupplier) readInstance(id string) (cty.Value, error) {
func (s *EC2InstanceSupplier) readInstance(id string) (cty.Value, error) {
resInstance, err := s.reader.ReadResource(terraform.ReadResourceArgs{
Ty: resourceaws.AwsInstanceResourceType,
ID: id,

View File

@ -31,7 +31,7 @@ func NewEC2KeyPairSupplier(provider *AWSTerraformProvider) *EC2KeyPairSupplier {
}
}
func (s EC2KeyPairSupplier) Resources() ([]resource.Resource, error) {
func (s *EC2KeyPairSupplier) Resources() ([]resource.Resource, error) {
keyPairs, err := s.client.ListAllKeyPairs()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsKeyPairResourceType)
@ -52,7 +52,7 @@ func (s EC2KeyPairSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s EC2KeyPairSupplier) readKeyPair(name string) (cty.Value, error) {
func (s *EC2KeyPairSupplier) readKeyPair(name string) (cty.Value, error) {
resKp, err := s.reader.ReadResource(terraform.ReadResourceArgs{
Ty: resourceaws.AwsKeyPairResourceType,
ID: name,

View File

@ -30,7 +30,7 @@ func NewECRRepositorySupplier(provider *AWSTerraformProvider) *ECRRepositorySupp
}
}
func (r ECRRepositorySupplier) Resources() ([]resource.Resource, error) {
func (r *ECRRepositorySupplier) Resources() ([]resource.Resource, error) {
repositories, err := r.client.ListAllRepositories()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsEcrRepositoryResourceType)
@ -51,7 +51,7 @@ func (r ECRRepositorySupplier) Resources() ([]resource.Resource, error) {
return r.deserializer.Deserialize(retrieve)
}
func (r ECRRepositorySupplier) readRepository(repository *ecr.Repository) (cty.Value, error) {
func (r *ECRRepositorySupplier) readRepository(repository *ecr.Repository) (cty.Value, error) {
val, err := r.reader.ReadResource(terraform.ReadResourceArgs{
ID: *repository.RepositoryName,
Ty: aws.AwsEcrRepositoryResourceType,

View File

@ -31,7 +31,7 @@ func NewIamAccessKeySupplier(provider *AWSTerraformProvider) *IamAccessKeySuppli
}
}
func (s IamAccessKeySupplier) Resources() ([]resource.Resource, error) {
func (s *IamAccessKeySupplier) Resources() ([]resource.Resource, error) {
keys, err := listIamAccessKeys(s.client)
if err != nil {
return nil, err
@ -52,7 +52,7 @@ func (s IamAccessKeySupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s IamAccessKeySupplier) readRes(key *iam.AccessKeyMetadata) (cty.Value, error) {
func (s *IamAccessKeySupplier) readRes(key *iam.AccessKeyMetadata) (cty.Value, error) {
res, err := s.reader.ReadResource(
terraform.ReadResourceArgs{
Ty: resourceaws.AwsIamAccessKeyResourceType,

View File

@ -32,7 +32,7 @@ func NewIamPolicySupplier(provider *AWSTerraformProvider) *IamPolicySupplier {
}
}
func (s IamPolicySupplier) Resources() ([]resource.Resource, error) {
func (s *IamPolicySupplier) Resources() ([]resource.Resource, error) {
policies, err := listIamPolicies(s.client)
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsIamPolicyResourceType)
@ -53,7 +53,7 @@ func (s IamPolicySupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s IamPolicySupplier) readRes(resource *iam.Policy) (cty.Value, error) {
func (s *IamPolicySupplier) readRes(resource *iam.Policy) (cty.Value, error) {
res, err := s.reader.ReadResource(
terraform.ReadResourceArgs{
Ty: resourceaws.AwsIamPolicyResourceType,

View File

@ -31,7 +31,7 @@ func NewIamRolePolicyAttachmentSupplier(provider *AWSTerraformProvider) *IamRole
}
}
func (s IamRolePolicyAttachmentSupplier) Resources() ([]resource.Resource, error) {
func (s *IamRolePolicyAttachmentSupplier) Resources() ([]resource.Resource, error) {
roles, err := listIamRoles(s.client, resourceaws.AwsIamRolePolicyAttachmentResourceType)
if err != nil {
return nil, err
@ -66,7 +66,7 @@ func (s IamRolePolicyAttachmentSupplier) Resources() ([]resource.Resource, error
return s.deserializer.Deserialize(results)
}
func (s IamRolePolicyAttachmentSupplier) readRes(attachedPol attachedRolePolicy) (cty.Value, error) {
func (s *IamRolePolicyAttachmentSupplier) readRes(attachedPol attachedRolePolicy) (cty.Value, error) {
res, err := s.reader.ReadResource(
terraform.ReadResourceArgs{
Ty: resourceaws.AwsIamRolePolicyAttachmentResourceType,

View File

@ -33,7 +33,7 @@ func NewIamRolePolicySupplier(provider *AWSTerraformProvider) *IamRolePolicySupp
}
}
func (s IamRolePolicySupplier) Resources() ([]resource.Resource, error) {
func (s *IamRolePolicySupplier) Resources() ([]resource.Resource, error) {
policies, err := listIamRolePolicies(s.client, resourceaws.AwsIamRolePolicyResourceType)
if err != nil {
return nil, err
@ -52,7 +52,7 @@ func (s IamRolePolicySupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s IamRolePolicySupplier) readRes(name string) (cty.Value, error) {
func (s *IamRolePolicySupplier) readRes(name string) (cty.Value, error) {
res, err := s.reader.ReadResource(
terraform.ReadResourceArgs{
Ty: resourceaws.AwsIamRolePolicyResourceType,

View File

@ -45,7 +45,7 @@ func awsIamRoleShouldBeIgnored(roleName string) bool {
return ok
}
func (s IamRoleSupplier) Resources() ([]resource.Resource, error) {
func (s *IamRoleSupplier) Resources() ([]resource.Resource, error) {
roles, err := listIamRoles(s.client, resourceaws.AwsIamRoleResourceType)
if err != nil {
return nil, err
@ -69,7 +69,7 @@ func (s IamRoleSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s IamRoleSupplier) readRes(resource *iam.Role) (cty.Value, error) {
func (s *IamRoleSupplier) readRes(resource *iam.Role) (cty.Value, error) {
res, err := s.reader.ReadResource(
terraform.ReadResourceArgs{
Ty: resourceaws.AwsIamRoleResourceType,

View File

@ -31,7 +31,7 @@ func NewIamUserPolicyAttachmentSupplier(provider *AWSTerraformProvider) *IamUser
}
}
func (s IamUserPolicyAttachmentSupplier) Resources() ([]resource.Resource, error) {
func (s *IamUserPolicyAttachmentSupplier) Resources() ([]resource.Resource, error) {
users, err := listIamUsers(s.client, resourceaws.AwsIamUserPolicyAttachmentResourceType)
if err != nil {
return nil, err
@ -63,7 +63,7 @@ func (s IamUserPolicyAttachmentSupplier) Resources() ([]resource.Resource, error
return s.deserializer.Deserialize(results)
}
func (s IamUserPolicyAttachmentSupplier) readRes(attachedPol attachedUserPolicy) (cty.Value, error) {
func (s *IamUserPolicyAttachmentSupplier) readRes(attachedPol attachedUserPolicy) (cty.Value, error) {
res, err := s.reader.ReadResource(
terraform.ReadResourceArgs{
Ty: resourceaws.AwsIamUserPolicyAttachmentResourceType,

View File

@ -33,7 +33,7 @@ func NewIamUserPolicySupplier(provider *AWSTerraformProvider) *IamUserPolicySupp
}
}
func (s IamUserPolicySupplier) Resources() ([]resource.Resource, error) {
func (s *IamUserPolicySupplier) Resources() ([]resource.Resource, error) {
users, err := listIamUsers(s.client, resourceaws.AwsIamUserPolicyResourceType)
if err != nil {
return nil, err
@ -66,7 +66,7 @@ func (s IamUserPolicySupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s IamUserPolicySupplier) readRes(policyName string) (cty.Value, error) {
func (s *IamUserPolicySupplier) readRes(policyName string) (cty.Value, error) {
res, err := s.reader.ReadResource(
terraform.ReadResourceArgs{
Ty: resourceaws.AwsIamUserPolicyResourceType,

View File

@ -31,7 +31,7 @@ func NewIamUserSupplier(provider *AWSTerraformProvider) *IamUserSupplier {
}
}
func (s IamUserSupplier) Resources() ([]resource.Resource, error) {
func (s *IamUserSupplier) Resources() ([]resource.Resource, error) {
users, err := listIamUsers(s.client, resourceaws.AwsIamUserResourceType)
if err != nil {
return nil, err
@ -52,7 +52,7 @@ func (s IamUserSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s IamUserSupplier) readRes(user *iam.User) (cty.Value, error) {
func (s *IamUserSupplier) readRes(user *iam.User) (cty.Value, error) {
res, err := s.reader.ReadResource(
terraform.ReadResourceArgs{
Ty: resourceaws.AwsIamUserResourceType,

View File

@ -68,7 +68,7 @@ func Init(alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary,
supplierLibrary.AddSupplier(NewSqsQueuePolicySupplier(provider))
supplierLibrary.AddSupplier(NewSNSTopicSupplier(provider))
supplierLibrary.AddSupplier(NewSNSTopicPolicySupplier(provider))
supplierLibrary.AddSupplier(NewSNSTopicSubscriptionSupplier(provider))
supplierLibrary.AddSupplier(NewSNSTopicSubscriptionSupplier(provider, alerter))
supplierLibrary.AddSupplier(NewDynamoDBTableSupplier(provider))
supplierLibrary.AddSupplier(NewRoute53HealthCheckSupplier(provider))
supplierLibrary.AddSupplier(NewCloudfrontDistributionSupplier(provider))

View File

@ -29,7 +29,7 @@ func NewInternetGatewaySupplier(provider *AWSTerraformProvider) *InternetGateway
}
}
func (s InternetGatewaySupplier) Resources() ([]resource.Resource, error) {
func (s *InternetGatewaySupplier) Resources() ([]resource.Resource, error) {
internetGateways, err := listInternetGateways(s.client)
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsInternetGatewayResourceType)
@ -50,7 +50,7 @@ func (s InternetGatewaySupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(resources)
}
func (s InternetGatewaySupplier) readInternetGateway(internetGateway ec2.InternetGateway) (cty.Value, error) {
func (s *InternetGatewaySupplier) readInternetGateway(internetGateway ec2.InternetGateway) (cty.Value, error) {
var Ty resource.ResourceType = aws.AwsInternetGatewayResourceType
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
Ty: Ty,

View File

@ -30,7 +30,7 @@ func NewKMSAliasSupplier(provider *AWSTerraformProvider) *KMSAliasSupplier {
}
}
func (s KMSAliasSupplier) Resources() ([]resource.Resource, error) {
func (s *KMSAliasSupplier) Resources() ([]resource.Resource, error) {
aliases, err := s.client.ListAllAliases()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsKmsAliasResourceType)
@ -51,7 +51,7 @@ func (s KMSAliasSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(retrieve)
}
func (s KMSAliasSupplier) readAlias(alias *kms.AliasListEntry) (cty.Value, error) {
func (s *KMSAliasSupplier) readAlias(alias *kms.AliasListEntry) (cty.Value, error) {
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
ID: *alias.AliasName,
Ty: aws.AwsKmsAliasResourceType,

View File

@ -30,7 +30,7 @@ func NewKMSKeySupplier(provider *AWSTerraformProvider) *KMSKeySupplier {
}
}
func (s KMSKeySupplier) Resources() ([]resource.Resource, error) {
func (s *KMSKeySupplier) Resources() ([]resource.Resource, error) {
keys, err := s.client.ListAllKeys()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsKmsKeyResourceType)
@ -51,7 +51,7 @@ func (s KMSKeySupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(retrieve)
}
func (s KMSKeySupplier) readKey(key *kms.KeyListEntry) (cty.Value, error) {
func (s *KMSKeySupplier) readKey(key *kms.KeyListEntry) (cty.Value, error) {
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
ID: *key.KeyId,
Ty: aws.AwsKmsKeyResourceType,

View File

@ -29,7 +29,7 @@ func NewLambdaEventSourceMappingSupplier(provider *AWSTerraformProvider) *Lambda
}
}
func (s LambdaEventSourceMappingSupplier) Resources() ([]resource.Resource, error) {
func (s *LambdaEventSourceMappingSupplier) Resources() ([]resource.Resource, error) {
functions, err := s.client.ListAllLambdaEventSourceMappings()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsLambdaEventSourceMappingResourceType)
@ -49,7 +49,7 @@ func (s LambdaEventSourceMappingSupplier) Resources() ([]resource.Resource, erro
return s.deserializer.Deserialize(results)
}
func (s LambdaEventSourceMappingSupplier) readLambdaEventSourceMapping(sourceMappingConfig lambda.EventSourceMappingConfiguration) (cty.Value, error) {
func (s *LambdaEventSourceMappingSupplier) readLambdaEventSourceMapping(sourceMappingConfig lambda.EventSourceMappingConfiguration) (cty.Value, error) {
resFunction, err := s.reader.ReadResource(
terraform.ReadResourceArgs{
Ty: resourceaws.AwsLambdaEventSourceMappingResourceType,

View File

@ -29,7 +29,7 @@ func NewLambdaFunctionSupplier(provider *AWSTerraformProvider) *LambdaFunctionSu
}
}
func (s LambdaFunctionSupplier) Resources() ([]resource.Resource, error) {
func (s *LambdaFunctionSupplier) Resources() ([]resource.Resource, error) {
functions, err := s.client.ListAllLambdaFunctions()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsLambdaFunctionResourceType)
@ -50,7 +50,7 @@ func (s LambdaFunctionSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s LambdaFunctionSupplier) readLambda(function lambda.FunctionConfiguration) (cty.Value, error) {
func (s *LambdaFunctionSupplier) readLambda(function lambda.FunctionConfiguration) (cty.Value, error) {
name := *function.FunctionName
resFunction, err := s.reader.ReadResource(
terraform.ReadResourceArgs{

View File

@ -29,7 +29,7 @@ func NewNatGatewaySupplier(provider *AWSTerraformProvider) *NatGatewaySupplier {
}
}
func (s NatGatewaySupplier) Resources() ([]resource.Resource, error) {
func (s *NatGatewaySupplier) Resources() ([]resource.Resource, error) {
retrievedNatGateways, err := listNatGateways(s.client)
if err != nil {
@ -58,7 +58,7 @@ func (s NatGatewaySupplier) Resources() ([]resource.Resource, error) {
return resources, nil
}
func (s NatGatewaySupplier) readNatGateway(gateway ec2.NatGateway) (cty.Value, error) {
func (s *NatGatewaySupplier) readNatGateway(gateway ec2.NatGateway) (cty.Value, error) {
var Ty resource.ResourceType = aws.AwsNatGatewayResourceType
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
ID: *gateway.NatGatewayId,

View File

@ -30,7 +30,7 @@ func NewRoute53HealthCheckSupplier(provider *AWSTerraformProvider) *Route53Healt
}
}
func (s Route53HealthCheckSupplier) Resources() ([]resource.Resource, error) {
func (s *Route53HealthCheckSupplier) Resources() ([]resource.Resource, error) {
healthChecks, err := s.client.ListAllHealthChecks()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsRoute53HealthCheckResourceType)
@ -51,7 +51,7 @@ func (s Route53HealthCheckSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(retrieve)
}
func (s Route53HealthCheckSupplier) readHealthCheck(healthCheck *route53.HealthCheck) (cty.Value, error) {
func (s *Route53HealthCheckSupplier) readHealthCheck(healthCheck *route53.HealthCheck) (cty.Value, error) {
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
ID: *healthCheck.Id,
Ty: aws.AwsRoute53HealthCheckResourceType,

View File

@ -32,7 +32,7 @@ func NewRoute53RecordSupplier(provider *AWSTerraformProvider) *Route53RecordSupp
terraform.NewParallelResourceReader(provider.Runner().SubRunner())}
}
func (s Route53RecordSupplier) Resources() ([]resource.Resource, error) {
func (s *Route53RecordSupplier) Resources() ([]resource.Resource, error) {
zones, err := s.listZones()
if err != nil {
@ -52,7 +52,7 @@ func (s Route53RecordSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s Route53RecordSupplier) listZones() ([][2]string, error) {
func (s *Route53RecordSupplier) listZones() ([][2]string, error) {
results := make([][2]string, 0)
zones, err := s.client.ListAllZones()
if err != nil {
@ -66,7 +66,7 @@ func (s Route53RecordSupplier) listZones() ([][2]string, error) {
return results, nil
}
func (s Route53RecordSupplier) listRecordsForZone(zoneId string, zoneName string) error {
func (s *Route53RecordSupplier) listRecordsForZone(zoneId string, zoneName string) error {
records, err := s.client.ListRecordsForZone(zoneId)

View File

@ -34,7 +34,7 @@ func NewRoute53ZoneSupplier(provider *AWSTerraformProvider) *Route53ZoneSupplier
}
}
func (s Route53ZoneSupplier) Resources() ([]resource.Resource, error) {
func (s *Route53ZoneSupplier) Resources() ([]resource.Resource, error) {
zones, err := s.client.ListAllZones()
if err != nil {
@ -55,7 +55,7 @@ func (s Route53ZoneSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s Route53ZoneSupplier) readZone(hostedZone route53.HostedZone) (cty.Value, error) {
func (s *Route53ZoneSupplier) readZone(hostedZone route53.HostedZone) (cty.Value, error) {
name := *hostedZone.Name
zone, err := s.reader.ReadResource(terraform.ReadResourceArgs{

View File

@ -29,7 +29,7 @@ func NewRouteSupplier(provider *AWSTerraformProvider) *RouteSupplier {
}
}
func (s RouteSupplier) Resources() ([]resource.Resource, error) {
func (s *RouteSupplier) Resources() ([]resource.Resource, error) {
routeTables, err := listRouteTables(s.client, aws.AwsRouteResourceType)
if err != nil {
@ -59,7 +59,7 @@ func (s RouteSupplier) Resources() ([]resource.Resource, error) {
return deserializedRoutes, nil
}
func (s RouteSupplier) readRoute(tableId string, route ec2.Route) (cty.Value, error) {
func (s *RouteSupplier) readRoute(tableId string, route ec2.Route) (cty.Value, error) {
var Ty resource.ResourceType = aws.AwsRouteResourceType
attributes := map[string]interface{}{

View File

@ -29,7 +29,7 @@ func NewRouteTableAssociationSupplier(provider *AWSTerraformProvider) *RouteTabl
}
}
func (s RouteTableAssociationSupplier) Resources() ([]resource.Resource, error) {
func (s *RouteTableAssociationSupplier) Resources() ([]resource.Resource, error) {
tables, err := listRouteTables(s.client, aws.AwsRouteTableAssociationResourceType)
if err != nil {
@ -64,7 +64,7 @@ func (s RouteTableAssociationSupplier) Resources() ([]resource.Resource, error)
return deserializedRouteTableAssociations, nil
}
func (s RouteTableAssociationSupplier) readRouteTableAssociation(assoc ec2.RouteTableAssociation) (cty.Value, error) {
func (s *RouteTableAssociationSupplier) readRouteTableAssociation(assoc ec2.RouteTableAssociation) (cty.Value, error) {
var Ty resource.ResourceType = aws.AwsRouteTableAssociationResourceType
attributes := map[string]interface{}{
"route_table_id": *assoc.RouteTableId,
@ -83,7 +83,7 @@ func (s RouteTableAssociationSupplier) readRouteTableAssociation(assoc ec2.Route
return *val, nil
}
func (s RouteTableAssociationSupplier) shouldBeIgnored(assoc *ec2.RouteTableAssociation) bool {
func (s *RouteTableAssociationSupplier) shouldBeIgnored(assoc *ec2.RouteTableAssociation) bool {
// Ignore when nothing is associated
if assoc.GatewayId == nil && assoc.SubnetId == nil {

View File

@ -37,14 +37,17 @@ func NewRouteTableSupplier(provider *AWSTerraformProvider) *RouteTableSupplier {
}
}
func (s RouteTableSupplier) Resources() ([]resource.Resource, error) {
func (s *RouteTableSupplier) Resources() ([]resource.Resource, error) {
retrievedRouteTables, err := listRouteTables(s.client, aws.AwsRouteTableResourceType)
results, err := listRouteTables(s.client, aws.AwsRouteTableResourceType)
if err != nil {
return nil, err
}
for _, routeTable := range retrievedRouteTables {
retrievedDefaultRouteTables := []*ec2.RouteTable{}
retrievedRouteTables := []*ec2.RouteTable{}
for _, routeTable := range results {
res := *routeTable
var isMain bool
for _, assoc := range res.Associations {
@ -54,13 +57,16 @@ func (s RouteTableSupplier) Resources() ([]resource.Resource, error) {
}
}
if isMain {
s.defaultRouteTableRunner.Run(func() (cty.Value, error) {
return s.readRouteTable(res, true)
})
retrievedDefaultRouteTables = append(retrievedDefaultRouteTables, &res)
continue
}
s.routeTableRunner.Run(func() (cty.Value, error) {
return s.readRouteTable(res, false)
retrievedRouteTables = append(retrievedRouteTables, &res)
}
for _, routeTable := range retrievedDefaultRouteTables {
res := *routeTable
s.defaultRouteTableRunner.Run(func() (cty.Value, error) {
return s.readRouteTable(res, true)
})
}
@ -69,6 +75,14 @@ func (s RouteTableSupplier) Resources() ([]resource.Resource, error) {
if err != nil {
return nil, err
}
for _, routeTable := range retrievedRouteTables {
res := *routeTable
s.routeTableRunner.Run(func() (cty.Value, error) {
return s.readRouteTable(res, false)
})
}
routeTableResources, err := s.routeTableRunner.Wait()
if err != nil {
return nil, err
@ -91,7 +105,7 @@ func (s RouteTableSupplier) Resources() ([]resource.Resource, error) {
return resources, nil
}
func (s RouteTableSupplier) readRouteTable(routeTable ec2.RouteTable, isMain bool) (cty.Value, error) {
func (s *RouteTableSupplier) readRouteTable(routeTable ec2.RouteTable, isMain bool) (cty.Value, error) {
var Ty resource.ResourceType = aws.AwsRouteTableResourceType
attributes := map[string]interface{}{}
if isMain {

View File

@ -33,7 +33,7 @@ func NewS3BucketSupplier(provider *AWSTerraformProvider, repository repository.S
}
}
func (s S3BucketSupplier) Resources() ([]resource.Resource, error) {
func (s *S3BucketSupplier) Resources() ([]resource.Resource, error) {
buckets, err := s.repository.ListAllBuckets()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsS3BucketResourceType)

View File

@ -30,7 +30,7 @@ func NewSNSTopicPolicySupplier(provider *AWSTerraformProvider) *SNSTopicPolicySu
}
}
func (s SNSTopicPolicySupplier) Resources() ([]resource.Resource, error) {
func (s *SNSTopicPolicySupplier) Resources() ([]resource.Resource, error) {
topics, err := s.client.ListAllTopics()
if err != nil {
return nil, remoteerror.NewResourceEnumerationErrorWithType(err, aws.AwsSnsTopicPolicyResourceType, aws.AwsSnsTopicResourceType)
@ -51,7 +51,7 @@ func (s SNSTopicPolicySupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(retrieve)
}
func (s SNSTopicPolicySupplier) readTopicPolicy(topic sns.Topic) (cty.Value, error) {
func (s *SNSTopicPolicySupplier) readTopicPolicy(topic sns.Topic) (cty.Value, error) {
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
ID: *topic.TopicArn,
Ty: aws.AwsSnsTopicPolicyResourceType,

View File

@ -1,12 +1,17 @@
package aws
import (
"fmt"
awssdk "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/sns"
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
"github.com/sirupsen/logrus"
"github.com/zclconf/go-cty/cty"
"github.com/cloudskiff/driftctl/pkg/alerter"
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
"github.com/cloudskiff/driftctl/pkg/remote/deserializer"
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/cloudskiff/driftctl/pkg/resource/aws"
@ -14,23 +19,39 @@ import (
"github.com/cloudskiff/driftctl/pkg/terraform"
)
type pendingTopicAlert struct {
endpoint *string
}
func (p *pendingTopicAlert) Message() string {
return fmt.Sprintf("%s with pending confirmation status for endpoint \"%s\" will be ignored",
aws.AwsSnsTopicSubscriptionResourceType,
awssdk.StringValue(p.endpoint))
}
func (p *pendingTopicAlert) ShouldIgnoreResource() bool {
return false
}
type SNSTopicSubscriptionSupplier struct {
reader terraform.ResourceReader
deserializer deserializer.CTYDeserializer
client repository.SNSRepository
runner *terraform.ParallelResourceReader
alerter alerter.AlerterInterface
}
func NewSNSTopicSubscriptionSupplier(provider *AWSTerraformProvider) *SNSTopicSubscriptionSupplier {
func NewSNSTopicSubscriptionSupplier(provider *AWSTerraformProvider, a alerter.AlerterInterface) *SNSTopicSubscriptionSupplier {
return &SNSTopicSubscriptionSupplier{
provider,
awsdeserializer.NewSNSTopicSubscriptionDeserializer(),
repository.NewSNSClient(provider.session),
terraform.NewParallelResourceReader(provider.Runner().SubRunner()),
a,
}
}
func (s SNSTopicSubscriptionSupplier) Resources() ([]resource.Resource, error) {
func (s *SNSTopicSubscriptionSupplier) Resources() ([]resource.Resource, error) {
subscriptions, err := s.client.ListAllSubscriptions()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsSnsTopicSubscriptionResourceType)
@ -38,7 +59,7 @@ func (s SNSTopicSubscriptionSupplier) Resources() ([]resource.Resource, error) {
for _, subscription := range subscriptions {
subscription := subscription
s.runner.Run(func() (cty.Value, error) {
return s.readTopicSubscription(subscription)
return s.readTopicSubscription(subscription, s.alerter)
})
}
@ -50,7 +71,15 @@ func (s SNSTopicSubscriptionSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(retrieve)
}
func (s SNSTopicSubscriptionSupplier) readTopicSubscription(subscription *sns.Subscription) (cty.Value, error) {
func (s *SNSTopicSubscriptionSupplier) readTopicSubscription(subscription *sns.Subscription, alertr alerter.AlerterInterface) (cty.Value, error) {
if subscription.SubscriptionArn != nil && *subscription.SubscriptionArn == "PendingConfirmation" {
alertr.SendAlert(
fmt.Sprintf("%s.%s", aws.AwsSnsTopicSubscriptionResourceType, *subscription.SubscriptionArn),
&pendingTopicAlert{subscription.Endpoint},
)
return cty.NilVal, nil
}
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
ID: *subscription.SubscriptionArn,
Ty: aws.AwsSnsTopicSubscriptionResourceType,

View File

@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/service/sns"
"github.com/cloudskiff/driftctl/pkg/alerter"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
resourceaws "github.com/cloudskiff/driftctl/pkg/resource/aws"
@ -35,6 +36,7 @@ func TestSNSTopicSubscriptionSupplier_Resources(t *testing.T) {
test string
dirName string
mocks func(client *mocks.SNSRepository)
alerts alerter.Alerts
err error
}{
{
@ -56,6 +58,23 @@ func TestSNSTopicSubscriptionSupplier_Resources(t *testing.T) {
},
err: nil,
},
{
test: "Multiple SNSTopic Subscription with one pending",
dirName: "sns_topic_subscription_multiple",
mocks: func(client *mocks.SNSRepository) {
client.On("ListAllSubscriptions").Return([]*sns.Subscription{
{SubscriptionArn: aws.String("PendingConfirmation"), Endpoint: aws.String("TEST")},
{SubscriptionArn: aws.String("arn:aws:sns:us-east-1:526954929923:user-updates-topic2:c0f794c5-a009-4db4-9147-4c55959787fa")},
{SubscriptionArn: aws.String("arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e")},
}, nil)
},
alerts: map[string][]alerter.Alert{
"aws_sns_topic_subscription.PendingConfirmation": []alerter.Alert{
&pendingTopicAlert{aws.String("TEST")},
},
},
err: nil,
},
{
test: "cannot list SNSTopic subscription",
dirName: "sns_topic_subscription_list",
@ -72,14 +91,16 @@ func TestSNSTopicSubscriptionSupplier_Resources(t *testing.T) {
supplierLibrary := resource.NewSupplierLibrary()
if shouldUpdate {
a := alerter.NewAlerter()
provider, err := InitTestAwsProvider(providerLibrary)
if err != nil {
t.Fatal(err)
}
supplierLibrary.AddSupplier(NewSNSTopicSubscriptionSupplier(provider))
supplierLibrary.AddSupplier(NewSNSTopicSubscriptionSupplier(provider, a))
}
t.Run(c.test, func(tt *testing.T) {
a := alerter.NewAlerter()
fakeClient := mocks.SNSRepository{}
c.mocks(&fakeClient)
provider := mocks2.NewMockedGoldenTFProvider(c.dirName, providerLibrary.Provider(terraform.AWS), shouldUpdate)
@ -89,10 +110,15 @@ func TestSNSTopicSubscriptionSupplier_Resources(t *testing.T) {
topicSubscriptionDeserializer,
&fakeClient,
terraform.NewParallelResourceReader(parallel.NewParallelRunner(context.TODO(), 10)),
a,
}
got, err := s.Resources()
assert.Equal(tt, c.err, err)
if c.alerts == nil {
c.alerts = map[string][]alerter.Alert{}
}
assert.Equal(tt, c.alerts, a.Retrieve())
mock.AssertExpectationsForObjects(tt)
test.CtyTestDiff(got, c.dirName, provider, topicSubscriptionDeserializer, shouldUpdate, tt)
})

View File

@ -30,7 +30,7 @@ func NewSNSTopicSupplier(provider *AWSTerraformProvider) *SNSTopicSupplier {
}
}
func (s SNSTopicSupplier) Resources() ([]resource.Resource, error) {
func (s *SNSTopicSupplier) Resources() ([]resource.Resource, error) {
topics, err := s.client.ListAllTopics()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsSnsTopicResourceType)
@ -51,7 +51,7 @@ func (s SNSTopicSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(retrieve)
}
func (s SNSTopicSupplier) readTopic(topic sns.Topic) (cty.Value, error) {
func (s *SNSTopicSupplier) readTopic(topic sns.Topic) (cty.Value, error) {
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
ID: *topic.TopicArn,
Ty: aws.AwsSnsTopicResourceType,

View File

@ -28,7 +28,7 @@ func NewSqsQueuePolicySupplier(provider *AWSTerraformProvider) *SqsQueuePolicySu
}
}
func (s SqsQueuePolicySupplier) Resources() ([]resource.Resource, error) {
func (s *SqsQueuePolicySupplier) Resources() ([]resource.Resource, error) {
queues, err := s.client.ListAllQueues()
if err != nil {
return nil, remoteerror.NewResourceEnumerationErrorWithType(err, aws.AwsSqsQueuePolicyResourceType, aws.AwsSqsQueueResourceType)
@ -49,7 +49,7 @@ func (s SqsQueuePolicySupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(resources)
}
func (s SqsQueuePolicySupplier) readSqsQueuePolicy(queueURL string) (cty.Value, error) {
func (s *SqsQueuePolicySupplier) readSqsQueuePolicy(queueURL string) (cty.Value, error) {
var Ty resource.ResourceType = aws.AwsSqsQueuePolicyResourceType
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
Ty: Ty,

View File

@ -28,7 +28,7 @@ func NewSqsQueueSupplier(provider *AWSTerraformProvider) *SqsQueueSupplier {
}
}
func (s SqsQueueSupplier) Resources() ([]resource.Resource, error) {
func (s *SqsQueueSupplier) Resources() ([]resource.Resource, error) {
queues, err := s.client.ListAllQueues()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsSqsQueueResourceType)
@ -49,7 +49,7 @@ func (s SqsQueueSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(resources)
}
func (s SqsQueueSupplier) readSqsQueue(queueURL string) (cty.Value, error) {
func (s *SqsQueueSupplier) readSqsQueue(queueURL string) (cty.Value, error) {
var Ty resource.ResourceType = aws.AwsSqsQueueResourceType
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
Ty: Ty,

View File

@ -36,7 +36,7 @@ func NewSubnetSupplier(provider *AWSTerraformProvider) *SubnetSupplier {
}
}
func (s SubnetSupplier) Resources() ([]resource.Resource, error) {
func (s *SubnetSupplier) Resources() ([]resource.Resource, error) {
input := ec2.DescribeSubnetsInput{}
var subnets []*ec2.Subnet
var defaultSubnets []*ec2.Subnet
@ -64,6 +64,11 @@ func (s SubnetSupplier) Resources() ([]resource.Resource, error) {
})
}
subnetResources, err := s.subnetRunner.Wait()
if err != nil {
return nil, err
}
for _, item := range defaultSubnets {
res := *item
s.defaultSubnetRunner.Run(func() (cty.Value, error) {
@ -76,10 +81,6 @@ func (s SubnetSupplier) Resources() ([]resource.Resource, error) {
if err != nil {
return nil, err
}
subnetResources, err := s.subnetRunner.Wait()
if err != nil {
return nil, err
}
// Deserialize
deserializedDefaultSubnets, err := s.defaultSubnetDeserializer.Deserialize(defaultSubnetResources)
@ -98,7 +99,7 @@ func (s SubnetSupplier) Resources() ([]resource.Resource, error) {
return resources, nil
}
func (s SubnetSupplier) readSubnet(subnet ec2.Subnet) (cty.Value, error) {
func (s *SubnetSupplier) readSubnet(subnet ec2.Subnet) (cty.Value, error) {
var Ty resource.ResourceType = aws.AwsSubnetResourceType
if subnet.DefaultForAz != nil && *subnet.DefaultForAz {
Ty = aws.AwsDefaultSubnetResourceType

View File

@ -38,7 +38,7 @@ func NewVPCSecurityGroupRuleSupplier(provider *AWSTerraformProvider) *VPCSecurit
}
}
func (s VPCSecurityGroupRuleSupplier) Resources() ([]resource.Resource, error) {
func (s *VPCSecurityGroupRuleSupplier) Resources() ([]resource.Resource, error) {
securityGroups, defaultSecurityGroups, err := listSecurityGroups(s.client)
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsSecurityGroupRuleResourceType)
@ -63,7 +63,7 @@ func (s VPCSecurityGroupRuleSupplier) Resources() ([]resource.Resource, error) {
return s.deserializer.Deserialize(results)
}
func (s VPCSecurityGroupRuleSupplier) readSecurityGroupRule(securityGroupRule resourceaws.AwsSecurityGroupRule) (cty.Value, error) {
func (s *VPCSecurityGroupRuleSupplier) readSecurityGroupRule(securityGroupRule resourceaws.AwsSecurityGroupRule) (cty.Value, error) {
id := securityGroupRule.Id
f := func(v *[]string) []string {
if v != nil {
@ -94,7 +94,7 @@ func (s VPCSecurityGroupRuleSupplier) readSecurityGroupRule(securityGroupRule re
return *resSgRule, nil
}
func (s VPCSecurityGroupRuleSupplier) listSecurityGroupsRules(securityGroups []*ec2.SecurityGroup) []resourceaws.AwsSecurityGroupRule {
func (s *VPCSecurityGroupRuleSupplier) listSecurityGroupsRules(securityGroups []*ec2.SecurityGroup) []resourceaws.AwsSecurityGroupRule {
var securityGroupsRules []resourceaws.AwsSecurityGroupRule
for _, sg := range securityGroups {
for _, rule := range sg.IpPermissions {
@ -109,7 +109,7 @@ func (s VPCSecurityGroupRuleSupplier) listSecurityGroupsRules(securityGroups []*
// addSecurityGroupRule will iterate through each "Source" as per Aws definition and create a
// rule with custom attributes
func (s VPCSecurityGroupRuleSupplier) addSecurityGroupRule(ruleType string, rule *ec2.IpPermission, sg *ec2.SecurityGroup) []resourceaws.AwsSecurityGroupRule {
func (s *VPCSecurityGroupRuleSupplier) addSecurityGroupRule(ruleType string, rule *ec2.IpPermission, sg *ec2.SecurityGroup) []resourceaws.AwsSecurityGroupRule {
var rules []resourceaws.AwsSecurityGroupRule
for _, groupPair := range rule.UserIdGroupPairs {
r := resourceaws.AwsSecurityGroupRule{
@ -179,7 +179,7 @@ func (s VPCSecurityGroupRuleSupplier) addSecurityGroupRule(ruleType string, rule
return rules
}
func (s VPCSecurityGroupRuleSupplier) isDefaultIngress(rule *resourceaws.AwsSecurityGroupRule) bool {
func (s *VPCSecurityGroupRuleSupplier) isDefaultIngress(rule *resourceaws.AwsSecurityGroupRule) bool {
return rule.Type != nil &&
*rule.Type == sgRuleTypeIngress &&
rule.FromPort != nil &&
@ -196,7 +196,7 @@ func (s VPCSecurityGroupRuleSupplier) isDefaultIngress(rule *resourceaws.AwsSecu
*rule.Self
}
func (s VPCSecurityGroupRuleSupplier) isDefaultEgress(rule *resourceaws.AwsSecurityGroupRule) bool {
func (s *VPCSecurityGroupRuleSupplier) isDefaultEgress(rule *resourceaws.AwsSecurityGroupRule) bool {
return rule.Type != nil &&
*rule.Type == sgRuleTypeEgress &&
rule.FromPort != nil &&

View File

@ -36,7 +36,7 @@ func NewVPCSecurityGroupSupplier(provider *AWSTerraformProvider) *VPCSecurityGro
}
}
func (s VPCSecurityGroupSupplier) Resources() ([]resource.Resource, error) {
func (s *VPCSecurityGroupSupplier) Resources() ([]resource.Resource, error) {
securityGroups, defaultSecurityGroups, err := listSecurityGroups(s.client)
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, resourceaws.AwsSecurityGroupResourceType)
@ -81,7 +81,7 @@ func (s VPCSecurityGroupSupplier) Resources() ([]resource.Resource, error) {
return resources, nil
}
func (s VPCSecurityGroupSupplier) readSecurityGroup(securityGroup ec2.SecurityGroup) (cty.Value, error) {
func (s *VPCSecurityGroupSupplier) readSecurityGroup(securityGroup ec2.SecurityGroup) (cty.Value, error) {
var Ty resource.ResourceType = resourceaws.AwsSecurityGroupResourceType
if isDefaultSecurityGroup(securityGroup) {
Ty = resourceaws.AwsDefaultSecurityGroupResourceType

View File

@ -36,7 +36,7 @@ func NewVPCSupplier(provider *AWSTerraformProvider) *VPCSupplier {
}
}
func (s VPCSupplier) Resources() ([]resource.Resource, error) {
func (s *VPCSupplier) Resources() ([]resource.Resource, error) {
input := ec2.DescribeVpcsInput{}
var VPCs []*ec2.Vpc
var defaultVPCs []*ec2.Vpc
@ -64,6 +64,11 @@ func (s VPCSupplier) Resources() ([]resource.Resource, error) {
})
}
VPCResources, err := s.vpcRunner.Wait()
if err != nil {
return nil, err
}
for _, item := range defaultVPCs {
res := *item
s.defaultVPCRunner.Run(func() (cty.Value, error) {
@ -76,10 +81,6 @@ func (s VPCSupplier) Resources() ([]resource.Resource, error) {
if err != nil {
return nil, err
}
VPCResources, err := s.vpcRunner.Wait()
if err != nil {
return nil, err
}
// Deserialize
deserializedDefaultVPCs, err := s.defaultVPCDeserializer.Deserialize(defaultVPCResources)
@ -98,7 +99,7 @@ func (s VPCSupplier) Resources() ([]resource.Resource, error) {
return resources, nil
}
func (s VPCSupplier) readVPC(vpc ec2.Vpc) (cty.Value, error) {
func (s *VPCSupplier) readVPC(vpc ec2.Vpc) (cty.Value, error) {
var Ty resource.ResourceType = aws.AwsVpcResourceType
if vpc.IsDefault != nil && *vpc.IsDefault {
Ty = aws.AwsDefaultVpcResourceType

View File

@ -23,6 +23,7 @@ func (s SNSTopicSubscriptionDeserializer) Deserialize(subscriptionsList []cty.Va
subscriptions := make([]resource.Resource, 0)
for _, value := range subscriptionsList {
value := value
subscription, err := decodeSNSTopicSubscription(value)
if err != nil {