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
I was initially wondering what the difference was between:
a) the secrets availables from the advanced options at creation time of a serverless function
b) secrets created from the Secret Manager menu
Why is it needed?
It was quite difficult to find documentation on calling secrets from a serverless function.
I finally was able to figure out the difference between secret types.
I post my code here. It will probably be useful to someone else
Want to write this documentation yourself?
Yes
Related PR(s)
fromurllibimportrequest, parse, errorimportos, base64, json# Passed as local ENV variableregion=os.getenv('REGION') #Available Regions: fr-par/nl-ams/pl-waw# Passed as local SECRET variableauthtk=os.getenv('SCW_SECRET_KEY') #API keysecret=os.getenv('SECRET_ID') #Secret ID from secret manager# Variable in SECRET Manager url= (
"https://api.scaleway.com/secret-manager/v1beta1/regions/"+region+"/secrets/"+secret+"/versions/latest/access"
)
defhandle(event, context):
req=request.Request(url, method='GET')
req.add_header('X-Auth-Token', authtk)
req.add_header('Content-Type', 'application/json')
try:
res=json.loads(request.urlopen(req).read().decode())
key=base64.b64decode(res['data']).decode('ascii')
excepterror.HTTPErrorase:
res='exception:'+e.read().decode()
key=''return {
"body": {
"message": str(res),
"key": str(key),
},
"statusCode": 200,
}
Hello @Mathr3e, thank you for raising this documentation need! You can go ahead and open a pull request whenever you are ready to start working on the content. You can refer to our contribution guidelines for more information on how to write it.
Feel free to contact us here or on the #documentation channel of our Community Slack if you have any questions.
Hello @Mathr3e, thank you for sharing your code!
The Secrets Manager and Serverless Functions integration is currently under works as it has already been requested by several users. The feature should be live in the next months, and will supersede this documentation.
I would suggest not writing a dedicated documentation and keeping this issue open in the meantime so users can use your code until the feature goes live.
Summary
I was initially wondering what the difference was between:
a) the secrets availables from the advanced options at creation time of a serverless function
b) secrets created from the Secret Manager menu
Why is it needed?
It was quite difficult to find documentation on calling secrets from a serverless function.
I finally was able to figure out the difference between secret types.
I post my code here. It will probably be useful to someone else
Want to write this documentation yourself?
Yes
Related PR(s)
(Optional) Scaleway Organization ID
b7190efa-fa4d-4717-b653-d351d5094caf
Email address
[email protected]
The text was updated successfully, but these errors were encountered: