SlideShare a Scribd company logo
1 of 30
Copyright © 2020 HashiCorp
Using New Sentinel Features in
Terraform Cloud and Terraform
Enterprise
Roger Berlind
Technology Specialist
HashiCorp
Copyright © 2020 HashiCorp
▪ Sentinel in Terraform Cloud (TFC) and Terraform Enterprise (TFE)
▪ Two New Sentinel Features
– Sentinel Modules
– Terraform Sentinel v2 Imports
▪ The Evolution of Sentinel Policies
▪ Some Prototypical Third-Generation Sentinel Policies
▪ The Third-Generation Common Functions
▪ Testing and Using the Third Generation Sentinel Policies
▪ A Demo
Agenda
Copyright © 2020 HashiCorp
Sentinel in Terraform Cloud and
Terraform Enterprise
Copyright © 2020 HashiCorp
▪ HashiCorp's Sentinel is a framework for implementing governance
policies as code in the same way that Terraform implements
infrastructure as code.
▪ It includes its own language and is embedded in HashiCorp's
enterprise products.
▪ Using Sentinel ensures that your governance policies are actually
being checked rather than just being listed in a spreadsheet.
▪ It supports fine-grained policies that use conditional logic.
▪ It includes a CLI that allows you to test and run policies.
What is Sentinel?
Copyright © 2020 HashiCorp
Terraform Cloud and Terraform Enterprise
▪ A User Interface
▪ Workspace Management
▪ Team Management
▪ State Management
▪ Secure Variable Management
▪ Remote Runs and State
▪ VCS Integrations
▪ HTTP/JSON API
▪ Private Module Registry
▪ Configuration Editor
▪ Sentinel (policy as code)
▪ SSO via SAML Integration
▪ Audit Logging
Terraform Cloud (TFC) includes the following advanced functionality that
makes it easier for teams and organizations to use Terraform:
Customers can install Terraform Enterprise (TFE) servers to self-host
TFC in their own virtual private networks or in their data centers.
Copyright © 2020 HashiCorp
▪ Sentinel policies are checked between the standard plan and apply
steps of Terraform runs.
▪ Policies have different enforcement levels: advisory, soft-mandatory, and
hard-mandatory.
▪ Violations prevent runs from being applied unless a user with sufficient
authority overrides them.
▪ Sentinel policies can evaluate the attributes (arguments and exported
attributes) of existing and new resources and data sources based on
information from the current run:
– the plan, the configuration, the current state, and other run data
including cost estimates
▪ This ensures that resources comply with all policies before they are
provisioned.
Where is Sentinel Used in Terraform?
Copyright © 2020 HashiCorp
How Terraform Works Without Sentinel
VCS Terraform Infrastructureplan & apply
Copyright © 2020 HashiCorp
How Terraform Works With Sentinel
VCS Terraform
Cloud
Workspace
Infrastructureplan Sentinel
Policy
Checks
apply
If cost estimates are enabled, they run right after the plan.
Copyright © 2020 HashiCorp
All Policy Checks Passed
Copyright © 2020 HashiCorp
▪ HashiCorp customers are using Sentinel to implement governance
policies like the following in Terraform Cloud/Enterprise:
– Enforce security standards:
▪ Require all S3 buckets use the private ACL and be encrypted by KMS.
▪ Restrict which roles the AWS provider can assume.
▪ Blacklist/whitelist resources, data sources, providers, or provisioners.
– Avoid excessive costs:
▪ Limit the sizes of VMs and Kubernetes clusters in public clouds.
▪ Limit the monthly spend of each Terraform workspace.
– Enforce mandatory tags on resources provisioned by Terraform.
– Mandate that all modules come from a Private Module Registry.
– Enforce specific Terraform coding conventions.
How Customers are Using Sentinel in Terraform
Copyright © 2020 HashiCorp
Two New Sentinel
Features
Copyright © 2020 HashiCorp
▪ A Sentinel Module defines Sentinel functions and rules in a file that can
be used by Sentinel policies with a single import statement.
▪ This avoids the need to paste the functions into every policy that calls
them, improving the reusability of Sentinel functions.
▪ Sentinel modules are registered in Sentinel CLI configuration files and in
TFC/TFE policy set configuration files.
▪ The terraform-guides repository includes 5 "third-generation" modules:
– tfplan-functions, tfstate-functions, tfconfig-functions, tfrun-functions,
and aws-functions
▪ Each function is documented in a separate MD file.
▪ Note that these are NOT standard functions.
Sentinel Modules
Copyright © 2020 HashiCorp
▪ The new v2 versions of three Terraform Sentinel imports (tfplan,
tfstate, and tfconfig) are aligned more closely with native
Terraform 0.12 data structures.
▪ This makes the v2 imports easier to use than the v1 imports.
▪ Additionally, since resource instances are stored in a single flat
map that spans across all Terraform modules and resource types, it
is much easier to find all resources instances of a specific type or a
sub-collection of them.
▪ However, there is a catch:
– The v2 imports can only be used with Terraform 0.12.
New v2 Versions of the Terraform Sentinel Imports
Copyright © 2020 HashiCorp
▪ The tfplan/v2 gives data generated from Terraform plans.
– https://www.terraform.io/docs/cloud/sentinel/import/tfplan-v2.html
▪ The tfconfig/v2 import gives data about the Terraform configuration.
– https://www.terraform.io/docs/cloud/sentinel/import/tfconfig-v2.html
▪ The tfstate/v2 import gives data about the current state of a
workspace.
– https://www.terraform.io/docs/cloud/sentinel/import/tfstate-v2.html
▪ The tfrun import provides metadata for Terraform runs and their
workspaces as well as cost estimate data. (There is no v2 version of it.)
– https://www.terraform.io/docs/cloud/sentinel/import/tfrun.html
Sentinel Imports in Terraform
Copyright © 2020 HashiCorp
The Evolution of Sentinel Policies
Copyright © 2020 HashiCorp
▪ The first-generation policies were written in late 2018 and used the
original Terraform Sentinel v1 imports.
▪ They had several short-comings, including the following:
– Most of the policies did not print violation messages for resources
that violated them.
– They stopped evaluating conditions as soon as a single resource
instance violated them.
– They failed when resources that were being destroyed violated
conditions.
– Their use of default Sentinel output was overly verbose.
The First-Generation Policies
Copyright © 2020 HashiCorp
▪ The second-generation policies were written in 2019 and used the original
Terraform Sentinel v1 imports:
▪ They made the following improvements:
– They offloaded most processing from rules into some common
parameterized functions.
– Those common functions were written in a way that caused all violations
of all rules to be reported.
– They printed out the full address of each resource instance that did
violate a policy.
– By using a single main rule, they suppressed most of Sentinel’s default,
overly verbose output.
– They skipped resources that were being destroyed but not recreated.
The Second-Generation Policies
Copyright © 2020 HashiCorp
▪ The new third-generation policies were written in the spring of 2020 and
use the new Terraform Sentinel v2 imports and Sentinel modules.
▪ They have the following advantages:
– Their use of the v2 imports and the Sentinel filter expression makes it
easier to restrict policies to specific operations performed by Terraform.
– The common functions defined in Sentinel modules do not need to be
pasted into policies that use them.
– Most of the policies do not have any for loops of if/else conditionals. This
makes the policies easier to understand and copy.
– They can evaluate the value of any attribute of any resource or data
source, even those that are deeply nested.
▪ However, since they do use the v2 imports, they can only be used with
Terraform 0.12
The New Third-Generation Policies
Copyright © 2020 HashiCorp
Some Prototypical Third-
Generation Sentinel Policies
Copyright © 2020 HashiCorp
▪ I'll review four prototypical third-generation Sentinel policies in
order of increasing sophistication:
– restrict-ec2-instance-type.sentinel (AWS)
– restrict-vm-cpu-and-memory.sentinel (VMware)
– restrict-vm-disk-size.sentinel (VMware)
– restrict-publishers-of-current-vms.sentinel (Azure)
Some Prototypical Third-Generation Policies
Copyright © 2020 HashiCorp
The Third-Generation Common
Functions
Copyright © 2020 HashiCorp
▪ As mentioned earlier, there are third-generation Sentinel modules
with common functions for each of the Terraform Sentinel imports.
▪ The tfplan and tfstate modules have the following functions:
– Find functions that find resources, data sources, and blocks.
– Filter functions that filter collections of resources, data sources, or
blocks. These each return two maps: resources and messages.
– The evaluate_attribute function that can evaluate any attribute
of any resource, data source, or block, even if deeply nested.
– The to_string and print_violation functions that are used by the
other functions.
▪ There is also a Sentinel module with some AWS-specific functions.
The Third-Generation Common Functions
Copyright © 2020 HashiCorp
Testing and Using the Third-
Generation Sentinel Policies
Copyright © 2020 HashiCorp
▪ All the third-generation Sentinel policies have test cases and mocks
that support testing the policies with the Sentinel CLI
▪ Do the following:
– Download the Sentinel CLI from the Sentinel Downloads page.
– Unzip the zip file and place the sentinel binary in your path.
– Fork the terraform-guides repository and clone your fork to your
local machine.
– Navigate to any of the cloud directories (aws, azure, gcp, or
vmware) or to the cloud-agnostic directory.
– Run sentinel test to test all policies for that cloud.
– Run sentinel test -run=<partial_policy_name> -verbose to
test individual policies, using a string that partially matches name.
Testing Policies with the Sentinel CLI
Copyright © 2020 HashiCorp
{
"modules": {
"tfplan-functions": {
"path": "../../../common-functions/tfplan-functions/
tfplan-functions.sentinel"
}
},
"mock": {
"tfplan/v2": "mock-tfplan-pass.sentinel"
},
"test": {
"main": true
}
}
An Example Test Case that References a Module
Copyright © 2020 HashiCorp
▪ After successfully testing a policy with the CLI and possibly also on
TFC itself, you will want to deploy it to your TFC/TFE organizations.
▪ If you have not already added the policy to a policy set in your
organizations, do that at this time.
▪ Add the new policy to an existing policy set that is already applied
against desired workspaces, or create a new policy set for the
policy and apply that policy set to desired workspaces across your
organizations.
▪ Also add any parameters the policy requires to your policy set.
▪ And add references to any Sentinel Modules that policies in it use.
Deploying Policies in TFC or TFE
Copyright © 2020 HashiCorp
▪ Here is an example policy set:
module "tfplan-functions" {
source = "../common-functions/tfplan-functions/tfplan
-functions.sentinel"
}
policy "restrict-ec2-instance-type" {
source = "./restrict-ec2-instance-type.sentinel"
enforcement_level = "soft-mandatory"
}
Example Policy Set
Copyright © 2020 HashiCorp
Demo
Copyright © 2020 HashiCorp
▪ Here are some useful Links
▪ Documentation
– https://www.terraform.io/docs/cloud/sentinel/index.html
– https://www.terraform.io/docs/cloud/sentinel/manage-
policies.html
– https://docs.hashicorp.com/sentinel
▪ Other Resources:
– Blog for this webinar
– Sentinel in Terraform v2 Workshop (including hands-on Instruqt
track that teaches you how to write and test policies)
Some Useful Links
Thank you.
hello@hashicorp.comwww.hashicorp.com

