Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alina Buzachis <[email protected]>
  • Loading branch information
alinabuzachis committed Sep 13, 2022
1 parent 11ff0c8 commit cdafdba
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 41 deletions.
24 changes: 20 additions & 4 deletions plugins/modules/rds_export_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
---
module: rds_export_task
version_added: 5.0.0
short_description: rds_export_task
short_description: Starts and cancels an export of a snapshot to Amazon S3
author: Alina Buzachis (@alinabuzachis)
description:
- Starts an export of a snapshot to Amazon S3.
Expand Down Expand Up @@ -50,6 +50,8 @@
description:
- The ID of the Amazon Web Services KMS customer master key (CMK) to use to encrypt the snapshot exported to Amazon S3.
type: str
aliases:
- key_id
s3_prefix:
description:
- The Amazon S3 bucket prefix to use as the file name and path of the exported snapshot.
Expand All @@ -71,10 +73,24 @@
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.aws_boto3
"""

EXAMPLES = r"""
- name: Export snapshot to S3
amazon.aws.rds_export_task:
export_task_id: "{{ export_task_id }}"
source_arn: "{{ db_snapshot_arn }}"
s3_bucket_name: "{{ bucket_name }}"
iam_role_arn: "{{ iam_role_arn }}"
kms_key_id: "{{ kms_key_arn }}"
state: present
register: _result_export_task
- name: Delete an export task
amazon.aws.rds_export_task:
export_task_id: "{{ export_task_id }}"
state: absent
"""

RETURN = r"""
Expand Down Expand Up @@ -169,7 +185,7 @@ def main():
source_arn=dict(type="str"),
s3_bucket_name=dict(type="str", aliases=['s3_bucket']),
iam_role_arn=dict(type="str", aliases=['iam_role']),
kms_key_id=dict(type="str"),
kms_key_id=dict(type="str", aliases=['key_id']),
s3_prefix=dict(type="str"),
export_only=dict(type="list", elements="str"),
)
Expand Down Expand Up @@ -200,4 +216,4 @@ def main():


if __name__ == "__main__":
main()
main()
1 change: 1 addition & 0 deletions tests/integration/targets/rds_export_task/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cloud/aws
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"Action": "sts:AssumeRole"
}
]
}
}
74 changes: 38 additions & 36 deletions tests/integration/targets/rds_export_task/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
ansible-test: '{{ resource_prefix }}'
register: _result_create_key

- name: Create an s3 bucket
- name: Create an S3 bucket
s3_bucket:
name: '{{ bucket_name }}'
state: present
Expand All @@ -42,19 +42,19 @@
- _result_create_s3_bucket is changed
- _result_create_s3_bucket.name == '{{ bucket_name }}'

# - name: Enable aws:kms encryption with KMS key
# s3_bucket:
# name: '{{ bucket_name }}'
# state: present
# encryption: "aws:kms"
# encryption_key_id: "{{ _result_create_key.key_arn }}"
# register: _result_s3_bucket
- name: Enable aws:kms encryption with KMS key
s3_bucket:
name: '{{ bucket_name }}'
state: present
encryption: "aws:kms"
encryption_key_id: "{{ _result_create_key.key_arn }}"
register: _result_s3_bucket

# - assert:
# that:
# - _result_s3_bucket.changed
# - _result_s3_bucket.encryption
# - _result_s3_bucket.encryption.SSEAlgorithm == 'aws:kms'
- assert:
that:
- _result_s3_bucket.changed
- _result_s3_bucket.encryption
- _result_s3_bucket.encryption.SSEAlgorithm == 'aws:kms'

- name: Create a source mariadb instance
rds_instance:
Expand Down Expand Up @@ -82,13 +82,14 @@
- assert:
that:
- _result_instance_snapshot_info is successful
#- _result_instance_snapshot_info.snapshots | length == 1
- _result_instance_snapshot_info.snapshots | length == 1

- name: Take a snapshot of the existing RDS instance
rds_instance_snapshot:
state: present
db_instance_identifier: "{{ instance_id }}"
db_snapshot_identifier: "{{ snapshot_id }}"
wait: true
register: _result_instance_snapshot

- assert:
Expand All @@ -114,6 +115,7 @@
iam_role_arn: "{{ _result_create_iam_role.arn }}"
kms_key_id: "{{ _result_create_key.key_arn }}"
state: present
check_mode: true
register: _result_export_task

- name: Export snapshot to S3
Expand All @@ -135,31 +137,31 @@
kms_key_id: "{{ _result_create_key.key_arn }}"
register: _result_export_task

# - name: Delete an export task (CHECK_MODE)
# rds_export_task:
# export_task_id: "{{ export_task_id }}"
# state: absent
# check_mode: true
# register: _result_delete
- name: Delete an export task (CHECK_MODE)
rds_export_task:
export_task_id: "{{ export_task_id }}"
state: absent
check_mode: true
register: _result_delete

# - name: Delete an export task - idempotence
# rds_export_task:
# export_task_id: "{{ export_task_id }}"
# state: absent
# check_mode: true
# register: _result_delete
- name: Delete an export task - idempotence
rds_export_task:
export_task_id: "{{ export_task_id }}"
state: absent
check_mode: true
register: _result_delete

# - name: Delete an export task
# rds_export_task:
# export_task_id: "{{ export_task_id }}"
# state: absent
# register: _result_delete
- name: Delete an export task
rds_export_task:
export_task_id: "{{ export_task_id }}"
state: absent
register: _result_delete

# - name: Delete an export task - idempotence
# rds_export_task:
# export_task_id: "{{ export_task_id }}"
# state: absent
# register: _result_delete
- name: Delete an export task - idempotence
rds_export_task:
export_task_id: "{{ export_task_id }}"
state: absent
register: _result_delete

always:
- name: Delete an export task
Expand Down

0 comments on commit cdafdba

Please sign in to comment.