Last updated
Last updated
Encrypting cloud resources is a priority for security teams, but it oftentimes goes overlooked. Encryption should be the default for many use cases, and as easy as clicking a button.
In this tutorial, we’ll walk through how you can get started with encrypting common GCP cloud resources at rest. Then we’ll complete a complex encryption use case: encrypting data in transit via https. We’ll do all of this with Resourcely and .
Navigate to and sign up for a free account.
Resourcely generates configuration and enforces policies as part of your CI. While you can use Resourcely standalone, to make the most out of it you will want to integrate it with your version control, CI, and Terraform runner.
To set up your environment, follow the .
Encryption on GCP hinges on crypto keys: tools that can be used to encrypt and decrypt cloud resources. Keys are managed with , which allows users to easily create and manage keys with features like automatic rotation, permissions, grouping, and more.
Here's a simple example of creating a crypto key with Terraform:
While this example is straightforward, there are drawbacks. A developer may...
not know what any of these parameters mean
may enter values that are dangerous or incorrect
omit values that are important to their organization
We can turn this into a Resourcely Blueprint by adding tags. This will create a guided UI a developer can use to confidently deploy infrastructure. Here is a Resourcely Blueprint for a crypto key, and the associated UI that is generated:
This Blueprint has two primary sections: Frontmatter (where variables are defined and augmented with guidance), and the primary resources section (Terraform, but with variables added to it).
Now that we have given users the ability to create crypto keys, let's make it easy for them to use keys and encrypt their services.
In Terraform, you might use code that looks like this to encrypt your resources:
This leaves too many surface areas for encryption failure:
Choosing the wrong alogrithm
Improper naming
Too long of a rotation period
Using the wrong crypto key ID
In our Blueprint code, notice our frontmatter tags:
Description
Default
Suggest
Required
Group
These tags embed context into our form that helps users avoid issues and choose the right configuration.
Let's now create Blueprints for our cloud resources that we want to encrypt:
With Google Compute Instances, you would normally link to a crypto key by referencing its ID:
What if you want to give users a simple list to choose from of possible crypto keys, with some guidance for what to pick? You can do this with the links_to
tag!
Start out by creating this Google Compute Instance Blueprint in Resourcely Foundry:
Notice the links_to
tag usage:
This manifests itself in the Blueprint UI with a dropdown box. Publish the Blueprint you just pasted, and create a PR in Resourcely with your crypto key Blueprint and this Compute Instance Blueprints.
When you do so, observe the disk encryption key field. It lists crypto keys that are being created by the user, or any existing crypto keys that you want to make available:
Using links_to
makes it simple for developers to link resources, making encryption easy to achieve: no looking up ARNs or IDs.
Navigate to Foundry and click "Author a Guardrail". We'll start with a simple Guardrail that makes sure we have a crypto key on our Cloud SQL databases.
Paste the above example into the Foundry IDE and publish it. Then, create a Blueprint in Foundry with for a Cloud SQL database that allows for a crypto key to be attached:
Notice that our Guardrail manifests itself on the Cloud SQL Blueprint form (see the Developer Experience tab):
If the field is left empty, this Guardrail will be triggered. The user must unlock the Guardrail with the Proceed button, acknowledging they aren't attaching a crypto key. In this case, the resulting PR will be blocked until the appropriate team can review it.
Guardrails are a great way to require or limit configuration settings that your team cares about (like encryption) without blocking the developers following your guidance.
Suppose that you want to make it easy for developers to set up https
support for their applications. Creating a certificate and connecting it to a backend service is not a straightforward exercise. There are many tricky parameters:
Host rules and path matching
Certificate setup and lifecycle rules
URL mapping and connecting to the backend service
Resourcely's QoL features for Blueprints are a perfect candidate for streamlining encryption in transit:
Easy, automated linking means that users never have to make their own references
Default values mean developers don't have to bother with fields they shouldn't need to know about
i.e. paths = ["/*"]
Markdown-based description make for robust instructions that keep developers on track
To implement encryption in transit using Resourcely, simply use the following Blueprint:
Paste it into Foundry, publish, and explore the UI.
See the desc
tags in frontmatter, and note how links can be included - giving users the ability to explore documentation if they want.
Adding suggestions and defaults helps users know what they should pick, especially if they aren't familiar
Publish your Blueprint and use it as-is to facilitate encrypted in transit web traffic for your applications!
We have pre-built encryption Blueprints and Guardrails available for:
Crypto keys and key rings
Compute Instances
Blob Storage
Pub/Sub Topics
Cloud SQL
BigQuery
Cloud Functions
Navigate to in Resourcely, paste the above code, and navigate to the Developer Experience tab to see the form that is created.
Now that you've created paved roads for creating encrypted resources by default, let's build some more restrictions into our input fields and some checks when CI runs. We'll do this with Resourcely .
Note the host_names
variables and see how they allow for multiple domains to be included in the UI. Resourcely automatically detects the hosts
parameter in Terraform and adjusts accordingly.
Encryption doesn't need to be an optional nice-to-have. You can make it easy to add encryption to your resources with , and enforce encryption with .
You can find them in our of use case examples! Simply copy the code into Foundry, and publish to get started.
Make encrypted storage the default for all your GCP services