More Related Content

What's hot

Kubernetes on AWS with Amazon EKS
Kubernetes on AWS with Amazon EKSKubernetes on AWS with Amazon EKS
Kubernetes on AWS with Amazon EKSAmazon Web Services
 
DRUPAL CI/CD FROM DEV TO PROD WITH GITLAB, KUBERNETES AND HELM
DRUPAL CI/CD FROM DEV TO PROD WITH GITLAB, KUBERNETES AND HELMDRUPAL CI/CD FROM DEV TO PROD WITH GITLAB, KUBERNETES AND HELM
DRUPAL CI/CD FROM DEV TO PROD WITH GITLAB, KUBERNETES AND HELMDrupalCamp Kyiv
 
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方OpenStack超入門シリーズ いまさら聞けないSwiftの使い方
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方Toru Makabe
 
Creating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformCreating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformKnoldus Inc.
 
ZabbixのAPIを使って運用を楽しくする話
ZabbixのAPIを使って運用を楽しくする話ZabbixのAPIを使って運用を楽しくする話
ZabbixのAPIを使って運用を楽しくする話Masahito Zembutsu
 
Bastion jump hosts with Teleport
Bastion jump hosts with TeleportBastion jump hosts with Teleport
Bastion jump hosts with TeleportFaelix Ltd
 
