Az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/12345686-82de-4a8d-b643-12345605372a"
{
"appId": "123456c7-dd48-41c0-aa76-52a770123456",
"displayName": "azure-cli-2022-01-24-20-13-16",
"name": "a88530c7-dd48-41c0-aa76-52a770fa69fb",
"password": "123456.Y1j3j_1234562sxONHwM123456.",
"tenant": "65123456-faea-4b9d-a488-123456123456"
}
ARM_CLIENT_ID=123456c7-dd48-41c0-aa76-52a770123456
ARM_CLIENT_SECRET=123456.Y1j3j_1234562sxONHwM123456.
ARM_TENANT_ID=65123456-faea-4b9d-a488-123456123456
ARM_SUBSCRIPTION_ID=12345686-82de-4a8d-b643-12345605372a
main.tf
, versions.tf
, outputs.tf
, variables.tf
and readme.md
files.Note: In a private module it did not pull in the versions.tf
configuration into the dependency tab.
module "staticwebsiteprivate" {
source = "app.terraform.io/richbjhudson/staticwebsiteprivate/azurerm"
version = "1.0.0"
# insert required variables here
}
terraform login
.
credentials.tfrc.json
as plain text.The CLI driven workflow allows you to:
Private registry
backend
block that is included in the terraform
block:backend "remote" {
organization = "richbjhudson"
workspaces {
name = "cli-driven-azure-demo"
}
}
cloud {
organization = "richbjhudson"
workspaces
{ name = "cli-driven-azure-demo" }
}
Make sure you add the environment variables to your workspace so that TFC can connect to your Azure subscription.
terraform plan
- this gets added to TFC runs tab you have to click on link from your local machine.terraform apply
- this gets recorded in TFC.terraform destroy
- this gets recorded in TFC.backend
/ cloud
block within a terraform
block.cloud {
organization = "richbjhudson"
workspaces {
name = "terraformCloudWorkspaceName"
}
}
terraform login
.
C:\Users\username\AppData\Roaming\terraform.d\credentials.tfrc.json
.terraform init
will result in a prompt to ask if you would like to migrate the local state to a terraform cloud workspace:Do you wish to proceed?
As part of migrating to Terraform Cloud, Terraform can optionally copy your current workspace state to the configured Terraform Cloud workspace.
Answer "yes" to copy the latest state snapshot to the configured Terraform Cloud workspace.
Answer "no" to ignore the existing state and just activate the configured Terraform Cloud workspace with its existing state, if any.
Should Terraform migrate your existing state?
Enter a value: yes
Note: After this step it creates the workspace if it did not already exist. The workspace is built to use the terraform cli version that you migrated from.
terraform plan
but before terraform apply
.Note: Mandatory policy checks will not pass onto the next stage if they are not compliant. The stage of the check is based on the functions e.g. tfconfig, tfrun, tfplan etc…
Terraform Governance Guides are a standard set of policies created by Hashicorp that may be used for common use cases.
.sentinel
files include policy configuration that reference the functions that stipulate when the policy should be applied e.g. cost limit policy at tfrun.Sentinel.hcl
- import modules (functions) and reference policies by source and enforcement_level.Note: You may install the HashiCorp sentinel extension in vscode to make it easier to understand the syntax.
sentinel.hcl
file.
policy "azure-cis-6.4-networking-enforce-network-watcher-flow-log-retention-period" {
source = "https://raw.githubusercontent.com/hashicorp/terraform-foundational-policies-library/master/cis/azure/networking/azure-cis-6.4-networking-enforce-network-watcher-flow-log-retention-period/azure-cis-6.4-networking-enforce-network-watcher-flow-log-retention-period.sentinel"
enforcement_level = "advisory"
}