Get the most recent presistent disk snapshot created

Hi all

i am trying to get the most recent snapshot for a persistent disk using an ansible playbook so i need to filter by name and timestamp a list of snapshots

here is my playbook i cannot find the filter for the timestamp and to choose the most recent snapshot created anyhelp

set_fact:
snapshot_name: “pdisksnap*”

this is a filter to get the last snap

  • name: get presistent disks snapshot
    google.cloud.gcp_compute_snapshot_info:
    filters:
  • name = “{{ snapshot_name}}”
    project: “{{ gcp_project }}”
    auth_kind: “{{ gcp_cred_kind }}”
    service_account_file: “{{ gcp_cred_file }}”
    register: snap
  • debug: msg=“{{ snap }}”

@Shahi

You can use below filter from gcloud commands

–filter=“creationTimestamp = $d”

You can set value for $d to get latest snapshot.