Getting Started with Infrastructure as Code
Getting Started with Infrastructure as CodeGetting Started with Infrastructure as Code
Getting Started with Infrastructure as CodeWinWire Technologies Inc
 
Terraform: Infrastructure as Code
Terraform: Infrastructure as CodeTerraform: Infrastructure as Code
Terraform: Infrastructure as CodePradeep Bhadani
 
Room 1 - 4 - Phạm Tường Chiến & Trần Văn Thắng - Deliver managed Kubernetes C...
Room 1 - 4 - Phạm Tường Chiến & Trần Văn Thắng - Deliver managed Kubernetes C...Room 1 - 4 - Phạm Tường Chiến & Trần Văn Thắng - Deliver managed Kubernetes C...
Room 1 - 4 - Phạm Tường Chiến & Trần Văn Thắng - Deliver managed Kubernetes C...Vietnam Open Infrastructure User Group
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesGabriel Carro
 
Building infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps KrakowBuilding infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps KrakowAnton Babenko
 

What's hot (20)

Amazon EKS Deep Dive
Amazon EKS Deep DiveAmazon EKS Deep Dive
Amazon EKS Deep Dive
 
Quarkus入門
Quarkus入門Quarkus入門
Quarkus入門
 
Kubernetes on AWS with Amazon EKS
Kubernetes on AWS with Amazon EKSKubernetes on AWS with Amazon EKS
Kubernetes on AWS with Amazon EKS
 
Terraform on Azure
Terraform on AzureTerraform on Azure
Terraform on Azure
 
Terraform
TerraformTerraform
Terraform
 
Terraform
TerraformTerraform
Terraform
 
DRUPAL CI/CD FROM DEV TO PROD WITH GITLAB, KUBERNETES AND HELM
DRUPAL CI/CD FROM DEV TO PROD WITH GITLAB, KUBERNETES AND HELMDRUPAL CI/CD FROM DEV TO PROD WITH GITLAB, KUBERNETES AND HELM
DRUPAL CI/CD FROM DEV TO PROD WITH GITLAB, KUBERNETES AND HELM
 
(ARC307) Infrastructure as Code
(ARC307) Infrastructure as Code(ARC307) Infrastructure as Code
(ARC307) Infrastructure as Code
 
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方OpenStack超入門シリーズ いまさら聞けないSwiftの使い方
OpenStack超入門シリーズ いまさら聞けないSwiftの使い方
 
DevOps: Infrastructure as Code
DevOps: Infrastructure as CodeDevOps: Infrastructure as Code
DevOps: Infrastructure as Code
 
Creating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformCreating AWS infrastructure using Terraform
Creating AWS infrastructure using Terraform
 
ZabbixのAPIを使って運用を楽しくする話
ZabbixのAPIを使って運用を楽しくする話ZabbixのAPIを使って運用を楽しくする話
ZabbixのAPIを使って運用を楽しくする話
 
Bastion jump hosts with Teleport
Bastion jump hosts with TeleportBastion jump hosts with Teleport
Bastion jump hosts with Teleport
 
Terraform
TerraformTerraform
Terraform
 
Getting Started with Infrastructure as Code
Getting Started with Infrastructure as CodeGetting Started with Infrastructure as Code
Getting Started with Infrastructure as Code
 
Terraform: Infrastructure as Code
Terraform: Infrastructure as CodeTerraform: Infrastructure as Code
Terraform: Infrastructure as Code
 
Room 1 - 4 - Phạm Tường Chiến & Trần Văn Thắng - Deliver managed Kubernetes C...
Room 1 - 4 - Phạm Tường Chiến & Trần Văn Thắng - Deliver managed Kubernetes C...Room 1 - 4 - Phạm Tường Chiến & Trần Văn Thắng - Deliver managed Kubernetes C...
Room 1 - 4 - Phạm Tường Chiến & Trần Văn Thắng - Deliver managed Kubernetes C...
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
AWS CDK Introduction
AWS CDK IntroductionAWS CDK Introduction
AWS CDK Introduction
 
Building infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps KrakowBuilding infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps Krakow
 

Similar to Using new sentinel features in terraform cloud

Using Sentinel Policies Across Multiple Terraform Cloud Organizations
Using Sentinel Policies Across Multiple Terraform Cloud OrganizationsUsing Sentinel Policies Across Multiple Terraform Cloud Organizations
Using Sentinel Policies Across Multiple Terraform Cloud OrganizationsMitchell Pronschinske
 
RIMA-Infrastructure as a code with Terraform.pptx
RIMA-Infrastructure as a code with Terraform.pptxRIMA-Infrastructure as a code with Terraform.pptx
RIMA-Infrastructure as a code with Terraform.pptxMrJustbis
 
Terraform Abstractions for Safety and Power
Terraform Abstractions for Safety and PowerTerraform Abstractions for Safety and Power
Terraform Abstractions for Safety and PowerCalvin French-Owen
 
Policy Guided Fulfillmentof Murano Applications
Policy Guided Fulfillmentof Murano ApplicationsPolicy Guided Fulfillmentof Murano Applications
Policy Guided Fulfillmentof Murano Applicationsrpospisil
 
3 Reasons to Select Time Series Platforms for Cloud Native Applications Monit...
3 Reasons to Select Time Series Platforms for Cloud Native Applications Monit...3 Reasons to Select Time Series Platforms for Cloud Native Applications Monit...
3 Reasons to Select Time Series Platforms for Cloud Native Applications Monit...DevOps.com
 
Terraform vs Pulumi
Terraform vs PulumiTerraform vs Pulumi
Terraform vs PulumiHoaiNam307
 
