You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since bedrock-runtime is not yet supported by moto, I want to patch it myself.
I cannot get rid of mock_aws all together because there is a section that uses dynamodb in the same function.
When I try using passthrough option so that moto does not intercept the request, the passthrough does not work.
I see that, in moto.backend_index.backend_url_patterns, regex string for bedrock-runtime is missing.
Is there any work arounds I can take?
Or should I just downgrade to v4.
code to reproduce the issue
importboto3importbotocorefromunittest.mockimportpatchfrompytestimportfixturefrommotoimportmock_aws@fixture(autouse=True)defmock_envs(mocker: MockerFixture):
mocker.patch.dict(os.environ, {
"AWS_ACCESS_KEY_ID": "dummy_do_not_change",
"AWS_SECRET_ACCESS_KEY": "dummy_do_not_change",
"AWS_SECURITY_TOKEN": "dummy_do_not_change",
"AWS_SESSION_TOKEN": "dummy_do_not_change",
"AWS_DEFAULT_REGION": "us-west-2",
}, clear=True)
@fixture(autouse=True)defaws(mock_envs):
withmock_aws(config={
"core": {
"passthrough": {
"services": ["bedrock-runtime"],
},
},
}):
yield# Original botocore _make_api_call functionorig=botocore.client.BaseClient._make_api_call# Mocked botocore _make_api_call functiondefmock_make_api_call(self, operation_name, kwarg):
# For example for the Access Analyzer service# As you can see the operation_name has the list_analyzers snake_case form but# we are using the ListAnalyzers form.# Rationale -> https://github.com/boto/botocore/blob/develop/botocore/client.py#L810:L816ifoperation_name=='InvokeModel':
return {} # I have actual response mock here.# If we don't want to patch the API callreturnorig(self, operation_name, kwarg)
deftest_ok():
client=boto3.client("bedrock-runtime")
withpatch('botocore.client.BaseClient._make_api_call', new=mock_make_api_call):
response=client.invoke_model(...)
# I get `botocore.exceptions.ClientError: An error occurred (404) when calling the InvokeModel operation: Not yet implemented`
The text was updated successfully, but these errors were encountered:
Hi @acro-s-yoshioka! The services-argument only works for services that Moto knows about. If it's an unknown service, like bedrock-agent, Moto doesn't know what URL to intercept, so you would indeed have to specify it explicitly.
problem
I cannot passthrough requests to bedrock-runtime.
Since bedrock-runtime is not yet supported by moto, I want to patch it myself.
I cannot get rid of mock_aws all together because there is a section that uses dynamodb in the same function.
When I try using
passthrough
option so that moto does not intercept the request, the passthrough does not work.I see that, in moto.backend_index.backend_url_patterns, regex string for bedrock-runtime is missing.
Is there any work arounds I can take?
Or should I just downgrade to v4.
code to reproduce the issue
The text was updated successfully, but these errors were encountered: