0

I'm running some unit tests and mocking sqs

from moto import mock_sqs

@pytest.fixture
def moto_boto():
    @mock_sqs
    def boto_resources():
        # setup mocked SQS for output
        sqs_resource = boto3.resource('sqs', region_name=REGION)
        sqs_resource.create_queue(QueueName="my-queue-sqs.fifo", Attributes={"FifoQueue": "true"})
    return boto_resources

@mock_sqs
def test_main(moto_boto):
    moto_boto()
    main()

Within main() there is a call info = ssm_client.get_parameter(Name='info'), which gives an error

An error occurred (UnrecognizedClientException) when calling the GetParameter operation: The security token included in the request is invalid.

Seemingly, mocking AWS SQS overrides the security tokens for all AWS clients and resources (in this case SSM). How can I mock sqs and also access live resources?

Yirmi
  • 332
  • 2
  • 13
  • 1
    There is no officially supported way, to only mock some services and access AWS for other services. This issue has a workaround though, that may be helpful: https://github.com/spulec/moto/issues/3111 – Bert Blommers Nov 07 '22 at 19:29

0 Answers0