mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-24 01:00:26 -07:00
Port the sns module to boto3 (#45634)
* Port sns to boto3 * Exception handling for ARN lookup * sns: Add integration tests
This commit is contained in:
parent
146709fb21
commit
be05069c61
5 changed files with 167 additions and 109 deletions
2
test/integration/targets/sns/aliases
Normal file
2
test/integration/targets/sns/aliases
Normal file
|
@ -0,0 +1,2 @@
|
|||
cloud/aws
|
||||
unsupported
|
1
test/integration/targets/sns/defaults/main.yml
Normal file
1
test/integration/targets/sns/defaults/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
sns_topic_name: "{{ resource_prefix }}-topic"
|
53
test/integration/targets/sns/tasks/main.yml
Normal file
53
test/integration/targets/sns/tasks/main.yml
Normal file
|
@ -0,0 +1,53 @@
|
|||
- name: set up AWS connection info
|
||||
set_fact:
|
||||
aws_connection_info: &aws_connection_info
|
||||
aws_secret_key: "{{ aws_secret_key }}"
|
||||
aws_access_key: "{{ aws_access_key }}"
|
||||
security_token: "{{ security_token }}"
|
||||
region: "{{ aws_region }}"
|
||||
no_log: true
|
||||
|
||||
- block:
|
||||
- name: Create an SNS topic
|
||||
sns_topic:
|
||||
name: "{{ sns_topic_name }}"
|
||||
display_name: "Test topic"
|
||||
<<: *aws_connection_info
|
||||
register: sns_topic
|
||||
|
||||
- name: Publish to the topic by name
|
||||
sns:
|
||||
topic: "{{ sns_topic_name }}"
|
||||
subject: Test message
|
||||
msg: Default test message
|
||||
http: Test message for HTTP
|
||||
https: Test message for HTTPS
|
||||
email: Test message for email
|
||||
email_json: Test message for email-json
|
||||
sms: Short test message for SMS
|
||||
sqs: Test message for SQS
|
||||
application: Test message for apps
|
||||
lambda: Test message for Lambda
|
||||
<<: *aws_connection_info
|
||||
register: result
|
||||
|
||||
- name: Check for expected result structure
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- "'message_id' in result"
|
||||
|
||||
- name: Publish to the topic by ARN
|
||||
sns:
|
||||
topic: "{{ sns_topic.sns_arn }}"
|
||||
subject: Second test message
|
||||
msg: Simple test message
|
||||
<<: *aws_connection_info
|
||||
|
||||
always:
|
||||
- name: Remove topic
|
||||
sns_topic:
|
||||
name: "{{ sns_topic_name }}"
|
||||
state: absent
|
||||
<<: *aws_connection_info
|
||||
ignore_errors: yes
|
Loading…
Add table
Add a link
Reference in a new issue