driftctl/pkg/remote/aws/sns_topic_subscription_deta...

42 lines
1.1 KiB
Go
Raw Normal View History

2021-07-07 17:23:43 +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 SNSTopicSubscriptionDetailsFetcher struct {
reader terraform.ResourceReader
deserializer *resource.Deserializer
}
func NewSNSTopicSubscriptionDetailsFetcher(provider terraform.ResourceReader, deserializer *resource.Deserializer) *SNSTopicSubscriptionDetailsFetcher {
return &SNSTopicSubscriptionDetailsFetcher{
reader: provider,
deserializer: deserializer,
}
}
func (r *SNSTopicSubscriptionDetailsFetcher) ReadDetails(res resource.Resource) (resource.Resource, error) {
ctyVal, err := r.reader.ReadResource(terraform.ReadResourceArgs{
ID: res.TerraformId(),
Ty: aws.AwsSnsTopicSubscriptionResourceType,
Attributes: map[string]string{
"SubscriptionId": res.TerraformId(),
},
})
if err != nil {
logrus.Error(err)
return nil, err
}
deserializedRes, err := r.deserializer.DeserializeOne(aws.AwsSnsTopicSubscriptionResourceType, *ctyVal)
if err != nil {
return nil, err
}
return deserializedRes, nil
}