[Python] boto3 resource connection fail

Discussão em 'Python' iniciado por Stack, Março 7, 2025.

  1. Stack

    Stack Membro Participativo

    I haven't found any mention anywhere of a similar problem, but I am having difficulty connecting to an AWS SQS queue when using the boto3 library. When I connect to a boto3 resource in a program (polling application), it exits unexpectedly without any reported error. However, when I access the same queue in an interactive Python console, it works perfectly every time. In the following code, the first message "Made it to the queue data" is logged, and also the printout of the actual boto3.resource() call with the parameters printed. When I copy and paste this into iPython, it executes just fine. In the script though, it fails, and the final line/message is not logged.

    Any insight would be appreciated.

    logging.info("Made it to get_queue_data")
    logging.info(f"""
    client = boto3.resource('sqs',
    region_name='{AWS_REGION}',
    aws_access_key_id='{AWS_KEY}',
    aws_secret_access_key='{AWS_SECRET}')
    """)
    # This line leads the program to exit without a reported error.
    client = boto3.resource('sqs',
    region_name=AWS_REGION,
    aws_access_key_id=AWS_KEY,
    aws_secret_access_key=AWS_SECRET)
    logging.info("Created SQS client.")

    Continue reading...

Compartilhe esta Página