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

Question: Is their a serverless plugin hook for google cloud function deploy? #237

Open
nspeet opened this issue Sep 15, 2020 · 1 comment

Comments

@nspeet
Copy link

nspeet commented Sep 15, 2020

AWS has hooks such as this.hooks = {
"aws:deploy:finalize:cleanup": this.afterDeploy.bind(this),
};

Are there similar hooks for GCP cloud function deploys? If not, how can one create a hook for 'after deploy' of a cloud function?

@steinnat
Copy link

steinnat commented Nov 3, 2020

Found this:
@deemetree-at-satelligence said you could use sls hooks using this plugin: https://www.npmjs.com/package/serverless-plugin-scripts


YAML FILE
service: YOUR-SERVICE-NAME

custom:
  ...
 # this comes from https://www.npmjs.com/package/serverless-plugin-scripts
  scripts:
    commands:
      make-public: gcloud functions add-iam-policy-binding ${self:service}-${self:provider.stage}-${opt:function, "YOUR-DEFAULT-FUNCTION-NAME"} --member="allUsers" --role="roles/cloudfunctions.invoker" --project=${self:provider.project} --region=${self:provider.region} | xargs echo 
    hooks:
      'after:deploy:deploy': npx sls make-public --function=YOUR-FUNCTION-NAME
...

This hook automatically makes the specified google functions public after deploy and otherwise you can run sls make-public --function= at any time, hope this helps.

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

No branches or pull requests

2 participants