Search code examples
google-secret-managergoogle-workflows

How can I decode the base64 payload from Google Secret Manager?


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

Solution

  • 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))}