DevOps Online Training in Hyderabad
DevOps Online Training in HyderabadDevOps Online Training in Hyderabad
DevOps Online Training in HyderabadVisualpath Training
 
Git ops & Continuous Infrastructure with terra*
Git ops  & Continuous Infrastructure with terra*Git ops  & Continuous Infrastructure with terra*
Git ops & Continuous Infrastructure with terra*Haggai Philip Zagury
 
Terraform day 1
Terraform day 1Terraform day 1
Terraform day 1Kalkey
 
Unicorn Platform; Basic Usage Guide
Unicorn Platform; Basic Usage GuideUnicorn Platform; Basic Usage Guide
Unicorn Platform; Basic Usage Guideubigiannis
 
Controlling Cloud Costs with HashiCorp Terraform
Controlling Cloud Costs with HashiCorp TerraformControlling Cloud Costs with HashiCorp Terraform
Controlling Cloud Costs with HashiCorp TerraformDevOps.com
 
Installing your influx enterprise cluster
Installing your influx enterprise clusterInstalling your influx enterprise cluster
Installing your influx enterprise clusterChris Churilo
 
3 reasons to pick a time series platform for monitoring dev ops driven contai...
3 reasons to pick a time series platform for monitoring dev ops driven contai...3 reasons to pick a time series platform for monitoring dev ops driven contai...
3 reasons to pick a time series platform for monitoring dev ops driven contai...DevOps.com
 
Developing Tizen OS Based Solutions (IDF13) - Chris Norman
Developing Tizen OS Based Solutions (IDF13) - Chris NormanDeveloping Tizen OS Based Solutions (IDF13) - Chris Norman
Developing Tizen OS Based Solutions (IDF13) - Chris NormanRyo Jin
 
Self-service PR-based Terraform
Self-service PR-based TerraformSelf-service PR-based Terraform
Self-service PR-based TerraformAndrew Kirkpatrick
 
Infrastructure as Code with Terraform.pptx
Infrastructure as Code with Terraform.pptxInfrastructure as Code with Terraform.pptx
Infrastructure as Code with Terraform.pptxSamuel862293
 
The Flink - Apache Bigtop integration
The Flink - Apache Bigtop integrationThe Flink - Apache Bigtop integration
The Flink - Apache Bigtop integrationMárton Balassi
 
Build cloud native solution using open source
Build cloud native solution using open source Build cloud native solution using open source
Build cloud native solution using open source Nitesh Jadhav
 

Similar to Using new sentinel features in terraform cloud (20)

Using Sentinel Policies Across Multiple Terraform Cloud Organizations
Using Sentinel Policies Across Multiple Terraform Cloud OrganizationsUsing Sentinel Policies Across Multiple Terraform Cloud Organizations
Using Sentinel Policies Across Multiple Terraform Cloud Organizations
 
RIMA-Infrastructure as a code with Terraform.pptx
RIMA-Infrastructure as a code with Terraform.pptxRIMA-Infrastructure as a code with Terraform.pptx
RIMA-Infrastructure as a code with Terraform.pptx
 
Terraform Abstractions for Safety and Power
Terraform Abstractions for Safety and PowerTerraform Abstractions for Safety and Power
Terraform Abstractions for Safety and Power
 
Policy Guided Fulfillmentof Murano Applications
Policy Guided Fulfillmentof Murano ApplicationsPolicy Guided Fulfillmentof Murano Applications
Policy Guided Fulfillmentof Murano Applications
 
3 Reasons to Select Time Series Platforms for Cloud Native Applications Monit...
3 Reasons to Select Time Series Platforms for Cloud Native Applications Monit...3 Reasons to Select Time Series Platforms for Cloud Native Applications Monit...
3 Reasons to Select Time Series Platforms for Cloud Native Applications Monit...
 
Terraform vs Pulumi
Terraform vs PulumiTerraform vs Pulumi
Terraform vs Pulumi
 
DevOps Online Training in Hyderabad
DevOps Online Training in HyderabadDevOps Online Training in Hyderabad
DevOps Online Training in Hyderabad
 
Kafka/SMM Crash Course
Kafka/SMM Crash CourseKafka/SMM Crash Course
Kafka/SMM Crash Course
 
Git ops & Continuous Infrastructure with terra*
Git ops  & Continuous Infrastructure with terra*Git ops  & Continuous Infrastructure with terra*
Git ops & Continuous Infrastructure with terra*
 
OpenStack Murano
OpenStack MuranoOpenStack Murano
OpenStack Murano
 
Terraform day 1
Terraform day 1Terraform day 1
Terraform day 1
 
Unicorn Platform; Basic Usage Guide
Unicorn Platform; Basic Usage GuideUnicorn Platform; Basic Usage Guide
Unicorn Platform; Basic Usage Guide
 
Controlling Cloud Costs with HashiCorp Terraform
Controlling Cloud Costs with HashiCorp TerraformControlling Cloud Costs with HashiCorp Terraform
Controlling Cloud Costs with HashiCorp Terraform
 
Installing your influx enterprise cluster
Installing your influx enterprise clusterInstalling your influx enterprise cluster
Installing your influx enterprise cluster
 
3 reasons to pick a time series platform for monitoring dev ops driven contai...
3 reasons to pick a time series platform for monitoring dev ops driven contai...3 reasons to pick a time series platform for monitoring dev ops driven contai...
3 reasons to pick a time series platform for monitoring dev ops driven contai...
 
Developing Tizen OS Based Solutions (IDF13) - Chris Norman
Developing Tizen OS Based Solutions (IDF13) - Chris NormanDeveloping Tizen OS Based Solutions (IDF13) - Chris Norman
Developing Tizen OS Based Solutions (IDF13) - Chris Norman
 
Self-service PR-based Terraform
Self-service PR-based TerraformSelf-service PR-based Terraform
Self-service PR-based Terraform
 
Infrastructure as Code with Terraform.pptx
Infrastructure as Code with Terraform.pptxInfrastructure as Code with Terraform.pptx
Infrastructure as Code with Terraform.pptx
 
