How to trace ansible internal AWS S3 API Call

Hi Team,

Before Posting my question let me explain the problem of statement and use cases.

Usecase:
We had a scenario to delete the AWS S3 buckets and recreate the same bucket in the next deployment run.

Bucket was deleted approximately 2hrs 45 min before the deployment.
Later we triggered the deployment using ansible playbook (Approx 2hrs : 45min later) - Playbook failed at create bucket stage. with error as "Failed to get bucket versioning: An error occurred (NoSuchBucket) when calling the GetBucketVersioning operation: The specified bucket does not exist"

s3_bucket:
name: “{{ item.bucket_name }}”
policy: “{{ lookup(‘template’,‘{{ item.policy_name }}’) }}”
with_items: “{{ s3_buckets_attributes }}”
when: item.is_policy_to_attach == ‘Yes’

boto3_version": "1.18.35

In Ansible, Before creating the bucket, It will try to fetch if the same bucket exists or not in Aws(Global namespace). But Seems to be ansible get success message for the bucket exists internal call then Ansible continue to fetch get Bucket versioning call return error that NoSuchBucket.

As per the AWS documentation/KB, S3 buckets are not get deleted immediately. Since S3 is a global entity, Aws takes some time to clean up the entry globally. Ref: https://aws.amazon.com/premiumsupport/knowledge-center/s3-conflicting-conditional-operation/

Would like to understand ansible internal call orders while creating S3 Bucket. Does it try to check if bucket exists call first and then verify getBucket versioning Boto3 call?

Q1: I would need a help in trace the ansible internal API call for above snippet. What is steps or option to collect the detailed api log and its output?

Also i have tried verbosity level to 3 in the log.

Thanks,

Bhoopathy