0

When using secret manager, the response is base64 encoded. How would one go about decoding it?

sendGridSend: 
   steps:    
   - getSecret:    
       call: http.get    
       args:    
           url: ${"https://secretmanager.googleapis.com/v1/projects/" + sys.get_env("GOOGLE_CLOUD_PROJECT_NUMBER") + "/secrets/" + secret + "/versions/latest:access"}    
           auth:    
               type: OAuth2    
       result: secretBase64Payload
Pentium10
  • 204,586
  • 122
  • 423
  • 502
Ed Kong
  • 59
  • 3
  • @Samuel Liew the question was OK, it should be left open. – Pentium10 Nov 16 '20 at 08:38
  • 2
    @Pentium10 No, I don't think so. Feel free to post a dispute on [meta] or discuss it in [SOCVR](http://chat.stackoverflow.com/rooms/41570/so-close-vote-reviewers) – Samuel Liew Nov 16 '20 at 09:25

1 Answers1

2

It would be like the below snippet, by using base64.decode. As this product just got out of alpha, there is no yet a documentation page linking to the available functions.

sendGridSend: 
   params: [secret, from, to, subject, content, contentType]    
   steps:    
   - getSecret:    
       call: http.get    
       args:    
           url: ${"https://secretmanager.googleapis.com/v1/projects/" + sys.get_env("GOOGLE_CLOUD_PROJECT_NUMBER") + "/secrets/" + secret + "/versions/latest:access"}    
           auth:    
               type: OAuth2    
       result: sendGridKey    
   - decodeSecrets:    
       assign:    
       - decodedKey: ${text.decode(base64.decode(sendGridKey.body.payload.data))}
Pentium10
  • 204,586
  • 122
  • 423
  • 502