Setup Google Cloud Functions

Google Cloud Functions provide a streamlined method for running a simple micro-service leveraging custom functions as well as SDKs for any Google service that can be imported into your script. Currently, node.js is the only non-beta language you can build scripts in.

Permissions

Before you setup Google Cloud Functions in your G Suite domain, first provide the account of a developer with the appropriate permissions, identified in the attached screen. 

Enable The SDKs You Need

G Suite has a number of features exposed to their API by importing SDKs into projects. As an example, the Admin SDK provides us with endpoints and classes that make developing micro services to perform actions in the G Suite admin portal easier. In this section we’ll import that SDK, although the tasks for importing other SDKs is similar. 

To get started, open the Google Cloud Platform using the button in the upper left hand corner and click on APIs and Services (the names of these buttons change over time).

TheClick on the Enable APIs and Services button in the dashboard.

Under Credentials, provide the appropriate credentials for the app you’re importing the SDK into.

Search for Admin SDK in the search dialog.

Click Admin SDK, made by Google.

Click Enable.

Once enabled, you’ll need to create a service account for your function to communicate with.

Setup A Service Account

Service accounts give you a JWT, useful to authenticate from a Google Cloud Function back to an instance of the GSuite Admin portal endpoints. To setup a Service account, go to “IAM & admin” using the button in the upper left hand corner. 

Click on Services Accounts.

