def _set_topic_attrs(self):
    changed = False
    try:
        topic_attributes = self.connection.get_topic_attributes(TopicArn=self.topic_arn)['Attributes']
    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
        self.module.fail_json_aws(e, msg=("Couldn't get topic attributes for topic %s" % self.topic_arn))
    if (self.display_name and (self.display_name != topic_attributes['DisplayName'])):
        changed = True
        self.attributes_set.append('display_name')
        if (not self.check_mode):
            try:
                self.connection.set_topic_attributes(TopicArn=self.topic_arn, AttributeName='DisplayName', AttributeValue=self.display_name)
            except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
                self.module.fail_json_aws(e, msg="Couldn't set display name")
    if (self.policy and compare_policies(self.policy, json.loads(topic_attributes['Policy']))):
        changed = True
        self.attributes_set.append('policy')
        if (not self.check_mode):
            try:
                self.connection.set_topic_attributes(TopicArn=self.topic_arn, AttributeName='Policy', AttributeValue=json.dumps(self.policy))
            except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
                self.module.fail_json_aws(e, msg="Couldn't set topic policy")
    if (self.delivery_policy and (('DeliveryPolicy' not in topic_attributes) or self._compare_delivery_policies(self.delivery_policy, json.loads(topic_attributes['DeliveryPolicy'])))):
        changed = True
        self.attributes_set.append('delivery_policy')
        if (not self.check_mode):
            try:
                self.connection.set_topic_attributes(TopicArn=self.topic_arn, AttributeName='DeliveryPolicy', AttributeValue=json.dumps(self.delivery_policy))
            except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
                self.module.fail_json_aws(e, msg="Couldn't set topic delivery policy")
    return changed
def _set_topic_attrs(self):
    changed = False
    try:
        topic_attributes = self.connection.get_topic_attributes(TopicArn=self.topic_arn)['Attributes']
    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
        self.module.fail_json_aws(e, msg=("Couldn't get topic attributes for topic %s" % self.topic_arn))
    if (self.display_name and (self.display_name != topic_attributes['DisplayName'])):
        changed = True
        self.attributes_set.append('display_name')
        if (not self.check_mode):
            try:
                self.connection.set_topic_attributes(TopicArn=self.topic_arn, AttributeName='DisplayName', AttributeValue=self.display_name)
            except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
                self.module.fail_json_aws(e, msg="Couldn't set display name")
    if (self.policy and compare_policies(self.policy, json.loads(topic_attributes['Policy']))):
        changed = True
        self.attributes_set.append('policy')
        if (not self.check_mode):
            try:
                self.connection.set_topic_attributes(TopicArn=self.topic_arn, AttributeName='Policy', AttributeValue=json.dumps(self.policy))
            except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
                self.module.fail_json_aws(e, msg="Couldn't set topic policy")
    if (self.delivery_policy and (('DeliveryPolicy' not in topic_attributes) or self._compare_delivery_policies(self.delivery_policy, json.loads(topic_attributes['DeliveryPolicy'])))):
        changed = True
        self.attributes_set.append('delivery_policy')
        if (not self.check_mode):
            try:
                self.connection.set_topic_attributes(TopicArn=self.topic_arn, AttributeName='DeliveryPolicy', AttributeValue=json.dumps(self.delivery_policy))
            except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
                self.module.fail_json_aws(e, msg="Couldn't set topic delivery policy")
    return changed