The Flink - Apache Bigtop integration
The Flink - Apache Bigtop integrationThe Flink - Apache Bigtop integration
The Flink - Apache Bigtop integration
 
Build cloud native solution using open source
Build cloud native solution using open source Build cloud native solution using open source
Build cloud native solution using open source
 

More from Mitchell Pronschinske

Getting Started with Kubernetes and Consul
Getting Started with Kubernetes and ConsulGetting Started with Kubernetes and Consul
Getting Started with Kubernetes and ConsulMitchell Pronschinske
 
Multi-Cloud with Nomad and Consul Connect
Multi-Cloud with Nomad and Consul ConnectMulti-Cloud with Nomad and Consul Connect
Multi-Cloud with Nomad and Consul ConnectMitchell Pronschinske
 
Dynamic Azure Credentials for Applications and CI/CD Pipelines
Dynamic Azure Credentials for Applications and CI/CD PipelinesDynamic Azure Credentials for Applications and CI/CD Pipelines
Dynamic Azure Credentials for Applications and CI/CD PipelinesMitchell Pronschinske
 
Migrating from VMs to Kubernetes using HashiCorp Consul Service on Azure
Migrating from VMs to Kubernetes using HashiCorp Consul Service on AzureMigrating from VMs to Kubernetes using HashiCorp Consul Service on Azure
Migrating from VMs to Kubernetes using HashiCorp Consul Service on AzureMitchell Pronschinske
 
Empowering developers and operators through Gitlab and HashiCorp
Empowering developers and operators through Gitlab and HashiCorpEmpowering developers and operators through Gitlab and HashiCorp
Empowering developers and operators through Gitlab and HashiCorpMitchell Pronschinske
 
Automate and simplify multi cloud complexity with f5 and hashi corp
Automate and simplify multi cloud complexity with f5 and hashi corpAutomate and simplify multi cloud complexity with f5 and hashi corp
Automate and simplify multi cloud complexity with f5 and hashi corpMitchell Pronschinske
 
Military Edge Computing with Vault and Consul
Military Edge Computing with Vault and ConsulMilitary Edge Computing with Vault and Consul
Military Edge Computing with Vault and ConsulMitchell Pronschinske
 
Unlocking the Cloud operating model with GitHub Actions
Unlocking the Cloud operating model with GitHub ActionsUnlocking the Cloud operating model with GitHub Actions
Unlocking the Cloud operating model with GitHub ActionsMitchell Pronschinske
 
Vault 1.4 integrated storage overview
Vault 1.4 integrated storage overviewVault 1.4 integrated storage overview
Vault 1.4 integrated storage overviewMitchell Pronschinske
 
Cisco ACI with HashiCorp Terraform (APAC)
Cisco ACI with HashiCorp Terraform (APAC)Cisco ACI with HashiCorp Terraform (APAC)
Cisco ACI with HashiCorp Terraform (APAC)Mitchell Pronschinske
 
Governance for Multiple Teams Sharing a Nomad Cluster
Governance for Multiple Teams Sharing a Nomad ClusterGovernance for Multiple Teams Sharing a Nomad Cluster
Governance for Multiple Teams Sharing a Nomad ClusterMitchell Pronschinske
 
Unlocking the Cloud Operating Model: Deployment
Unlocking the Cloud Operating Model: DeploymentUnlocking the Cloud Operating Model: Deployment
Unlocking the Cloud Operating Model: DeploymentMitchell Pronschinske
 
Keeping a Secret with HashiCorp Vault
Keeping a Secret with HashiCorp VaultKeeping a Secret with HashiCorp Vault
Keeping a Secret with HashiCorp VaultMitchell Pronschinske
 
Modern Scheduling for Modern Applications with Nomad
Modern Scheduling for Modern Applications with NomadModern Scheduling for Modern Applications with Nomad
Modern Scheduling for Modern Applications with NomadMitchell Pronschinske
 
Moving to a Microservice World: Leveraging Consul on Azure
Moving to a Microservice World: Leveraging Consul on AzureMoving to a Microservice World: Leveraging Consul on Azure
Moving to a Microservice World: Leveraging Consul on AzureMitchell Pronschinske
 

More from Mitchell Pronschinske (20)

Getting Started with Kubernetes and Consul
Getting Started with Kubernetes and ConsulGetting Started with Kubernetes and Consul
Getting Started with Kubernetes and Consul
 
Multi-Cloud with Nomad and Consul Connect
Multi-Cloud with Nomad and Consul ConnectMulti-Cloud with Nomad and Consul Connect
Multi-Cloud with Nomad and Consul Connect
 
Code quality for Terraform
Code quality for TerraformCode quality for Terraform
Code quality for Terraform
 
Dynamic Azure Credentials for Applications and CI/CD Pipelines
Dynamic Azure Credentials for Applications and CI/CD PipelinesDynamic Azure Credentials for Applications and CI/CD Pipelines
Dynamic Azure Credentials for Applications and CI/CD Pipelines
 
Migrating from VMs to Kubernetes using HashiCorp Consul Service on Azure
Migrating from VMs to Kubernetes using HashiCorp Consul Service on AzureMigrating from VMs to Kubernetes using HashiCorp Consul Service on Azure
Migrating from VMs to Kubernetes using HashiCorp Consul Service on Azure
 
Empowering developers and operators through Gitlab and HashiCorp
Empowering developers and operators through Gitlab and HashiCorpEmpowering developers and operators through Gitlab and HashiCorp
Empowering developers and operators through Gitlab and HashiCorp
 
Automate and simplify multi cloud complexity with f5 and hashi corp
Automate and simplify multi cloud complexity with f5 and hashi corpAutomate and simplify multi cloud complexity with f5 and hashi corp
Automate and simplify multi cloud complexity with f5 and hashi corp
 
Vault 1.5 Overview
Vault 1.5 OverviewVault 1.5 Overview
Vault 1.5 Overview
 
Military Edge Computing with Vault and Consul
Military Edge Computing with Vault and ConsulMilitary Edge Computing with Vault and Consul
Military Edge Computing with Vault and Consul
 
