Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Secret Manager #35

Closed
flopshot opened this issue Dec 31, 2020 · 4 comments
Closed

Add Support for Secret Manager #35

flopshot opened this issue Dec 31, 2020 · 4 comments

Comments

@flopshot
Copy link

Motivation

For Serverless products like Cloud Run, one should not be injecting secrets into your backend service via Environment Variables. Thus, one should use Google Cloud's Secret Manager to query for sensitive information like Database Passwords. It seems that there would be a great advantage to have the logic to retrieve secrets in GoogleCloudKit

Implementation

Much of the work for authentication can be re-used from GoogleCloudCore. A request would only need the OAuth token, provided by OAuthRefreshable. From the Secret Manager api docs, a request would be simple enough to implement with the token

Create a Secret

curl "https://secretmanager.googleapis.com/v1/projects/project-id/secrets?secretId=my-secret" \
    --request "POST" \
    --header "authorization: Bearer $(gcloud auth print-access-token)" \
    --header "content-type: application/json" \
    --header "x-goog-user-project: project-id" \
    --data "{\"replication\": {\"automatic\": {}}}"

Retrieve a Secret

curl "https://secretmanager.googleapis.com/v1/projects/project-id/secrets/my-secret/versions/1:access" \
    --request "GET" \
    --header "authorization: Bearer $(gcloud auth print-access-token)" \
    --header "content-type: application/json" \
    --header "x-goog-user-project: project-id"
@flopshot
Copy link
Author

If it's alright with the community, I'd like to contribute this feature to GoogleCloudKit.

@owainhunt
Copy link

👋 #33 already covers getting a secret version, but doesn’t implement creating a secret or secret version.

@flopshot
Copy link
Author

flopshot commented Jan 2, 2021

👋 #33 already covers getting a secret version, but doesn’t implement creating a secret or secret version.

Perfect timing. That's all I needed for my use case, accessing secrets in secret manager. Thanks for your contribution. I'll try out the fork next week.

@Andrewangeta
Copy link
Member

Released and tagged in RC 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants