Fix false positive drifts on aws_sns_topic

main
Elie 2021-02-08 18:32:31 +01:00
parent 42595c13eb
commit 2f7fa28622
No known key found for this signature in database
GPG Key ID: 399AF69092C727B6
2 changed files with 30 additions and 12 deletions

View File

@ -2,70 +2,70 @@
{
"ApplicationFailureFeedbackRoleArn": "",
"ApplicationSuccessFeedbackRoleArn": "",
"ApplicationSuccessFeedbackSampleRate": null,
"ApplicationSuccessFeedbackSampleRate": 0,
"Arn": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic",
"DeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false,\"defaultThrottlePolicy\":{\"maxReceivesPerSecond\":1}}}",
"DisplayName": "",
"HttpFailureFeedbackRoleArn": "",
"HttpSuccessFeedbackRoleArn": "",
"HttpSuccessFeedbackSampleRate": null,
"HttpSuccessFeedbackSampleRate": 0,
"Id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic",
"KmsMasterKeyId": "",
"LambdaFailureFeedbackRoleArn": "",
"LambdaSuccessFeedbackRoleArn": "",
"LambdaSuccessFeedbackSampleRate": null,
"LambdaSuccessFeedbackSampleRate": 0,
"Name": "user-updates-topic",
"NamePrefix": null,
"Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:eu-west-3:526954929923:user-updates-topic\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"526954929923\"}}}]}",
"SqsFailureFeedbackRoleArn": "",
"SqsSuccessFeedbackRoleArn": "",
"SqsSuccessFeedbackSampleRate": null,
"SqsSuccessFeedbackSampleRate": 0,
"Tags": {}
},
{
"ApplicationFailureFeedbackRoleArn": "",
"ApplicationSuccessFeedbackRoleArn": "",
"ApplicationSuccessFeedbackSampleRate": null,
"ApplicationSuccessFeedbackSampleRate": 0,
"Arn": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic2",
"DeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false,\"defaultThrottlePolicy\":{\"maxReceivesPerSecond\":1}}}",
"DisplayName": "",
"HttpFailureFeedbackRoleArn": "",
"HttpSuccessFeedbackRoleArn": "",
"HttpSuccessFeedbackSampleRate": null,
"HttpSuccessFeedbackSampleRate": 0,
"Id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic2",
"KmsMasterKeyId": "",
"LambdaFailureFeedbackRoleArn": "",
"LambdaSuccessFeedbackRoleArn": "",
"LambdaSuccessFeedbackSampleRate": null,
"LambdaSuccessFeedbackSampleRate": 0,
"Name": "user-updates-topic2",
"NamePrefix": null,
"Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:eu-west-3:526954929923:user-updates-topic2\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"526954929923\"}}}]}",
"SqsFailureFeedbackRoleArn": "",
"SqsSuccessFeedbackRoleArn": "",
"SqsSuccessFeedbackSampleRate": null,
"SqsSuccessFeedbackSampleRate": 0,
"Tags": {}
},
{
"ApplicationFailureFeedbackRoleArn": "",
"ApplicationSuccessFeedbackRoleArn": "",
"ApplicationSuccessFeedbackSampleRate": null,
"ApplicationSuccessFeedbackSampleRate": 0,
"Arn": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic3",
"DeliveryPolicy": "",
"DisplayName": "",
"HttpFailureFeedbackRoleArn": "",
"HttpSuccessFeedbackRoleArn": "",
"HttpSuccessFeedbackSampleRate": null,
"HttpSuccessFeedbackSampleRate": 0,
"Id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic3",
"KmsMasterKeyId": "",
"LambdaFailureFeedbackRoleArn": "",
"LambdaSuccessFeedbackRoleArn": "",
"LambdaSuccessFeedbackSampleRate": null,
"LambdaSuccessFeedbackSampleRate": 0,
"Name": "user-updates-topic3",
"NamePrefix": null,
"Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:eu-west-3:526954929923:user-updates-topic3\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"526954929923\"}}}]}",
"SqsFailureFeedbackRoleArn": "",
"SqsSuccessFeedbackRoleArn": "",
"SqsSuccessFeedbackSampleRate": null,
"SqsSuccessFeedbackSampleRate": 0,
"Tags": {}
}
]

View File

@ -3,6 +3,7 @@ package aws
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/cloudskiff/driftctl/pkg/resource"
)
@ -10,14 +11,31 @@ func (r *AwsSnsTopic) NormalizeForState() (resource.Resource, error) {
if r.Policy != nil && *r.Policy == "" {
r.Policy = nil
}
r.normalizeDefaultFields()
return r, nil
}
func (r *AwsSnsTopic) NormalizeForProvider() (resource.Resource, error) {
r.Policy = nil
r.normalizeDefaultFields()
return r, nil
}
func (r *AwsSnsTopic) normalizeDefaultFields() {
if r.SqsSuccessFeedbackSampleRate == nil {
r.SqsSuccessFeedbackSampleRate = aws.Int(0)
}
if r.LambdaSuccessFeedbackSampleRate == nil {
r.LambdaSuccessFeedbackSampleRate = aws.Int(0)
}
if r.HttpSuccessFeedbackSampleRate == nil {
r.HttpSuccessFeedbackSampleRate = aws.Int(0)
}
if r.ApplicationSuccessFeedbackSampleRate == nil {
r.ApplicationSuccessFeedbackSampleRate = aws.Int(0)
}
}
func (r *AwsSnsTopic) String() string {
if r.DisplayName != nil && *r.DisplayName != "" && r.Name != nil && *r.Name != "" {
return fmt.Sprintf("%s (%s)", *r.DisplayName, *r.Name)