Unlocking the Cloud operating model with GitHub Actions
Unlocking the Cloud operating model with GitHub ActionsUnlocking the Cloud operating model with GitHub Actions
Unlocking the Cloud operating model with GitHub Actions
 
Vault 1.4 integrated storage overview
Vault 1.4 integrated storage overviewVault 1.4 integrated storage overview
Vault 1.4 integrated storage overview
 
Unlocking the Cloud Operating Model
Unlocking the Cloud Operating ModelUnlocking the Cloud Operating Model
Unlocking the Cloud Operating Model
 
Cisco ACI with HashiCorp Terraform (APAC)
Cisco ACI with HashiCorp Terraform (APAC)Cisco ACI with HashiCorp Terraform (APAC)
Cisco ACI with HashiCorp Terraform (APAC)
 
Governance for Multiple Teams Sharing a Nomad Cluster
Governance for Multiple Teams Sharing a Nomad ClusterGovernance for Multiple Teams Sharing a Nomad Cluster
Governance for Multiple Teams Sharing a Nomad Cluster
 
Integrating Terraform and Consul
Integrating Terraform and ConsulIntegrating Terraform and Consul
Integrating Terraform and Consul
 
Unlocking the Cloud Operating Model: Deployment
Unlocking the Cloud Operating Model: DeploymentUnlocking the Cloud Operating Model: Deployment
Unlocking the Cloud Operating Model: Deployment
 
Keeping a Secret with HashiCorp Vault
Keeping a Secret with HashiCorp VaultKeeping a Secret with HashiCorp Vault
Keeping a Secret with HashiCorp Vault
 
Modern Scheduling for Modern Applications with Nomad
Modern Scheduling for Modern Applications with NomadModern Scheduling for Modern Applications with Nomad
Modern Scheduling for Modern Applications with Nomad
 
Moving to a Microservice World: Leveraging Consul on Azure
Moving to a Microservice World: Leveraging Consul on AzureMoving to a Microservice World: Leveraging Consul on Azure
Moving to a Microservice World: Leveraging Consul on Azure
 
Remote Culture at HashiCorp
Remote Culture at HashiCorpRemote Culture at HashiCorp
Remote Culture at HashiCorp
 

Recently uploaded

How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROmotivationalword821
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 

Recently uploaded (20)

How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 

