Use conditional formatting with resource metadata in Lucidscale

Written by:  Shanna S
Last updated:  

Using conditional formatting in a Lucidscale document to highlight and organize specified resources with stylistic elements and icons based on the underlying resource metadata. 

Note: The features described in this article are accompanied with screenshots and examples of an AWS architecture diagram, but are accessible to all provider generated documents (AWS, Azure, Google Cloud).

Watch: Filters and conditional formatting

Create rules using conditional formatting

Create a new rule

To create the first rule, open the conditional formatting menu by clicking on the wand icon at the top of the workspace and then click Create Rule.

how

After you create the first rule, you can add additional rules by clicking + Create a new formatting rule at the top of the Conditional Formatting menu.

Name a rule

When you create a rule, it is helpful to start by giving the rule a name so that you remember what the rule refers to. For example, if you create a rule to identify which RDS DB Instances rendered in a document do not have encrypted data, then you might call the rule “RDS: StorageEncrypted”. You can double-click the title at the top to edit the rule name at any time.

name

1. For – Select the resource type to apply the rule to

You can apply conditional formatting rules to specific resource types in a document or apply rules to all non-container resource types. Selecting a resource (e.g. “RDS DB Instances”) listed in the drop-down menu under For applies the rule to all resources of that class rendered in the document.

For

2. If – Create conditions

To create an “If” condition, start by choosing between two categories of metadata: Resource Data or Tags. Each category renders a list of different metadata fields that were imported with resources. Whichever metadata field you choose to select under the “If'' drop-down menu after selecting a category is the field you want Lucidscale to check the condition on.

If

Render resource data

After choosing which resource to apply the rule to in step 1, select Resource Data and click the drop-down menu under “If” to render a list of all the metadata fields imported with that resource. These fields are also shown in the "Configuration" tab of the Data panel to the right of the workspace when  rendered resource is selected.

Render tags

After choosing a resource to apply a rule to in step 1, select Tags and click the drop-down menu under “If” to render a list of Tags that you defined for that resource through your cloud provider. These values are also shown as both a Tag array in the "Configuration" tab of the Data panel to the right of the workspace and are also listed in the “Curated Data” tab under “Tags”. 

Note: The values that exist within the set of “Tag” values are defined in your cloud provider’s console.

Once you have selected a metadata field, you can choose a condition from a list of 14 options:

conditional

Then you can specify the value you want the rule to look for. Continuing with our example, if you create a rule to identify which RDS DB Instances rendered in a document do not have encrypted data, then you would have selected “RDS DB Instances” as the resource for the rule and “StorageEncrypted” as the metadata field which the rule references.

You could then choose a condition such as “Does not contain” then populate “true” as the value. This highlights all RDS DB Instances in a document which do not have the value “true” in their “StorageEncrypted” metadata field.

conditional

3. Then – Select formatting

In the “Then” section, you can select from three formatting options: 

Apply shape style

If you select shape style as the formatting, you can choose from the following options: shape fill color, border color, border style, and border width. The styling options you specify are applied to all resources that meet the rule’s condition(s).

conditional

Add icons

If you select icons as the formatting option, you can choose the “Type” of icon (icons from Lucidscale’s library, a custom icon upload, or a text badge), adjust the style, add hover text (optional), and specify where the icon appears on the resource with the “Position” selection.

In this example, we have chosen to use Lucidscale’s icon library, selected an "X" icon, and have opted to render it in the upper right-hand corner of the resource if it meets the conditions of the rule.

conditional

Use dynamic shapes

If you select dynamic shapes, you can choose the shape style, the color that fills the shape, the color of the background of the shape, and then specify the parameters for the value of the shape.

For example, to show a progress bar that shows percent completion on a task from 0 to 100 percent, you could choose a custom number as the value source, and type in 0 and 100 as the minimum and maximum values (see the example below).

You could also use shape data or formulas to specify the minimum and maximum values (although this is less common for most use cases).

Finally, in the “Value” section, select the value that you want the shape to reflect. For example, if the value field contained the number 70, the progress bars will all show 70 percent completion. Instead of choosing “Custom number” as the value source, it is generally more helpful to use shape data or a formula to specify this number so that it is unique to each shape.

