Untitled

mail@pastecode.io avatar
unknown
plain_text
21 days ago
672 B
3
Indexable
Never
import boto3

def get_ssm_command_history(limit=100):
    # Initialize a boto3 SSM client
    ssm_client = boto3.client('ssm')

    # Retrieve the last 'limit' command invocations
    response = ssm_client.list_command_invocations(
        MaxResults=limit,
        Details=False
    )

    # Extract the unique SSM document names
    unique_ssm_docs = set(invocation['DocumentName'] for invocation in response['CommandInvocations'])

    return unique_ssm_docs

if __name__ == "__main__":
    # Query and print unique SSM document names
    unique_docs = get_ssm_command_history(100)
    print("Unique SSM Document Names:")
    for doc in unique_docs:
        print(doc)
Leave a Comment