Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkrief committed Jun 13, 2023
1 parent 9ee079e commit 5c4f4fe
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHAP11/kitchen/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source "https://rubygems.org/" do
gem "kitchen-terraform", "5.8.0"
gem "kitchen-terraform", "7.0.2"
end
4 changes: 2 additions & 2 deletions CHAP11/opa/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ resource "azurerm_resource_group" "rg" {
}

resource "azurerm_storage_account" "storage" {
name = "sademotestopa123"
name = "sademotestopa1"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
account_tier = "Standard"
account_replication_type = "GRS"
enable_https_traffic_only = true #false
enable_https_traffic_only = false #true
}
1 change: 1 addition & 0 deletions CHAP11/opa/tfplan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"format_version":"1.1","terraform_version":"1.4.6","planned_values":{"root_module":{"resources":[{"address":"azurerm_resource_group.rg","mode":"managed","type":"azurerm_resource_group","name":"rg","provider_name":"registry.terraform.io/hashicorp/azurerm","schema_version":0,"values":{"location":"westeurope","name":"rg-demo-opa","tags":null,"timeouts":null},"sensitive_values":{}},{"address":"azurerm_storage_account.storage","mode":"managed","type":"azurerm_storage_account","name":"storage","provider_name":"registry.terraform.io/hashicorp/azurerm","schema_version":3,"values":{"account_kind":"StorageV2","account_replication_type":"GRS","account_tier":"Standard","allow_nested_items_to_be_public":true,"allowed_copy_scope":null,"azure_files_authentication":[],"cross_tenant_replication_enabled":true,"custom_domain":[],"customer_managed_key":[],"default_to_oauth_authentication":false,"edge_zone":null,"enable_https_traffic_only":true,"identity":[],"immutability_policy":[],"infrastructure_encryption_enabled":false,"is_hns_enabled":false,"location":"westeurope","min_tls_version":"TLS1_2","name":"sademotestopa123","nfsv3_enabled":false,"public_network_access_enabled":true,"queue_encryption_key_type":"Service","resource_group_name":"rg-demo-opa","sas_policy":[],"sftp_enabled":false,"shared_access_key_enabled":true,"static_website":[],"table_encryption_key_type":"Service","tags":null,"timeouts":null},"sensitive_values":{"azure_files_authentication":[],"blob_properties":[],"custom_domain":[],"customer_managed_key":[],"identity":[],"immutability_policy":[],"network_rules":[],"queue_properties":[],"routing":[],"sas_policy":[],"share_properties":[],"static_website":[]}}]}},"resource_changes":[{"address":"azurerm_resource_group.rg","mode":"managed","type":"azurerm_resource_group","name":"rg","provider_name":"registry.terraform.io/hashicorp/azurerm","change":{"actions":["create"],"before":null,"after":{"location":"westeurope","name":"rg-demo-opa","tags":null,"timeouts":null},"after_unknown":{"id":true},"before_sensitive":false,"after_sensitive":{}}},{"address":"azurerm_storage_account.storage","mode":"managed","type":"azurerm_storage_account","name":"storage","provider_name":"registry.terraform.io/hashicorp/azurerm","change":{"actions":["create"],"before":null,"after":{"account_kind":"StorageV2","account_replication_type":"GRS","account_tier":"Standard","allow_nested_items_to_be_public":true,"allowed_copy_scope":null,"azure_files_authentication":[],"cross_tenant_replication_enabled":true,"custom_domain":[],"customer_managed_key":[],"default_to_oauth_authentication":false,"edge_zone":null,"enable_https_traffic_only":true,"identity":[],"immutability_policy":[],"infrastructure_encryption_enabled":false,"is_hns_enabled":false,"location":"westeurope","min_tls_version":"TLS1_2","name":"sademotestopa123","nfsv3_enabled":false,"public_network_access_enabled":true,"queue_encryption_key_type":"Service","resource_group_name":"rg-demo-opa","sas_policy":[],"sftp_enabled":false,"shared_access_key_enabled":true,"static_website":[],"table_encryption_key_type":"Service","tags":null,"timeouts":null},"after_unknown":{"access_tier":true,"azure_files_authentication":[],"blob_properties":true,"custom_domain":[],"customer_managed_key":[],"id":true,"identity":[],"immutability_policy":[],"large_file_share_enabled":true,"network_rules":true,"primary_access_key":true,"primary_blob_connection_string":true,"primary_blob_endpoint":true,"primary_blob_host":true,"primary_connection_string":true,"primary_dfs_endpoint":true,"primary_dfs_host":true,"primary_file_endpoint":true,"primary_file_host":true,"primary_location":true,"primary_queue_endpoint":true,"primary_queue_host":true,"primary_table_endpoint":true,"primary_table_host":true,"primary_web_endpoint":true,"primary_web_host":true,"queue_properties":true,"routing":true,"sas_policy":[],"secondary_access_key":true,"secondary_blob_connection_string":true,"secondary_blob_endpoint":true,"secondary_blob_host":true,"secondary_connection_string":true,"secondary_dfs_endpoint":true,"secondary_dfs_host":true,"secondary_file_endpoint":true,"secondary_file_host":true,"secondary_location":true,"secondary_queue_endpoint":true,"secondary_queue_host":true,"secondary_table_endpoint":true,"secondary_table_host":true,"secondary_web_endpoint":true,"secondary_web_host":true,"share_properties":true,"static_website":[]},"before_sensitive":false,"after_sensitive":{"azure_files_authentication":[],"blob_properties":[],"custom_domain":[],"customer_managed_key":[],"identity":[],"immutability_policy":[],"network_rules":[],"primary_access_key":true,"primary_blob_connection_string":true,"primary_connection_string":true,"queue_properties":[],"routing":[],"sas_policy":[],"secondary_access_key":true,"secondary_blob_connection_string":true,"secondary_connection_string":true,"share_properties":[],"static_website":[]}}}],"configuration":{"provider_config":{"azurerm":{"name":"azurerm","full_name":"registry.terraform.io/hashicorp/azurerm","version_constraint":"~\u003e 3.0","expressions":{"features":[{}]}}},"root_module":{"resources":[{"address":"azurerm_resource_group.rg","mode":"managed","type":"azurerm_resource_group","name":"rg","provider_config_key":"azurerm","expressions":{"location":{"constant_value":"westeurope"},"name":{"constant_value":"rg-demo-opa"}},"schema_version":0},{"address":"azurerm_storage_account.storage","mode":"managed","type":"azurerm_storage_account","name":"storage","provider_config_key":"azurerm","expressions":{"account_replication_type":{"constant_value":"GRS"},"account_tier":{"constant_value":"Standard"},"enable_https_traffic_only":{"constant_value":true},"location":{"references":["azurerm_resource_group.rg.location","azurerm_resource_group.rg"]},"name":{"constant_value":"sademotestopa123"},"resource_group_name":{"references":["azurerm_resource_group.rg.name","azurerm_resource_group.rg"]}},"schema_version":3}]}},"relevant_attributes":[{"resource":"azurerm_resource_group.rg","attribute":["location"]},{"resource":"azurerm_resource_group.rg","attribute":["name"]}]}
5 changes: 5 additions & 0 deletions CHAP11/pytest/test_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