You can also add hover text that appears when anyone hovers their cursor over an icon.

conditional

 

Access advanced rule options

advanced

Toggling the “Advanced Rule Options” switch at the bottom of the conditional formatting editor renders additional customization options for a rule: “Formula”, “Or/And” conditions, “Apply to all views”, and “Else/Else If” conditions.

conditional

Apply a formula

Use Lucid's formula syntax to write your own conditional check. If you select the “Formula” option for an “If” condition, a field will appear where you can type in the formula.

conditional

Learn more: For more detailed documentation on using formulas in conditional formatting rules, please review the following resource: Lucid Formulas.

Apply to all views

Enabling “Apply to all views” under “3.Then” applies the conditional formatting rule to all views you’ve previously created and any new views you create. 

how

Add an “Or” or “And” condition

Select + Add condition. Adding an “Or” condition allows you to specify a second condition that, if true, triggers the same formatting as an “If” condition. “And” and “Or” conditions have the same fields and the same layout as “If” conditions when “Advanced Rule Options” is enabled.

An “And” condition allows you to specify that BOTH the “If” and the “And” conditions must be met before the formatting is applied. 

conditional

Add an “Else” or an “Else If” condition

Add an “Else” or an “Else If” condition if you want to apply formatting to the shapes in a selection that do NOT meet the conditions that you specified above. You can set “Else” and “Else If” conditions the same way that you set the “If” conditions.

conditional

Save a rule

Click Save at the bottom of the rule editor to save a rule. Once you save a rule, it is automatically applied to all rendered shapes of the resource class you selected in 1.For.

Manage conditional formatting rules

Once a rule has been created and saved, it is listed in the Conditional Formatting menu. This list appears whenever you click on the wand icon and are not editing a specific rule. From the list of rules, you can rename, edit, duplicate, or delete rules by clicking on the three-dot menu in the upper-right of a rule and selecting from the options. You can also un-apply the rule by unchecking the box next to the rule name.

conditional

By default, rules you create are only be applied to the view that you created them in. Rules can also be set as “Global” rules that are applied to all existing views and new views that you create. 

Example formulas for conditional formatting rules

AWS

Example 1: Public IP address in a private subnet

  • If you have an upcoming cloud audit, you may want to highlight EC2 instances that have a Public Ip Address in a Private Subnet. 
  • After selecting EC2 Instances in 1.For, you can use the following formula in 2.If to identify these resources: 
    AND(not(container.MapPublicIpOnLaunch), @PublicIpAddress)
  • You can also display custom hover text in 3.Then that renders the exact IP Address of a highlighted resource you’re hovering over: 
    IP Address {{=@PublicIpAddress}} is public, in a private subnet   

Example 2: Stopped EC2 instances

  • You may want to highlight “stopped” EC2 instances in your account. 
  • After selecting “EC2 Instances” in 1.For, you can use the following formula in 2.If to identify EC2 instances that aren’t running: 
    (@'State'.'Name' = 'stopped') 

Example 3: Default VPC

After selecting VPCs in 1.For, you can use the following formula in 2.If to identify the default VPC:
AND(@IsDefault, contains(@'$Name', 'VPC'))

Azure

Example: Encrypted storage account

  • You may want to highlight all encrypted storage accounts in your subscription. 

After selecting “Storage Accounts” in 1.For, you can use the following formula in 2.If to identify encrypted storage accounts in the subscription: 
=@"encryption".services.blob.enabled

Google Cloud (formerly GCP)

Example: Owner BigQuery dataset

  • You may want to identify the owner of a BigQuery Dataset. 
  • After selecting “BigQuery Datasets” in 1.For, you can use the following formula in 2.If to identify BigQuery Datasets which have a value in the “userByEmail” metadata field which is associated with the owner:
    =ISNOTEMPTY(this.access.userByEmail)   
  • You can then display custom hover text in 3.Then that renders the value populated in the “userByEmail” metadata field, which is typically the owner’s email address: 
    =this.access.userByEmail

Give feedback on this article

Have feedback about this article? Tell us about your experience here

Did you find what you were looking for?

Still have a question or want to share what you have learned? Visit our Community   to get help and collaborate with others.