topic_policy#

State module for managing SNS topic policy.

async idem_aws.states.aws.sns.topic_policy.present(hub, ctx, name: str, topic_arn: str, policy: str, resource_id: str = None) Dict[str, Any][source]#

Updates the topic’s policy attribute.

A topic can have a single policy, checks for changes in policy attribute and updates it if required.

Parameters:
  • name (str) – The idem name for the topic_policy

  • topic_arn (str) – The ARN of the topic for which the policy should be updated

  • policy (str) – Topic policy, in json string format

  • resource_id (str, Optional) – Topic arn and ‘policy’ keyword separated with ‘-’

Returns:

dict[str, Any]

Examples

topic-policy-name:
  aws.sns.topic_policy.present:
    - name: topic-policy-name
    - topic_arn: arn:aws:sns:eu-west-3:537227425989:test-topic
    - policy: '{"Version": "2012-10-17", "Id": "id-1", "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"],
               "Resource": "arn:aws:sns:eu-west-3:537227425989:test-topic", "Condition": {"StringEquals":
               {"AWS:SourceOwner": "537227425989"}}}]}'
    - resource_id: arn:aws:sns:eu-west-3:537227425989:test-topic-policy
async idem_aws.states.aws.sns.topic_policy.absent(hub, ctx, name: str, resource_id: str = None) Dict[str, Any][source]#

Deletes the current topic policy and replace with the default value.

This action is idempotent, so deleting a topic’s policy that does not exist does not result in an error.

Parameters:
  • name (str) – The idem name of the topic_policy.

  • resource_id (str, Optional) – Topic arn and ‘policy’ keyword separated with ‘-’

Returns:

dict[str, Any]

Examples

test-topic-policy:
  aws.sns.topic_policy.absent:
  - name: test-topic-policy
  - resource_id: arn:aws:sns:eu-west-3:537227425989:test-topic-policy
async idem_aws.states.aws.sns.topic_policy.describe(hub, ctx) Dict[str, Dict[str, Any]][source]#

Describe the resource in a way that can be recreated/managed with the corresponding “present” function.

Describes list of all the topic policy

Returns:

dict[str, Any]

Examples

$ idem describe aws.sns.topic_policy