Provide a project name and a location (if your organization uses locations, otherwise leave that set to No Organization.

Create Your Google Cloud Function

The Google Cloud Function is the microservice that you can then call. This might be sending some json from an app to perform a task from an app, or sending a webhook to the function to perform an action. To get started with functions, click Cloud Function at the bottom of the Google Cloud Platform dashboard.

If functions aren’t enabled, click Enable Billing.

If necessary, click UPGRADE.

The function api will also need to be enabled; if so, click Enable API.

Once all of this is done, you should have a button that says Create function. Click that and then you’ll be able to provide settings for the function.

Settings include the following:

  • Name: How the function is called in the admin panel. 
  • Memory allocated: How much memory the function can consume.
  • Trigger: Most will use HTTP for our purposes.
  • URL: The URL you use to call the function. 
  • Source: The code (typically node.js) that is run.

Note: The package.json allows for us to leverage this function in a multi-tenant fashion. 

Once enabled, you can hit the endpoint. If there’s no header parameters you need to send, that could be as simple as:

curl https://us-central1-alpine-canto-231018.cloudfunctions.net/test-function

Reset Connections To ApplePay and Health With ckksctl

I’ve seen a few issues now where ApplePay and Health stopped working properly on a Mac and iOS device and when you fixed one, it seemed to wreck the connection with the other. Turns out that the information on a local system is managed with the new(ish) ckksctl command. Using ckksctl is pretty straight forward. First, let’s look at what’s on the Mac, using the ckksctl command with the status verb:

/usr/sbin/ckksctl status

There will be a section for ApplePay and another for Health. Here, if the services are configured, you should see the following in that section:

CloudKit account: logged in

Now, let’s force a pull of what’s in iCloud using the fetch verb:

/usr/sbin/ckksctl fetch

A successful sync will simply exit. However, that doesn’t mean that the keys are actually working. So if the issues persist, what we’re going to do is reset what’s in the local system and then pull the information from CloudKit again and show the status:

/usr/sbin/ckksctl reset; /usr/sbin/ckksctl status

Additionally, if you feel the local system is correct and the CloudKit data is incorrect then you could do the opposite and push a fresh config from the client to CloudKit:

/usr/sbin/ckksctl reset-cloudkit; /usr/sbin/ckksctl status

This has resolved issues I’ve seen. The status is also useful to track what a client has been configured to access. Please feel free to comment if you’ve had other experiences as I’ve found practically no information on this command.

Scripting Instances On Google Cloud From A Mac

Over the users I’ve written a good bit about pushing a workload off to a virtual machine sitting in a data center somewhere. The Google CloudPlatform has matured a lot and I haven’t really gotten around to writing about it. So… It’s worth going into their SDK and what it looks like from a shell using some quick examples. For starters, you’ll need an account with Google Cloud Platform, at cloud.google.com and you’ll want to go ahead and login to the interface, which is pretty self-explanatory (although at first you might have to hunt a little for some of the more finely grained features, like zoning virtual instances.

The SDK

The SDK will include the gcloud command, which you’ll use to perform most tasks in the Google CloudPlatform. To install the SDK, go to https://cloud.google.com/sdk/downloads and download the appropriate version for your computer. If you’re on a mac, most likely the x86_64 version. Next, move the downloaded folder to a permanent location and run the install.sh inside it, which will kindly offer to add gcloud to your path. ./install.sh
Welcome to the Google Cloud SDK! To help improve the quality of this product, we collect anonymized usage data and anonymized stacktraces when crashes are encountered; additional information is available at <https://cloud.google.com/sdk/usage-statistics>. You may choose to opt out of this collection now (by choosing ‘N’ at the below prompt), or at any time in the future by running the following command: gcloud config set disable_usage_reporting true Do you want to help improve the Google Cloud SDK (Y/n)?  y Modify profile to update your $PATH and enable shell command completion? Do you want to continue (Y/n)?  y The Google Cloud SDK installer will now prompt you to update an rc file to bring the Google Cloud CLIs into your environment. Enter a path to an rc file to update, or leave blank to use [/Users/charlesedge/.bash_profile]: Backing up [/Users/charlesedge/.bash_profile] to [/Users/charlesedge/.bash_profile.backup]. [/Users/charlesedge/.bash_profile] has been updated. ==> Start a new shell for the changes to take effect. For more information on how to get started, please visit: https://cloud.google.com/sdk/docs/quickstarts
Inside that bin folder, you’ll find the gcloud python script, which once installed, you can then run. Next, you’ll need to run the init, which links it to your CloudPlatform account via oauth. To do so, run gcloud with the init verb, which will step you through the process: gcloud init
Welcome! This command will take you through the configuration of gcloud. Your current configuration has been set to: [default] You can skip diagnostics next time by using the following flag: gcloud init –skip-diagnostics Network diagnostic detects and fixes local network connection issues. Checking network connection…done. Reachability Check passed. Network diagnostic (1/1 checks) passed. You must log in to continue. Would you like to log in (Y/n)? y
If you say yes in the above screen, your browser will then prompt you with a standard Google oauth screen where you’ll need to click Allow. Now go back to Terminal and pick a “Project” (when you set up billing the default was created for you):
Pick cloud project to use: [1] seventh-capsule-138123 [2] Create a new project Please enter numeric choice or text value (must exactly match list item): 1

The Command Line

Next, we’re gonna’ create a VM. There are several tables that lay out machine types. Let’s start by listing any instances we might have: gcloud compute instances list
Listed 0 items.
Note: If you have a lot of these you can use  --regexp to filter them quickly. Then let’s pick a machine type. A description of machine types can be found at https://cloud.google.com/compute/docs/machine-types. And an image. Images can be seen using the compute command with images and then list, as follows: gcloud compute images list Now, let’s use that table from earlier and make a custom machine using an ubuntu uri, a –custom-cpu and a –custom-memory: gcloud compute instances create krypted1 –image https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1610-yakkety-v20170502 –custom-cpu 2 –custom-memory 5 You’ll then see that your VM is up, running, and… has an IP:
Created [https://www.googleapis.com/compute/v1/projects/seventh-capsule-138523/zones/us-central1-a/instances/krypted1]. NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS krypted1 us-central1-a custom (2 vCPU, 5.00 GiB) 10.128.0.2 104.154.169.65 RUNNING
Now let’s SSH in: gcloud compute ssh krypted1 This creates ssh keys, adds you to the hosts and SSH’s you into a machine. So viola. You’re done. Oh wait, you don’t want to leave it running forever. After all, you’re paying by the minute… So let’s list your instances: gcloud compute instances list Then let’s stop the one we just created: gcloud compute instances stop krypted1 And if you’d like, tear it down: gcloud compute instances delete krypted1 Overall, super logical, very easy to use, and lovely command line environment. Fast, highly configurable VMs. Fun times!

HuffPost Article On Cool Things To Do With Google Drive

I’ve been a huge fan of Google Apps for awhile. For this piece, I got a bit more specific and tried to focus on Google Drive. Obviously, there’s a lot of tie-ins with Google’s other products, given how much integration there is there. But, what I did here was really focus on the Google Drive bits. Hope you enjoy it! Screen Shot 2016-05-05 at 1.32.01 PM http://www.huffingtonpost.com/charles-edge/22-cool-things-you-can-do_b_9843122.html

Huffington Post Article: 20 Cool Things You Can Do With Box.com

My latest Huffington Post article, Twenty Cool Things You Can Do with Box is online here. It begins:
If you are looking for a secure and uncomplicated and file sharing service, you will find box.com to be a wonderful way to share files from any device. Today, it is easier than ever for businesses to operate globally regardless of how large or small they are. This is because of the digital age that makes works products easy to share or transfer. Here are twenty cool things that you can do with box.com.
Screen Shot 2016-04-01 at 9.12.58 PM For more, click here.  

10 Cool Things You Might Not Know You Can Do With Dropbox Article On Huffington Post

My latest Huffington Post article is up; this one on 10 Cool Things You Might Not Know You Can Do With Dropbox. A sample of the article:

You lіvе in an аgе whеn you wаnt (and ѕоmеtіmеѕ nееd) tо access іnfоrmаtіоn аt аll tіmеѕ. Thіѕ іnсludеѕ yоur оwn dаtа аnd fіlеѕ — text dосumеntѕ, рhоtоgrарhѕ, vіdеоѕ, music and mоrе. Thаt’ѕ whу ѕеrvісеѕ lіkе Drорbоx is so popular wіth thе соnnесtеd gеnеrаtіоn.

Free оf сhаrgе (wіth a раіd uрgrаdе орtіоn), Dropbox lеtѕ уоu uрlоаd уоur files tо fоldеrѕ ассеѕѕіblе аnуwhеrе thеrе’ѕ аn Intеrnеt connection. It еlіmіnаtеѕ thе hаѕѕlе of еmаіlіng уоurѕеlf attachments аnd runnіng іntо size limits. People can use Dropbox through the desktop арр, mоbіlе аррѕ оr via thе wеb.

Read more at http://www.huffingtonpost.com/charles-edge/10-cl-things-you-didnt-kn_b_9515912.html Screen Shot 2016-03-22 at 1.29.15 PM

6 Ways To Cloud Nirvana Article On IT Business Edge

I have another article up on the world webs. This one is on cloud use in small businesses, with IT Business Edge. Check it out at http://www.itbusinessedge.com/slideshows/6-ways-small-businesses-can-master-the-cloud-in-2016-08.html. Screen Shot 2016-01-20 at 3.24.36 PM

My Predictions For How The Cloud Is Leveraged By Small Businesses In 2016

I published an article with VMblog.com with my (and Bushel’s) predictions for how small businesses will leverage the cloud in 2016.
In today’s increasingly mobile world, more and more small businesses are taking advantage of the cloud, as 72 percent indicate they use mobile apps in their business, with roughly 38 percent reporting they could not survive – or it would be a major challenge to survive- without mobile apps, says a recent survey report. Given this trend, here’s a look at what cloud-connected small and medium-sized businesses can expect in the year ahead:
Read the predictions here… Screen Shot 2015-12-15 at 2.19.53 PM

Swiping Through Spam Like A Boss

Who still says “like a boss?” I guess I did. Get over it. But don’t get over spam. Especially annoying are the ones we know we accidentally signed up for. Because it’s our own darn fault. But luckily, there’s a lot more tools for dealing with bulk mail (solicited or unsolicited) these days. Most modern email clients have the ability to deal with spam. Exchange/Office 365 has clutter and junk. You can build rules on sites. You can use spam assassin on your servers. But, there’s also a nice little app called unroll.me. Once you sign up you’ll have 3 ways of dealing with each message: request removal from a list, mark as rolled up into a single daily digest, or mark as good email. Download it here. The app works a lot like something like Tinder. You swipe right to like something, left to not like something. Facebook should implement this into your timeline! Screen Shot 2015-12-01 at 2.34.08 PM If you decide to mark emails as digests, you’ll get an email once a day that looks like this: Screen Shot 2015-12-01 at 2.20.58 PM This works great for organizations that actually properly remove you from lists (which is surprisingly most). Using this swiping type of workflow, you can knock through 100 or more emails in 10-15 minutes. For organizations that don’t respect unfollow or stop sending me your crap emails, there’s also always just marking them as spam. The only problem with this is that you likely have a phone, a computer, a home computer, and maybe a tablet. No one wants to mark the same email as spam four times and then potentially have emails disappearing and not being able to figure out which computer they were marked as junk on. There are lots and lots of options for this type of thing. But given the ease of use an quick evisceration I can do on my mailbox, I rather like unfollow.me. Give it a shot. You might hate it. I don’t.