@pytest.fixture(scope="session")
def terraform_plan_output():

subprocess.run(["terraform", "init"])
# Run the Terraform plan command to generate the state file
subprocess.run(["terraform", "plan", "-out", "plan.tfout"])

Expand All @@ -15,6 +17,9 @@ def terraform_plan_output():


def test_storage_account_https_only_enabled(terraform_plan_output):


assert terraform_plan_output["format_version"] == "1.1"
# Get the value of the 'enable_https_traffic_only' property
enable_https_traffic_only = terraform_plan_output['resource_changes'][1]['change']['after']['enable_https_traffic_only']

Expand Down
6 changes: 3 additions & 3 deletions CHAP11/tf-compliance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "azurerm_storage_account" "storage" {
account_tier = "Standard"
account_replication_type = "GRS"
enable_https_traffic_only = false #true
tags = {
DEMO = "book"
}
# tags = {
# DEMO = "book"
# }
}
1 change: 1 addition & 0 deletions CHAP11/tf-compliance/out.tfplan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"format_version":"1.1","terraform_version":"1.3.6","planned_values":{"root_module":{"resources":[{"address":"azurerm_resource_group.rg","mode":"managed","type":"azurerm_resource_group","name":"rg","provider_name":"registry.terraform.io/hashicorp/azurerm","schema_version":0,"values":{"location":"westeurope","name":"rg-demo-compliance","tags":null,"timeouts":null},"sensitive_values":{}},{"address":"azurerm_storage_account.storage","mode":"managed","type":"azurerm_storage_account","name":"storage","provider_name":"registry.terraform.io/hashicorp/azurerm","schema_version":3,"values":{"account_kind":"StorageV2","account_replication_type":"GRS","account_tier":"Standard","allow_nested_items_to_be_public":true,"allowed_copy_scope":null,"azure_files_authentication":[],"cross_tenant_replication_enabled":true,"custom_domain":[],"customer_managed_key":[],"default_to_oauth_authentication":false,"edge_zone":null,"enable_https_traffic_only":false,"identity":[],"immutability_policy":[],"infrastructure_encryption_enabled":false,"is_hns_enabled":false,"location":"westeurope","min_tls_version":"TLS1_2","name":"sademotestcomp123","nfsv3_enabled":false,"public_network_access_enabled":true,"queue_encryption_key_type":"Service","resource_group_name":"rg-demo-compliance","sas_policy":[],"sftp_enabled":false,"shared_access_key_enabled":true,"static_website":[],"table_encryption_key_type":"Service","tags":null,"timeouts":null},"sensitive_values":{"azure_files_authentication":[],"blob_properties":[],"custom_domain":[],"customer_managed_key":[],"identity":[],"immutability_policy":[],"network_rules":[],"queue_properties":[],"routing":[],"sas_policy":[],"share_properties":[],"static_website":[]}}]}},"resource_changes":[{"address":"azurerm_resource_group.rg","mode":"managed","type":"azurerm_resource_group","name":"rg","provider_name":"registry.terraform.io/hashicorp/azurerm","change":{"actions":["create"],"before":null,"after":{"location":"westeurope","name":"rg-demo-compliance","tags":null,"timeouts":null},"after_unknown":{"id":true},"before_sensitive":false,"after_sensitive":{}}},{"address":"azurerm_storage_account.storage","mode":"managed","type":"azurerm_storage_account","name":"storage","provider_name":"registry.terraform.io/hashicorp/azurerm","change":{"actions":["create"],"before":null,"after":{"account_kind":"StorageV2","account_replication_type":"GRS","account_tier":"Standard","allow_nested_items_to_be_public":true,"allowed_copy_scope":null,"azure_files_authentication":[],"cross_tenant_replication_enabled":true,"custom_domain":[],"customer_managed_key":[],"default_to_oauth_authentication":false,"edge_zone":null,"enable_https_traffic_only":false,"identity":[],"immutability_policy":[],"infrastructure_encryption_enabled":false,"is_hns_enabled":false,"location":"westeurope","min_tls_version":"TLS1_2","name":"sademotestcomp123","nfsv3_enabled":false,"public_network_access_enabled":true,"queue_encryption_key_type":"Service","resource_group_name":"rg-demo-compliance","sas_policy":[],"sftp_enabled":false,"shared_access_key_enabled":true,"static_website":[],"table_encryption_key_type":"Service","tags":null,"timeouts":null},"after_unknown":{"access_tier":true,"azure_files_authentication":[],"blob_properties":true,"custom_domain":[],"customer_managed_key":[],"id":true,"identity":[],"immutability_policy":[],"large_file_share_enabled":true,"network_rules":true,"primary_access_key":true,"primary_blob_connection_string":true,"primary_blob_endpoint":true,"primary_blob_host":true,"primary_connection_string":true,"primary_dfs_endpoint":true,"primary_dfs_host":true,"primary_file_endpoint":true,"primary_file_host":true,"primary_location":true,"primary_queue_endpoint":true,"primary_queue_host":true,"primary_table_endpoint":true,"primary_table_host":true,"primary_web_endpoint":true,"primary_web_host":true,"queue_properties":true,"routing":true,"sas_policy":[],"secondary_access_key":true,"secondary_blob_connection_string":true,"secondary_blob_endpoint":true,"secondary_blob_host":true,"secondary_connection_string":true,"secondary_dfs_endpoint":true,"secondary_dfs_host":true,"secondary_file_endpoint":true,"secondary_file_host":true,"secondary_location":true,"secondary_queue_endpoint":true,"secondary_queue_host":true,"secondary_table_endpoint":true,"secondary_table_host":true,"secondary_web_endpoint":true,"secondary_web_host":true,"share_properties":true,"static_website":[]},"before_sensitive":false,"after_sensitive":{"azure_files_authentication":[],"blob_properties":[],"custom_domain":[],"customer_managed_key":[],"identity":[],"immutability_policy":[],"network_rules":[],"primary_access_key":true,"primary_blob_connection_string":true,"primary_connection_string":true,"queue_properties":[],"routing":[],"sas_policy":[],"secondary_access_key":true,"secondary_blob_connection_string":true,"secondary_connection_string":true,"share_properties":[],"static_website":[]}}}],"configuration":{"provider_config":{"azurerm":{"name":"azurerm","full_name":"registry.terraform.io/hashicorp/azurerm","version_constraint":"~\u003e 3.0","expressions":{"features":[{}]}}},"root_module":{"resources":[{"address":"azurerm_resource_group.rg","mode":"managed","type":"azurerm_resource_group","name":"rg","provider_config_key":"azurerm","expressions":{"location":{"constant_value":"westeurope"},"name":{"constant_value":"rg-demo-compliance"}},"schema_version":0},{"address":"azurerm_storage_account.storage","mode":"managed","type":"azurerm_storage_account","name":"storage","provider_config_key":"azurerm","expressions":{"account_replication_type":{"constant_value":"GRS"},"account_tier":{"constant_value":"Standard"},"enable_https_traffic_only":{"constant_value":false},"location":{"references":["azurerm_resource_group.rg.location","azurerm_resource_group.rg"]},"name":{"constant_value":"sademotestcomp123"},"resource_group_name":{"references":["azurerm_resource_group.rg.name","azurerm_resource_group.rg"]}},"schema_version":3}]}},"relevant_attributes":[{"resource":"azurerm_resource_group.rg","attribute":["name"]},{"resource":"azurerm_resource_group.rg","attribute":["location"]}]}

0 comments on commit 5c4f4fe

Please sign in to comment.