I’m starting to work my way through the IBM Cloud Secrets Manager examples but hitting issues.
- The examples reference
secretsManager
, when the library seems to useSecretsManagerV2
. - It seems the
get_secret
function requires a value for self, but the examples don’t show how to set that correctly. Is there a missing step in the examples, perhaps due to library updates?
What I want to do is obtain a secret from my instance. I have an IAM API key, I know my service URL and have that set.
I have a name for the secret, the Secret group ID, and the ID for the key, so I think I have everything I need, but I cannot work out from the examples how I should write my Python code to pull the secret value.
I followed the examples, but hit issues with library name mismatches, references in the error to needing a self value as well as the id, so I am unsure if I have missed a step, or if the examples are wrong, or if I have the wrong library.
My code is like this:
from ibm_cloud_sdk_core.authenticators.iam_authenticator import IAMAuthenticator
from ibm_secrets_manager_sdk.secrets_manager_v2 import *
from icecream import ic
secrets_manager_service = SecretsManagerV2(authenticator=IAMAuthenticator(
apikey=MY_API_KEY))
secrets_manager_service.set_service_url(
'https://MY_PROJECT_INSTANCE.eu-gb.secrets-manager.appdomain.cloud')
response = SecretsManagerV2.get_secret(
id='ID_OF_SECRET')
But I get an error stating:
TypeError: SecretsManagerV2.get_secret() missing 1 required positional argument: 'self'
I don’t understand why it would need a self reference, unless I have missed a step?
3
Your code is wrong. If you name the instance secrets_manager_service, you have to use that name….
response = secrets_manager_service.get_secret(
id='ID_OF_SECRET')
4