Using new sentinel features in terraform cloud

  • 1. Copyright © 2020 HashiCorp Using New Sentinel Features in Terraform Cloud and Terraform Enterprise Roger Berlind Technology Specialist HashiCorp
  • 2. Copyright © 2020 HashiCorp ▪ Sentinel in Terraform Cloud (TFC) and Terraform Enterprise (TFE) ▪ Two New Sentinel Features – Sentinel Modules – Terraform Sentinel v2 Imports ▪ The Evolution of Sentinel Policies ▪ Some Prototypical Third-Generation Sentinel Policies ▪ The Third-Generation Common Functions ▪ Testing and Using the Third Generation Sentinel Policies ▪ A Demo Agenda
  • 3. Copyright © 2020 HashiCorp Sentinel in Terraform Cloud and Terraform Enterprise
  • 4. Copyright © 2020 HashiCorp ▪ HashiCorp's Sentinel is a framework for implementing governance policies as code in the same way that Terraform implements infrastructure as code. ▪ It includes its own language and is embedded in HashiCorp's enterprise products. ▪ Using Sentinel ensures that your governance policies are actually being checked rather than just being listed in a spreadsheet. ▪ It supports fine-grained policies that use conditional logic. ▪ It includes a CLI that allows you to test and run policies. What is Sentinel?
  • 5. Copyright © 2020 HashiCorp Terraform Cloud and Terraform Enterprise ▪ A User Interface ▪ Workspace Management ▪ Team Management ▪ State Management ▪ Secure Variable Management ▪ Remote Runs and State ▪ VCS Integrations ▪ HTTP/JSON API ▪ Private Module Registry ▪ Configuration Editor ▪ Sentinel (policy as code) ▪ SSO via SAML Integration ▪ Audit Logging Terraform Cloud (TFC) includes the following advanced functionality that makes it easier for teams and organizations to use Terraform: Customers can install Terraform Enterprise (TFE) servers to self-host TFC in their own virtual private networks or in their data centers.
  • 6. Copyright © 2020 HashiCorp ▪ Sentinel policies are checked between the standard plan and apply steps of Terraform runs. ▪ Policies have different enforcement levels: advisory, soft-mandatory, and hard-mandatory. ▪ Violations prevent runs from being applied unless a user with sufficient authority overrides them. ▪ Sentinel policies can evaluate the attributes (arguments and exported attributes) of existing and new resources and data sources based on information from the current run: – the plan, the configuration, the current state, and other run data including cost estimates ▪ This ensures that resources comply with all policies before they are provisioned. Where is Sentinel Used in Terraform?
  • 7. Copyright © 2020 HashiCorp How Terraform Works Without Sentinel VCS Terraform Infrastructureplan & apply
  • 8. Copyright © 2020 HashiCorp How Terraform Works With Sentinel VCS Terraform Cloud Workspace Infrastructureplan Sentinel Policy Checks apply If cost estimates are enabled, they run right after the plan.
  • 9. Copyright © 2020 HashiCorp All Policy Checks Passed
  • 10. Copyright © 2020 HashiCorp ▪ HashiCorp customers are using Sentinel to implement governance policies like the following in Terraform Cloud/Enterprise: – Enforce security standards: ▪ Require all S3 buckets use the private ACL and be encrypted by KMS. ▪ Restrict which roles the AWS provider can assume. ▪ Blacklist/whitelist resources, data sources, providers, or provisioners. – Avoid excessive costs: ▪ Limit the sizes of VMs and Kubernetes clusters in public clouds. ▪ Limit the monthly spend of each Terraform workspace. – Enforce mandatory tags on resources provisioned by Terraform. – Mandate that all modules come from a Private Module Registry. – Enforce specific Terraform coding conventions. How Customers are Using Sentinel in Terraform
  • 11. Copyright © 2020 HashiCorp Two New Sentinel Features
  • 12. Copyright © 2020 HashiCorp ▪ A Sentinel Module defines Sentinel functions and rules in a file that can be used by Sentinel policies with a single import statement. ▪ This avoids the need to paste the functions into every policy that calls them, improving the reusability of Sentinel functions. ▪ Sentinel modules are registered in Sentinel CLI configuration files and in TFC/TFE policy set configuration files. ▪ The terraform-guides repository includes 5 "third-generation" modules: – tfplan-functions, tfstate-functions, tfconfig-functions, tfrun-functions, and aws-functions ▪ Each function is documented in a separate MD file. ▪ Note that these are NOT standard functions. Sentinel Modules
  • 13. Copyright © 2020 HashiCorp ▪ The new v2 versions of three Terraform Sentinel imports (tfplan, tfstate, and tfconfig) are aligned more closely with native Terraform 0.12 data structures. ▪ This makes the v2 imports easier to use than the v1 imports. ▪ Additionally, since resource instances are stored in a single flat map that spans across all Terraform modules and resource types, it is much easier to find all resources instances of a specific type or a sub-collection of them. ▪ However, there is a catch: – The v2 imports can only be used with Terraform 0.12. New v2 Versions of the Terraform Sentinel Imports
  • 14. Copyright © 2020 HashiCorp ▪ The tfplan/v2 gives data generated from Terraform plans. – https://www.terraform.io/docs/cloud/sentinel/import/tfplan-v2.html ▪ The tfconfig/v2 import gives data about the Terraform configuration. – https://www.terraform.io/docs/cloud/sentinel/import/tfconfig-v2.html ▪ The tfstate/v2 import gives data about the current state of a workspace. – https://www.terraform.io/docs/cloud/sentinel/import/tfstate-v2.html ▪ The tfrun import provides metadata for Terraform runs and their workspaces as well as cost estimate data. (There is no v2 version of it.) – https://www.terraform.io/docs/cloud/sentinel/import/tfrun.html Sentinel Imports in Terraform
  • 15. Copyright © 2020 HashiCorp The Evolution of Sentinel Policies
  • 16. Copyright © 2020 HashiCorp ▪ The first-generation policies were written in late 2018 and used the original Terraform Sentinel v1 imports. ▪ They had several short-comings, including the following: – Most of the policies did not print violation messages for resources that violated them. – They stopped evaluating conditions as soon as a single resource instance violated them. – They failed when resources that were being destroyed violated conditions. – Their use of default Sentinel output was overly verbose. The First-Generation Policies
  • 17. Copyright © 2020 HashiCorp ▪ The second-generation policies were written in 2019 and used the original Terraform Sentinel v1 imports: ▪ They made the following improvements: – They offloaded most processing from rules into some common parameterized functions. – Those common functions were written in a way that caused all violations of all rules to be reported. – They printed out the full address of each resource instance that did violate a policy. – By using a single main rule, they suppressed most of Sentinel’s default, overly verbose output. – They skipped resources that were being destroyed but not recreated. The Second-Generation Policies
  • 18. Copyright © 2020 HashiCorp ▪ The new third-generation policies were written in the spring of 2020 and use the new Terraform Sentinel v2 imports and Sentinel modules. ▪ They have the following advantages: – Their use of the v2 imports and the Sentinel filter expression makes it easier to restrict policies to specific operations performed by Terraform. – The common functions defined in Sentinel modules do not need to be pasted into policies that use them. – Most of the policies do not have any for loops of if/else conditionals. This makes the policies easier to understand and copy. – They can evaluate the value of any attribute of any resource or data source, even those that are deeply nested. ▪ However, since they do use the v2 imports, they can only be used with Terraform 0.12 The New Third-Generation Policies
  • 19. Copyright © 2020 HashiCorp Some Prototypical Third- Generation Sentinel Policies
  • 20. Copyright © 2020 HashiCorp ▪ I'll review four prototypical third-generation Sentinel policies in order of increasing sophistication: – restrict-ec2-instance-type.sentinel (AWS) – restrict-vm-cpu-and-memory.sentinel (VMware) – restrict-vm-disk-size.sentinel (VMware) – restrict-publishers-of-current-vms.sentinel (Azure) Some Prototypical Third-Generation Policies
  • 21. Copyright © 2020 HashiCorp The Third-Generation Common Functions
  • 22. Copyright © 2020 HashiCorp ▪ As mentioned earlier, there are third-generation Sentinel modules with common functions for each of the Terraform Sentinel imports. ▪ The tfplan and tfstate modules have the following functions: – Find functions that find resources, data sources, and blocks. – Filter functions that filter collections of resources, data sources, or blocks. These each return two maps: resources and messages. – The evaluate_attribute function that can evaluate any attribute of any resource, data source, or block, even if deeply nested. – The to_string and print_violation functions that are used by the other functions. ▪ There is also a Sentinel module with some AWS-specific functions. The Third-Generation Common Functions
  • 23. Copyright © 2020 HashiCorp Testing and Using the Third- Generation Sentinel Policies
  • 24. Copyright © 2020 HashiCorp ▪ All the third-generation Sentinel policies have test cases and mocks that support testing the policies with the Sentinel CLI ▪ Do the following: – Download the Sentinel CLI from the Sentinel Downloads page. – Unzip the zip file and place the sentinel binary in your path. – Fork the terraform-guides repository and clone your fork to your local machine. – Navigate to any of the cloud directories (aws, azure, gcp, or vmware) or to the cloud-agnostic directory. – Run sentinel test to test all policies for that cloud. – Run sentinel test -run=<partial_policy_name> -verbose to test individual policies, using a string that partially matches name. Testing Policies with the Sentinel CLI
  • 25. Copyright © 2020 HashiCorp { "modules": { "tfplan-functions": { "path": "../../../common-functions/tfplan-functions/ tfplan-functions.sentinel" } }, "mock": { "tfplan/v2": "mock-tfplan-pass.sentinel" }, "test": { "main": true } } An Example Test Case that References a Module
  • 26. Copyright © 2020 HashiCorp ▪ After successfully testing a policy with the CLI and possibly also on TFC itself, you will want to deploy it to your TFC/TFE organizations. ▪ If you have not already added the policy to a policy set in your organizations, do that at this time. ▪ Add the new policy to an existing policy set that is already applied against desired workspaces, or create a new policy set for the policy and apply that policy set to desired workspaces across your organizations. ▪ Also add any parameters the policy requires to your policy set. ▪ And add references to any Sentinel Modules that policies in it use. Deploying Policies in TFC or TFE
  • 27. Copyright © 2020 HashiCorp ▪ Here is an example policy set: module "tfplan-functions" { source = "../common-functions/tfplan-functions/tfplan -functions.sentinel" } policy "restrict-ec2-instance-type" { source = "./restrict-ec2-instance-type.sentinel" enforcement_level = "soft-mandatory" } Example Policy Set
  • 28. Copyright © 2020 HashiCorp Demo
  • 29. Copyright © 2020 HashiCorp ▪ Here are some useful Links ▪ Documentation – https://www.terraform.io/docs/cloud/sentinel/index.html – https://www.terraform.io/docs/cloud/sentinel/manage- policies.html – https://docs.hashicorp.com/sentinel ▪ Other Resources: – Blog for this webinar – Sentinel in Terraform v2 Workshop (including hands-on Instruqt track that teaches you how to write and test policies) Some Useful Links

