driftctl/pkg/remote/aws/sns_topic_policy_details_fe...

37 lines
1020 B
Go
Raw Normal View History

2021-07-06 16:46:38 +00:00
package aws
import (
"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, err
}
return r.deserializer.DeserializeOne(aws.AwsSnsTopicPolicyResourceType, *val)
}