Editor's Notes

  1. These slides are intended to accompany the Sentinel for Terraform v2 workshop They should be used with the Sentinel for Terraform v2 Instruqt track: https://instruqt.com/hashicorp/tracks/sentinel-for-terraform-v2
  2. Let's talk about Sentinel and how it fits into Terraform Cloud and Terraform Enterprise. We'll also discuss how customers are using Sentinel in TFC and TFE.
  3. Sentinel is a framework for implementing governance policies as code It has its own language It has a CLI for testing and running policies
  4. Let's level set about Terraform Cloud and Terraform Enterprise Note that Terraform Cloud (TFC) refers both to the actual application used and the implementation hosted by HashiCorp at app.terraform.io. Since TFE uses the TFC application, we will mostly just talk about TFC. But anything we say about TFC is true of TFE too except when we discuss very new features that have been released to TFC. But those new features generally end up in TFE within 4-6 weeks.
  5. Let's talk about where Sentinel is used in TFC and TFE. It is run between the plan and the apply of a run. If cost estimates are enabled for a workspace, the Sentinel policies are checked after the cost estimates are collected. "Arguments" are the inputs to Terraform resources and data sources. Each resource and data source also exports certain attributes that are computed during the apply. These are called "exported attributes". But since the arguments or a resource are also exported, it is common to use "attributes" to refer to the union of a resource's arguments and exported attributes.
  6. Here is how Terraform works without Sentinel.
  7. Here is how Terraform works with Sentinel. Note that if cost estimates are enabled for the workspace, they will run right after the plan.
  8. A screenshot from TFC showing that all policy checks passed for a run.
  9. Let's talk about some use cases for Sentinel in TFC and TFE.
  10. Let's spend some time discussing the Sentinel language.
  11. Sentinel modules allow for the reuse of Sentinel functions and rules. They are registered in Sentinel CLI configuration files and in TFC/TFE policy set configuration files.
  12. Sentinel has some builtin functions that you can use in any policy.
  13. This is a good point to discuss the Terraform-specific Sentinel imports. Terraform Cloud/Enterprise adds 4 Sentinel imports beyond the standard ones. This version of the workshop uses the v2 versions of the tfplan, tfconfig, and tfstate imports. The v2 versions are more closely aligned to Terraform 0.12's internal data structures. There is only 1 version of the tfrun import.
  14. Now we will do the first two workshop challenges on the Instruqt platform
  15. The first-generation policies had several limitations.
  16. The second-generation policies made many improvements.
  17. The new workshop exercises leverage the Instruqt platform and make solving the exercises much easier. Be sure to use the Sentinel Instruqt track that ends in v2, not the one that ends in v1.
  18. Now let's walk through the basic 8 step methodology of the Writing and Testing Sentinel Policies for Terraform guide.
  19. This slide gives the basic 8 step methodology of writing and testing Sentinel policies from the Writing and Testing Sentinel Policies for Terraform guide. We will focus on 5-7 in this workshop.
  20. Now let's walk through the basic 8 step methodology of the Writing and Testing Sentinel Policies for Terraform guide.
  21. After testing new Sentinel policies with the Sentinel CLI, you can test them in an organization on a TFC or TFE server.
  22. While we won't be using Sentinel in Terraform Cloud or Terraform Enterprise today, we did want to review this topic After all, that is where your Sentinel policies will really be running. You'll get a chance to complete and test some more Sentinel policies with the Sentinel CLI after this section.
  23. After testing new Sentinel policies with the Sentinel CLI, you can test them in an organization on a TFC or TFE server.
  24. The stanza at the top declares a Sentinel Modules with functions that can be called by Sentinel policies that import them. In this case, the file "tfplan-functions.sentinel" is being declared as the module "tfplan-functions". Recall that when we imported it in our policy, we gave it the alias "plan". We also indicate that the test case should use the mock-tfplan-pass.sentinel mock and that the main rule should evaluate to true. If using tfconfig/v2, tfstate/v2, or tfrun mock files, you need to specify the mock type accordingly (instead of using "tfplan/v2").
  25. After testing a policy with the Sentinel CLI and possibly in a TFC/TFE organization, you'll want to deploy it to your TFC organizations.
  26. You'll need to create policy sets that contain the policies you want to use in TFC or TFE You can now specify Sentinel modules in your policy sets, but the modules must be in or under the directory with the sentinel.hcl file at this time. In the near future, we will support loading of modules from remote locations.
  27. While we won't be using Sentinel in Terraform Cloud or Terraform Enterprise today, we did want to review this topic After all, that is where your Sentinel policies will really be running. You'll get a chance to complete and test some more Sentinel policies with the Sentinel CLI after this section.
  28. Thanks for attending the Sentinel in Terraform Workshop or reviewing these slides.