From 4c7ca8992fde46351c678d04253676f39b6cb58a Mon Sep 17 00:00:00 2001 From: Sathish Date: Wed, 4 Aug 2021 08:53:00 +0530 Subject: [PATCH 01/23] support Bignum and Float for create method Signed-off-by: Sathish --- libraries/azure_backend.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/azure_backend.rb b/libraries/azure_backend.rb index d187ae954..d251c0940 100644 --- a/libraries/azure_backend.rb +++ b/libraries/azure_backend.rb @@ -601,7 +601,7 @@ def create_method(object, name, value) # Create the necessary method based on the var that has been passed # Test the value for its type so that the method can be setup correctly case value.class.to_s - when 'String', 'Integer', 'TrueClass', 'FalseClass', 'Fixnum', 'Time' + when 'String', 'Integer', 'TrueClass', 'FalseClass', 'Fixnum', 'Time', 'Bignum', 'Float' object.define_singleton_method name do value end From e9a20a34496725bd35440504e80f9ceb4bac70f6 Mon Sep 17 00:00:00 2001 From: Sathish Date: Wed, 4 Aug 2021 08:53:23 +0530 Subject: [PATCH 02/23] support azure migrate assessment(s) Signed-off-by: Sathish --- libraries/azure_migrate_assessment.rb | 20 +++++++++++++++++ libraries/azure_migrate_assessments.rb | 31 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 libraries/azure_migrate_assessment.rb create mode 100644 libraries/azure_migrate_assessments.rb diff --git a/libraries/azure_migrate_assessment.rb b/libraries/azure_migrate_assessment.rb new file mode 100644 index 000000000..536d418b7 --- /dev/null +++ b/libraries/azure_migrate_assessment.rb @@ -0,0 +1,20 @@ +require 'azure_generic_resource' + +class AzureMigrateAssessment < AzureGenericResource + name 'azure_migrate_assessment' + desc 'Retrieves and verifies the settings of a container group instance.' + example <<-EXAMPLE + describe azure_migrate_assessment(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: 'zoneA_machines_migrate_assessment') do + it { should exist } + end + EXAMPLE + + def initialize(opts = {}) + raise ArgumentError, 'Parameters must be provided in an Hash object.' unless opts.is_a?(Hash) + + opts[:resource_provider] = specific_resource_constraint('Microsoft.Migrate/assessmentProjects', opts) + opts[:required_parameters] = %i(project_name group_name name) + opts[:resource_path] = [opts[:project_name], 'groups', opts[:group_name], 'assessments'].join('/') + super(opts, true) + end +end diff --git a/libraries/azure_migrate_assessments.rb b/libraries/azure_migrate_assessments.rb new file mode 100644 index 000000000..b6921894d --- /dev/null +++ b/libraries/azure_migrate_assessments.rb @@ -0,0 +1,31 @@ +require 'azure_generic_resources' + +class AzureMigrateAssessments < AzureGenericResources + name 'azure_migrate_assessments' + desc 'Verifies settings for a collection of Azure Migrate Assessments in a project' + example <<-EXAMPLE + describe azure_migrate_assessments(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project') do + it { should exist } + end + EXAMPLE + + def initialize(opts = {}) + raise ArgumentError, 'Parameters must be provided in an Hash object.' unless opts.is_a?(Hash) + opts[:resource_provider] = specific_resource_constraint('Microsoft.Migrate/assessmentProjects', opts) + opts[:required_parameters] = %i(project_name) + opts[:resource_path] = [opts[:project_name], 'assessments'].join('/') + super(opts, true) + return if failed_resource? + + table_schema = @table.first.keys.map { |key| { column: key.to_s.pluralize.to_sym, field: key, style: :simple } } + AzureGenericResources.populate_filter_table(:table, table_schema) + end + + private + + def populate_table + @resources.each do |resource| + @table << resource.merge(resource[:properties]) + end + end +end From 74ae5d7ed34b22b44c78b5cd9a6dc97318ef8556 Mon Sep 17 00:00:00 2001 From: Sathish Date: Wed, 4 Aug 2021 08:53:35 +0530 Subject: [PATCH 03/23] unit test azure migrate assessment(s) Signed-off-by: Sathish --- .../azure_migrate_assessment_test.rb | 17 +++++++++++++++ .../azure_migrate_assessments_test.rb | 21 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/unit/resources/azure_migrate_assessment_test.rb create mode 100644 test/unit/resources/azure_migrate_assessments_test.rb diff --git a/test/unit/resources/azure_migrate_assessment_test.rb b/test/unit/resources/azure_migrate_assessment_test.rb new file mode 100644 index 000000000..3023040c1 --- /dev/null +++ b/test/unit/resources/azure_migrate_assessment_test.rb @@ -0,0 +1,17 @@ +require_relative 'helper' +require 'azure_migrate_assessment' + +class AzureMigrateAssessmentConstructorTest < Minitest::Test + def test_empty_param_not_ok + assert_raises(ArgumentError) { AzureMigrateAssessment.new } + end + + # resource_provider should not be allowed. + def test_resource_provider_not_ok + assert_raises(ArgumentError) { AzureMigrateAssessment.new(resource_provider: 'some_type') } + end + + def test_resource_group_name_alone_ok + assert_raises(ArgumentError) { AzureMigrateAssessment.new(name: 'my-name', resource_group: 'test') } + end +end diff --git a/test/unit/resources/azure_migrate_assessments_test.rb b/test/unit/resources/azure_migrate_assessments_test.rb new file mode 100644 index 000000000..cbbca5b9b --- /dev/null +++ b/test/unit/resources/azure_migrate_assessments_test.rb @@ -0,0 +1,21 @@ +require_relative 'helper' +require 'azure_migrate_assessments' + +class AzureMigrateAssessmentsConstructorTest < Minitest::Test + # resource_type should not be allowed. + def test_resource_type_not_ok + assert_raises(ArgumentError) { AzureMigrateAssessments.new(resource_provider: 'some_type') } + end + + def tag_value_not_ok + assert_raises(ArgumentError) { AzureMigrateAssessments.new(tag_value: 'some_tag_value') } + end + + def tag_name_not_ok + assert_raises(ArgumentError) { AzureMigrateAssessments.new(tag_name: 'some_tag_name') } + end + + def test_name_not_ok + assert_raises(ArgumentError) { AzureMigrateAssessments.new(name: 'some_name') } + end +end From 2bf127717a5c91362c6e6109199179b4686f1734 Mon Sep 17 00:00:00 2001 From: Sathish Date: Wed, 4 Aug 2021 08:53:45 +0530 Subject: [PATCH 04/23] integrate test azure migrate assessment(s) Signed-off-by: Sathish --- .../verify/controls/azure_migrate_assessment.rb | 17 +++++++++++++++++ .../controls/azure_migrate_assessments.rb | 15 +++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/integration/verify/controls/azure_migrate_assessment.rb create mode 100644 test/integration/verify/controls/azure_migrate_assessments.rb diff --git a/test/integration/verify/controls/azure_migrate_assessment.rb b/test/integration/verify/controls/azure_migrate_assessment.rb new file mode 100644 index 000000000..86d809c72 --- /dev/null +++ b/test/integration/verify/controls/azure_migrate_assessment.rb @@ -0,0 +1,17 @@ +resource_group = input(:resource_group, value: '') +project_name = input(:inspec_migrate_project_name, value: '') +# either way these are manual values since there is no terraform resource available +group_name = 'inspec-migrate-test-assement-group' +name = 'inspec-migrate-test-assement' + +control 'verify a azure migrate assessment' do + describe azure_migrate_assessment(resource_group: resource_group, project_name: project_name, group_name: group_name, name: name) do + it { should exist } + its('name') { should eq name } + its('type') { should eq 'Microsoft.Migrate/assessmentprojects/groups/assessments' } + its('properties.azurePricingTier') { should eq 'Standard' } + its('properties.azureStorageRedundancy') { should eq 'LocallyRedundant' } + its('properties.groupType') { should eq 'Import' } + its('properties.scalingFactor') { should eq 1.0 } + end +end diff --git a/test/integration/verify/controls/azure_migrate_assessments.rb b/test/integration/verify/controls/azure_migrate_assessments.rb new file mode 100644 index 000000000..2ab3c33e6 --- /dev/null +++ b/test/integration/verify/controls/azure_migrate_assessments.rb @@ -0,0 +1,15 @@ +resource_group = input(:resource_group, value: '') +project_name = input(:inspec_migrate_project_name, value: '') +name = 'inspec-migrate-test-assement' + +control 'verify all azure migrate assessments in a project' do + describe azure_migrate_assessments(resource_group: resource_group, project_name: project_name) do + it { should exist } + its('names') { should include name } + its('types') { should include 'Microsoft.Migrate/assessmentprojects/groups/assessments' } + its('azurePricingTiers') { should include 'Standard' } + its('azureStorageRedundancies') { should include 'LocallyRedundant' } + its('groupTypes') { should include 'Import' } + its('scalingFactors') { should include 1.0 } + end +end From f1c0d4ec8a9c6ce07efa28f5597d2afa2ec6bf5e Mon Sep 17 00:00:00 2001 From: Sathish Date: Wed, 4 Aug 2021 08:54:07 +0530 Subject: [PATCH 05/23] tf support outputs and variables Signed-off-by: Sathish --- terraform/outputs.tf | 5 +++++ terraform/variables.tf | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/terraform/outputs.tf b/terraform/outputs.tf index 352ccfad0..8e6b81169 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -384,3 +384,8 @@ output "inspec_container_group_name" { description = "the name of the container group" value = azurerm_container_group.inspec_container_trial.name } + +output "inspec_migrate_project_name" { + description = "The name of the Azure Migrate Project that was setup manually since there is no tf resource" + value = var.inspec_migrate_project_name +} \ No newline at end of file diff --git a/terraform/variables.tf b/terraform/variables.tf index df594dba9..64096d3e7 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -145,4 +145,8 @@ variable "inspec_db_migration_service" { variable "inspec_container_group_name" { default = "inspec_container_trial" +} + +variable "inspec_migrate_project_name" { + default = "inspec-migrate-integ117eproject" } \ No newline at end of file From 1a38568f7183d7d7fcc17a3d70a9767c2566501a Mon Sep 17 00:00:00 2001 From: Sathish Date: Wed, 4 Aug 2021 11:20:15 +0530 Subject: [PATCH 06/23] update docs for migrate assessment(s) Signed-off-by: Sathish --- README.md | 2 + docs/resources/azure_migrate_assessment.md | 107 +++++++++++++++++ docs/resources/azure_migrate_assessments.md | 127 ++++++++++++++++++++ 3 files changed, 236 insertions(+) create mode 100644 docs/resources/azure_migrate_assessment.md create mode 100644 docs/resources/azure_migrate_assessments.md diff --git a/README.md b/README.md index 17fde5e20..28fd68ca2 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,8 @@ The following is a list of static resources. - [azure_management_groups](docs/resources/azure_management_groups.md) - [azure_mariadb_server](docs/resources/azure_mariadb_server.md) - [azure_mariadb_servers](docs/resources/azure_mariadb_servers.md) +- [azure_migrate_assessment](docs/resources/azure_migrate_assessment.md) +- [azure_migrate_assessments](docs/resources/azure_migrate_assessments.md) - [azure_monitor_activity_log_alert](docs/resources/azure_monitor_activity_log_alert.md) - [azure_monitor_activity_log_alerts](docs/resources/azure_monitor_activity_log_alerts.md) - [azure_monitor_log_profile](docs/resources/azure_monitor_log_profile.md) diff --git a/docs/resources/azure_migrate_assessment.md b/docs/resources/azure_migrate_assessment.md new file mode 100644 index 000000000..71aa72bc3 --- /dev/null +++ b/docs/resources/azure_migrate_assessment.md @@ -0,0 +1,107 @@ +--- +title: About the azure_migrate_assessment Resource +platform: azure +--- + +# azure_migrate_assessment + +Use the `azure_migrate_assessment` InSpec audit resource to test properties related to an Azure Migrate Assessments. + +## Azure REST API version, endpoint and http client parameters + +This resource interacts with api versions supported by the resource provider. +The `api_version` can be defined as a resource parameter. +If not provided, the latest version will be used. +For more information, refer to [`azure_generic_resource`](azure_generic_resource.md). + +Unless defined, `azure_cloud` global endpoint, and default values for the http client will be used. +For more information, refer to the resource pack [README](../../README.md). + +## Availability + +### Installation + +This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). +For an example `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). + +## Syntax + +`name` is a required parameter and `resource_group` could be provided as an optional parameter. + +```ruby +describe azure_migrate_assessment(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: 'zoneA_machines_migrate_assessment') do + it { should exist } + its('name') { should cmp 'zoneA_machines_migrate_assessment' } + its('type') { should cmp 'Microsoft.Migrate/assessmentprojects/groups/assessments' } +end +``` + +```ruby +describe azure_migrate_assessment(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: 'zoneA_machines_migrate_assessment') do + it { should exist } +end +``` +## Parameters + +| Name | Description | +|----------------|----------------------------------------------------------------------------------| +| name | Name of the Azure Migrate Assessments to test. | +| resource_group | Azure resource group that the targeted resource resides in. `MyResourceGroup` | +| project_name | Azure Migrate Assessment Project. | +| group_name | Unique name of a group within a project. | +| name | Unique name of an assessment within a project. | + +The parameter set should be provided for a valid query: +- `resource_group` and `project_name` and `group_name` and `name` + +## Properties + +| Property | Description | +|-------------------------------|------------------------------------------------------------------| +| id | Path reference to the assessment. | +| name | Unique name of an assessment. | +| type | Type of the object. `Microsoft.Migrate/assessmentProjects/groups/assessments` | +| eTag | For optimistic concurrency control. | +| properties | Properties of the assessment. | +| properties.azureDiskType | Storage type selected for this disk. | +| properties.currency | Currency to report prices in. | +| properties.sizingCriterion | Assessment sizing criterion. | +| properties.reservedInstance | Azure reserved instance. | + + +For properties applicable to all resources, such as `type`, `name`, `id`, `properties`, refer to [`azure_generic_resource`](azure_generic_resource.md#properties). + +Also, refer to [Azure documentation](https://docs.microsoft.com/en-us/rest/api/migrate/assessment/assessments/get) for other properties available. +Any attribute in the response may be accessed with the key names separated by dots (`.`). + +## Examples + +### Test that the Migrate Assessments has a minimum scalingFactor. + +```ruby +describe azure_migrate_assessment(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: 'zoneA_machines_migrate_assessment') do + its('properties.scalingFactor') { should eq 1.0 } +end +``` + +## Matchers + +This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [Universal Matchers page](/inspec/matchers/). + +### exists + +```ruby +# If a Migrate Assessments is found it will exist +describe azure_migrate_assessment(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: 'zoneA_machines_migrate_assessment') do + it { should exist } +end + +# if Migrate Assessments are not found it will not exist +describe azure_migrate_assessment(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: 'zoneA_machines_migrate_assessment') do + it { should_not exist } +end +``` + +## Azure Permissions + +Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be setup with a `contributor` role on the subscription you wish to test. diff --git a/docs/resources/azure_migrate_assessments.md b/docs/resources/azure_migrate_assessments.md new file mode 100644 index 000000000..e2c7bb660 --- /dev/null +++ b/docs/resources/azure_migrate_assessments.md @@ -0,0 +1,127 @@ +--- +title: About the azure_migrate_assessments Resource +platform: azure +--- + +# azure_migrate_assessments + +Use the `azure_migrate_assessments` InSpec audit resource to test properties related to all Azure Migrate Assessments within a project. + +## Azure REST API version, endpoint and http client parameters + +This resource interacts with api versions supported by the resource provider. +The `api_version` can be defined as a resource parameter. +If not provided, the latest version will be used. +For more information, refer to [`azure_generic_resource`](azure_generic_resource.md). + +Unless defined, `azure_cloud` global endpoint, and default values for the http client will be used. +For more information, refer to the resource pack [README](../../README.md). + +## Availability + +### Installation + +This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). +For an example `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). + +## Syntax + +An `azure_migrate_assessments` resource block returns all Azure Migrate Assessments within a project. + +```ruby +describe azure_migrate_assessments(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project') do + #... +end +``` + +## Parameters +| Name | Description | +|----------------|----------------------------------------------------------------------------------| +| resource_group | Azure resource group that the targeted resource resides in. `MyResourceGroup` | +| project_name | Azure Migrate Assessment Project. | + +The parameter set should be provided for a valid query: +- `resource_group` and `project_name` + +## Properties + +|Property | Description | Filter Criteria* | +|--------------------------------|------------------------------------------------------------------------|------------------| +| ids | Path reference to the assessments. | `id` | +| names | Unique names for all assessments. | `name` | +| types | Type of the objects. | `type` | +| eTags | A list of eTags for all the assessments. | `eTag` | +| properties | A list of Properties for all the assessments. | `properties` | +| azureDiskTypes | Storage type selected for the disk of all the assessments. | `azureDiskType` | +| azureHybridUseBenefits | AHUB discount on windows virtual machines of all the assessments. | `azureHybridUseBenefit`| +| azureLocations | Target Azure locations for which the machines should be assessed. | `azureLocation` | +| azureOfferCodes | Offer codes according to which cost estimation is done. | `azureOfferCode` | +| azurePricingTiers | Pricing tiers for Size evaluation. | `azurePricingTier`| +| azureStorageRedundancies | Storage Redundancy types offered by Azure. | `azureStorageRedundancy`| +| azureVmFamilies | List of azure VM families. | `azureVmFamilies`| +| confidenceRatingInPercentages | Confidence rating percentages for assessment. | `confidenceRatingInPercentage`| +| createdTimestamps | Time when this project was created. | `createdTimestamp` | +| currencies | Currencies to report prices in. | `currency` | +| discountPercentages | Custom discount percentages to be applied on final costs. | `discountPercentage`| +| eaSubscriptionIds | Enterprise agreement subscription arm ids. | `eaSubscriptionId`| +| monthlyBandwidthCosts | Monthly network cost estimates for the machines. | `monthlyBandwidthCost`| +| monthlyComputeCosts | Monthly compute cost estimates for the machines. | `monthlyComputeCost`| +| monthlyPremiumStorageCosts | Monthly premium storage cost estimates for the machines. | `monthlyPremiumStorageCost`| +| monthlyStandardSSDStorageCosts | Monthly standard SSD storage cost estimates for the machines. | `monthlyStandardSSDStorageCost`| +| monthlyStorageCosts | Monthly storage cost estimates for the machines. | `monthlyStorageCost` | +| numberOfMachines | Number of assessed machines part of the assessments. | `numberOfMachines` | +| percentiles | Percentiles of performance data used to recommend Azure size. | `percentile` | +| perfDataEndTimes | End times to consider performance data for assessments. | `perfDataEndTime` | +| perfDataStartTimes | Start times to consider performance data for assessments. | `perfDataStartTime` | +| pricesTimestamps | Times when the Azure Prices were queried. | `pricesTimestamp` | +| reservedInstances | Azure reserved instances. | `reservedInstance` +| scalingFactors | Scaling factors used over utilization data to add a performance buffer for new machines to be created in Azure.| `scalingFactor` | +| sizingCriterions | Assessment sizing criterions. | `sizingCriterion` | +| stages | User configurable setting that describes the status of the assessments.| `stage` | +| statuses | Whether the assessments has been created and is valid. | `status` | +| timeRanges | Time ranges of performance data used to recommend a size. | `timeRange` | +| updatedTimestamps | Times when the project was last updated. | `updatedTimestamp`| +| vmUptimes | Specify the durations for which the VMs are up in the on-premises environment.| `vmUptime` | + + +* For information on how to use filter criteria on plural resources refer to [FilterTable usage](https://github.com/inspec/inspec/blob/master/dev-docs/filtertable-usage.md). + +## Examples + +### Loop through Migrate Assessments by their names. + +```ruby +azure_migrate_assessments(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project').names.each do |name| + describe azure_container_group(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: name) do + it { should exist } + end +end +``` +### Test that there are Migrate Assessments with local redundancy. + +```ruby +describe azure_migrate_assessments(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project').where(azureStorageRedundancy: 'LocallyRedundant') do + it { should exist } +end +``` + +## Matchers + +This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [Universal Matchers page](https://www.inspec.io/docs/reference/matchers/). + +### exists + +```ruby +# Should not exist if no Migrate Assessments are present in the project and in the resource group +describe azure_migrate_assessments(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project') do + it { should_not exist } +end + +# Should exist if the filter returns at least one Migrate Assessment in the project and in the resource group +describe azure_migrate_assessments(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project') do + it { should exist } +end +``` +## Azure Permissions + +Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be setup with a `contributor` role on the subscription you wish to test. \ No newline at end of file From 1363fbff9e60c9fc894160facdf3425157a05716 Mon Sep 17 00:00:00 2001 From: Sathish Date: Thu, 19 Aug 2021 13:44:54 +0530 Subject: [PATCH 07/23] fix azure tf Signed-off-by: Sathish --- terraform/azure.tf | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/terraform/azure.tf b/terraform/azure.tf index b96d26b69..813d6bb66 100644 --- a/terraform/azure.tf +++ b/terraform/azure.tf @@ -1338,15 +1338,17 @@ resource "azurerm_policy_assignment" "inspec_compliance_policy_assignment" { } PARAMETERS } + resource "azurerm_bastion_host" "abh" { - name = "test_bastion" - location = azurerm_resource_group.rg.location + name = "test_bastion" + location = azurerm_resource_group.rg.location resource_group_name = azurerm_resource_group.rg.name ip_configuration { - name = "configuration" - subnet_id = azurerm_subnet.subnet.id + name = "configuration" + subnet_id = azurerm_subnet.subnet.id public_ip_address_id = azurerm_public_ip.public_ip_address.id } +} resource "azurerm_dns_zone" "example-public" { name = "mydomain_example.com" From 5ab1e6100568166767e0938a80fcf29e3b1ed8c1 Mon Sep 17 00:00:00 2001 From: Sathish Date: Thu, 19 Aug 2021 13:45:13 +0530 Subject: [PATCH 08/23] implement to_s Signed-off-by: Sathish --- libraries/azure_migrate_assessment.rb | 4 ++++ libraries/azure_migrate_assessments.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libraries/azure_migrate_assessment.rb b/libraries/azure_migrate_assessment.rb index 536d418b7..79ffb62be 100644 --- a/libraries/azure_migrate_assessment.rb +++ b/libraries/azure_migrate_assessment.rb @@ -17,4 +17,8 @@ def initialize(opts = {}) opts[:resource_path] = [opts[:project_name], 'groups', opts[:group_name], 'assessments'].join('/') super(opts, true) end + + def to_s + super(AzureMigrateAssessment) + end end diff --git a/libraries/azure_migrate_assessments.rb b/libraries/azure_migrate_assessments.rb index b6921894d..15f9f059a 100644 --- a/libraries/azure_migrate_assessments.rb +++ b/libraries/azure_migrate_assessments.rb @@ -21,6 +21,10 @@ def initialize(opts = {}) AzureGenericResources.populate_filter_table(:table, table_schema) end + def to_s + super(AzureMigrateAssessments) + end + private def populate_table From 40c81f86756d83673e25f3e2790199000afcdef1 Mon Sep 17 00:00:00 2001 From: Sathish Date: Thu, 19 Aug 2021 13:45:23 +0530 Subject: [PATCH 09/23] use populate tabel from response Signed-off-by: Sathish --- libraries/azure_migrate_assessments.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/azure_migrate_assessments.rb b/libraries/azure_migrate_assessments.rb index 15f9f059a..b53a8e704 100644 --- a/libraries/azure_migrate_assessments.rb +++ b/libraries/azure_migrate_assessments.rb @@ -17,8 +17,7 @@ def initialize(opts = {}) super(opts, true) return if failed_resource? - table_schema = @table.first.keys.map { |key| { column: key.to_s.pluralize.to_sym, field: key, style: :simple } } - AzureGenericResources.populate_filter_table(:table, table_schema) + populate_filter_table_from_response end def to_s From 892221b834f5c34d5ab1b31fdce4fcdeba2a2430 Mon Sep 17 00:00:00 2001 From: Sathish Date: Thu, 19 Aug 2021 13:45:40 +0530 Subject: [PATCH 10/23] update docs Signed-off-by: Sathish --- docs/resources/azure_migrate_assessment.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/resources/azure_migrate_assessment.md b/docs/resources/azure_migrate_assessment.md index 71aa72bc3..49e122207 100644 --- a/docs/resources/azure_migrate_assessment.md +++ b/docs/resources/azure_migrate_assessment.md @@ -45,11 +45,10 @@ end | Name | Description | |----------------|----------------------------------------------------------------------------------| -| name | Name of the Azure Migrate Assessments to test. | +| name | Name of the Azure Migrate Assessment to test. | | resource_group | Azure resource group that the targeted resource resides in. `MyResourceGroup` | | project_name | Azure Migrate Assessment Project. | | group_name | Unique name of a group within a project. | -| name | Unique name of an assessment within a project. | The parameter set should be provided for a valid query: - `resource_group` and `project_name` and `group_name` and `name` From 1f6adf57b1e93b8df47845e33a0194d11e788f6e Mon Sep 17 00:00:00 2001 From: Deepa Kumaraswamy Date: Thu, 9 Sep 2021 17:42:13 +0530 Subject: [PATCH 11/23] edits Signed-off-by: Deepa Kumaraswamy --- docs/resources/azure_generic_resource.md | 2 +- docs/resources/azure_migrate_assessment.md | 50 ++++++++++----------- docs/resources/azure_migrate_assessments.md | 44 +++++++++--------- 3 files changed, 45 insertions(+), 51 deletions(-) diff --git a/docs/resources/azure_generic_resource.md b/docs/resources/azure_generic_resource.md index 976b647fb..c2a493482 100644 --- a/docs/resources/azure_generic_resource.md +++ b/docs/resources/azure_generic_resource.md @@ -31,7 +31,7 @@ where The following parameters can be passed for targeting a specific Azure resource. -| Name | Description | +| Name |Description | |--------------------------------------|----------------------------------------------------------------------------------------------------------| | resource_group | Azure resource group that the targeted resource has been created in. `MyResourceGroup` | | name | Name of the Azure resource to test. `MyResourceName` | diff --git a/docs/resources/azure_migrate_assessment.md b/docs/resources/azure_migrate_assessment.md index 49e122207..e206e4ac6 100644 --- a/docs/resources/azure_migrate_assessment.md +++ b/docs/resources/azure_migrate_assessment.md @@ -5,52 +5,50 @@ platform: azure # azure_migrate_assessment -Use the `azure_migrate_assessment` InSpec audit resource to test properties related to an Azure Migrate Assessments. +Use the `azure_migrate_assessment` InSpec audit resource to test the properties related to Azure Migrate Assessments. -## Azure REST API version, endpoint and http client parameters +## Azure REST API version, Endpoint, and HTTP Client Parameters -This resource interacts with api versions supported by the resource provider. -The `api_version` can be defined as a resource parameter. -If not provided, the latest version will be used. -For more information, refer to [`azure_generic_resource`](azure_generic_resource.md). +This resource interacts with API versions supported by the resource provider. The `api_version` is defined as a resource parameter. +If not provided, the latest version is used. For more information, refer to [`azure_generic_resource`](azure_generic_resource.md). -Unless defined, `azure_cloud` global endpoint, and default values for the http client will be used. -For more information, refer to the resource pack [README](../../README.md). +Unless defined, `azure_cloud` global endpoint and default values for the HTTP client are used. For more information, refer to the resource pack [README](../../README.md). ## Availability ### Installation -This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). -For an example `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). +This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). For an example, `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). ## Syntax -`name` is a required parameter and `resource_group` could be provided as an optional parameter. +`name` is a required parameter, and `resource_group` is an optional parameter. ```ruby -describe azure_migrate_assessment(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: 'zoneA_machines_migrate_assessment') do +describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', NAME: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do it { should exist } - its('name') { should cmp 'zoneA_machines_migrate_assessment' } + its('name') { should cmp 'ZONEA_MACHINES_MIGRATE_ASSESSMENT' } its('type') { should cmp 'Microsoft.Migrate/assessmentprojects/groups/assessments' } end ``` ```ruby -describe azure_migrate_assessment(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: 'zoneA_machines_migrate_assessment') do +describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', name: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do it { should exist } end ``` + ## Parameters | Name | Description | |----------------|----------------------------------------------------------------------------------| | name | Name of the Azure Migrate Assessment to test. | -| resource_group | Azure resource group that the targeted resource resides in. `MyResourceGroup` | +| resource_group | Azure resource group where the targeted resource resides in. `MyResourceGroup` | | project_name | Azure Migrate Assessment Project. | | group_name | Unique name of a group within a project. | The parameter set should be provided for a valid query: + - `resource_group` and `project_name` and `group_name` and `name` ## Properties @@ -59,7 +57,7 @@ The parameter set should be provided for a valid query: |-------------------------------|------------------------------------------------------------------| | id | Path reference to the assessment. | | name | Unique name of an assessment. | -| type | Type of the object. `Microsoft.Migrate/assessmentProjects/groups/assessments` | +| type | Object type. `Microsoft.Migrate/assessmentProjects/groups/assessments` | | eTag | For optimistic concurrency control. | | properties | Properties of the assessment. | | properties.azureDiskType | Storage type selected for this disk. | @@ -67,18 +65,16 @@ The parameter set should be provided for a valid query: | properties.sizingCriterion | Assessment sizing criterion. | | properties.reservedInstance | Azure reserved instance. | +For properties applicable to all resources, such as `type`, `name`, `id`, and `properties`, refer to [`azure_generic_resource`](azure_generic_resource.md#properties). -For properties applicable to all resources, such as `type`, `name`, `id`, `properties`, refer to [`azure_generic_resource`](azure_generic_resource.md#properties). - -Also, refer to [Azure documentation](https://docs.microsoft.com/en-us/rest/api/migrate/assessment/assessments/get) for other properties available. -Any attribute in the response may be accessed with the key names separated by dots (`.`). +Also, refer to [Azure documentation](https://docs.microsoft.com/en-us/rest/api/migrate/assessment/assessments/get) for other properties available. Any attribute in the response is accessed with the key names separated by dots (`.`). ## Examples -### Test that the Migrate Assessments has a minimum scalingFactor. +### Test that the Migrate Assessments has a minimum scalingFactor ```ruby -describe azure_migrate_assessment(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: 'zoneA_machines_migrate_assessment') do +describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', name: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do its('properties.scalingFactor') { should eq 1.0 } end ``` @@ -90,17 +86,17 @@ This InSpec audit resource has the following special matchers. For a full list o ### exists ```ruby -# If a Migrate Assessments is found it will exist -describe azure_migrate_assessment(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: 'zoneA_machines_migrate_assessment') do +# If a Migrate Assessments is found, it will exist +describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', name: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do it { should exist } end -# if Migrate Assessments are not found it will not exist -describe azure_migrate_assessment(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: 'zoneA_machines_migrate_assessment') do +# if Migrate Assessments are not found, it will not exist +describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'zONEA_MACHINES_GROUP', name: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do it { should_not exist } end ``` ## Azure Permissions -Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be setup with a `contributor` role on the subscription you wish to test. +Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be set up with a `contributor` role on the subscription you wish to test. diff --git a/docs/resources/azure_migrate_assessments.md b/docs/resources/azure_migrate_assessments.md index e2c7bb660..1609cabdf 100644 --- a/docs/resources/azure_migrate_assessments.md +++ b/docs/resources/azure_migrate_assessments.md @@ -5,31 +5,27 @@ platform: azure # azure_migrate_assessments -Use the `azure_migrate_assessments` InSpec audit resource to test properties related to all Azure Migrate Assessments within a project. +Use the `azure_migrate_assessments` InSpec audit resource to test the properties related to all Azure Migrate Assessments within a project. -## Azure REST API version, endpoint and http client parameters +## Azure REST API version, Endpoint, and HTTP Client Parameters -This resource interacts with api versions supported by the resource provider. -The `api_version` can be defined as a resource parameter. -If not provided, the latest version will be used. -For more information, refer to [`azure_generic_resource`](azure_generic_resource.md). +This resource interacts with API versions supported by the resource provider. The `api_version` is defined as a resource parameter. +If not provided, the latest version is used. For more information, refer to [`azure_generic_resource`](azure_generic_resource.md). -Unless defined, `azure_cloud` global endpoint, and default values for the http client will be used. -For more information, refer to the resource pack [README](../../README.md). +Unless defined, `azure_cloud` global endpoint and default values for the HTTP client is used. For more information, refer to the resource pack [README](../../README.md). ## Availability ### Installation -This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). -For an example `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). +This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). For an example, `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). ## Syntax An `azure_migrate_assessments` resource block returns all Azure Migrate Assessments within a project. ```ruby -describe azure_migrate_assessments(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project') do +describe azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT') do #... end ``` @@ -60,7 +56,7 @@ The parameter set should be provided for a valid query: | azureStorageRedundancies | Storage Redundancy types offered by Azure. | `azureStorageRedundancy`| | azureVmFamilies | List of azure VM families. | `azureVmFamilies`| | confidenceRatingInPercentages | Confidence rating percentages for assessment. | `confidenceRatingInPercentage`| -| createdTimestamps | Time when this project was created. | `createdTimestamp` | +| createdTimestamps | Time when this project is created. | `createdTimestamp` | | currencies | Currencies to report prices in. | `currency` | | discountPercentages | Custom discount percentages to be applied on final costs. | `discountPercentage`| | eaSubscriptionIds | Enterprise agreement subscription arm ids. | `eaSubscriptionId`| @@ -73,14 +69,14 @@ The parameter set should be provided for a valid query: | percentiles | Percentiles of performance data used to recommend Azure size. | `percentile` | | perfDataEndTimes | End times to consider performance data for assessments. | `perfDataEndTime` | | perfDataStartTimes | Start times to consider performance data for assessments. | `perfDataStartTime` | -| pricesTimestamps | Times when the Azure Prices were queried. | `pricesTimestamp` | +| pricesTimestamps | Times when the Azure Prices are queried. | `pricesTimestamp` | | reservedInstances | Azure reserved instances. | `reservedInstance` | scalingFactors | Scaling factors used over utilization data to add a performance buffer for new machines to be created in Azure.| `scalingFactor` | | sizingCriterions | Assessment sizing criterions. | `sizingCriterion` | | stages | User configurable setting that describes the status of the assessments.| `stage` | -| statuses | Whether the assessments has been created and is valid. | `status` | +| statuses | Whether the assessments have been created and is valid. | `status` | | timeRanges | Time ranges of performance data used to recommend a size. | `timeRange` | -| updatedTimestamps | Times when the project was last updated. | `updatedTimestamp`| +| updatedTimestamps | Times when the project is last updated. | `updatedTimestamp`| | vmUptimes | Specify the durations for which the VMs are up in the on-premises environment.| `vmUptime` | @@ -88,19 +84,20 @@ The parameter set should be provided for a valid query: ## Examples -### Loop through Migrate Assessments by their names. +### Loop through Migrate Assessments by their names ```ruby -azure_migrate_assessments(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project').names.each do |name| - describe azure_container_group(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', group_name: 'zoneA_machines_group', name: name) do +azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT').names.each do |name| + describe azure_container_group(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', name: name) do it { should exist } end end ``` -### Test that there are Migrate Assessments with local redundancy. + +### Test to ensure Migrate Assessments with local redundancy ```ruby -describe azure_migrate_assessments(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project').where(azureStorageRedundancy: 'LocallyRedundant') do +describe azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT').where(azureStorageRedundancy: 'LOCALLYREDUNDANT') do it { should exist } end ``` @@ -113,15 +110,16 @@ This InSpec audit resource has the following special matchers. For a full list o ```ruby # Should not exist if no Migrate Assessments are present in the project and in the resource group -describe azure_migrate_assessments(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project') do +describe azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT') do it { should_not exist } end # Should exist if the filter returns at least one Migrate Assessment in the project and in the resource group -describe azure_migrate_assessments(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project') do +describe azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT') do it { should exist } end ``` + ## Azure Permissions -Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be setup with a `contributor` role on the subscription you wish to test. \ No newline at end of file +Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be set up with a `contributor` role on the subscription you wish to test. From ee421e1b6f5a09d87fa79b61b7ba973136881e5a Mon Sep 17 00:00:00 2001 From: Sathish Date: Mon, 13 Sep 2021 11:25:17 +0530 Subject: [PATCH 12/23] fix required params doc Signed-off-by: Sathish --- docs/resources/azure_migrate_assessment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/azure_migrate_assessment.md b/docs/resources/azure_migrate_assessment.md index e206e4ac6..fe1fd4383 100644 --- a/docs/resources/azure_migrate_assessment.md +++ b/docs/resources/azure_migrate_assessment.md @@ -22,7 +22,7 @@ This resource is available in the [InSpec Azure resource pack](https://github.co ## Syntax -`name` is a required parameter, and `resource_group` is an optional parameter. +`name`, `resource_group`, `project_name` & `group_name` is a required parameter. ```ruby describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', NAME: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do From d14856f8f5a83dfbc0b05a1ff36c6e8d364c8ffd Mon Sep 17 00:00:00 2001 From: Sathish Babu <80091550+sathish-progress@users.noreply.github.com> Date: Mon, 13 Sep 2021 11:26:48 +0530 Subject: [PATCH 13/23] Update docs/resources/azure_migrate_assessment.md Co-authored-by: Ian Maddaus --- docs/resources/azure_migrate_assessment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/azure_migrate_assessment.md b/docs/resources/azure_migrate_assessment.md index fe1fd4383..273cf31bc 100644 --- a/docs/resources/azure_migrate_assessment.md +++ b/docs/resources/azure_migrate_assessment.md @@ -67,7 +67,7 @@ The parameter set should be provided for a valid query: For properties applicable to all resources, such as `type`, `name`, `id`, and `properties`, refer to [`azure_generic_resource`](azure_generic_resource.md#properties). -Also, refer to [Azure documentation](https://docs.microsoft.com/en-us/rest/api/migrate/assessment/assessments/get) for other properties available. Any attribute in the response is accessed with the key names separated by dots (`.`). +Refer to the [Azure documentation](https://docs.microsoft.com/en-us/rest/api/migrate/assessment/assessments/get) for a full list of available properties. Access any attribute in the response by separating the key names with a period (`.`). ## Examples From a267ecd1f60313ebd68224518643b550153d9c3b Mon Sep 17 00:00:00 2001 From: Sathish Babu <80091550+sathish-progress@users.noreply.github.com> Date: Mon, 13 Sep 2021 11:26:56 +0530 Subject: [PATCH 14/23] Update docs/resources/azure_migrate_assessment.md Co-authored-by: Ian Maddaus --- docs/resources/azure_migrate_assessment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/azure_migrate_assessment.md b/docs/resources/azure_migrate_assessment.md index 273cf31bc..f519caed7 100644 --- a/docs/resources/azure_migrate_assessment.md +++ b/docs/resources/azure_migrate_assessment.md @@ -71,7 +71,7 @@ Refer to the [Azure documentation](https://docs.microsoft.com/en-us/rest/api/mig ## Examples -### Test that the Migrate Assessments has a minimum scalingFactor +### Test that the Migrate Assessments has a minimum scaling factor ```ruby describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', name: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do From d27c5b62545057b50431a2b069f61e8ebc1af7d1 Mon Sep 17 00:00:00 2001 From: Sathish Babu <80091550+sathish-progress@users.noreply.github.com> Date: Mon, 13 Sep 2021 11:27:08 +0530 Subject: [PATCH 15/23] Update docs/resources/azure_migrate_assessments.md Co-authored-by: Ian Maddaus --- docs/resources/azure_migrate_assessments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/azure_migrate_assessments.md b/docs/resources/azure_migrate_assessments.md index 1609cabdf..1e58ee0c3 100644 --- a/docs/resources/azure_migrate_assessments.md +++ b/docs/resources/azure_migrate_assessments.md @@ -79,7 +79,7 @@ The parameter set should be provided for a valid query: | updatedTimestamps | Times when the project is last updated. | `updatedTimestamp`| | vmUptimes | Specify the durations for which the VMs are up in the on-premises environment.| `vmUptime` | - +Refer to the [Azure Migrate assements documentation](https://docs.microsoft.com/en-us/rest/api/migrate/assessment/assessments/get) for additional information. * For information on how to use filter criteria on plural resources refer to [FilterTable usage](https://github.com/inspec/inspec/blob/master/dev-docs/filtertable-usage.md). ## Examples From c78f077abc3eeffa5ec5d74c94d83323db5a2548 Mon Sep 17 00:00:00 2001 From: Sathish Babu <80091550+sathish-progress@users.noreply.github.com> Date: Mon, 13 Sep 2021 11:27:28 +0530 Subject: [PATCH 16/23] Update docs/resources/azure_migrate_assessments.md Co-authored-by: Ian Maddaus --- docs/resources/azure_migrate_assessments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/azure_migrate_assessments.md b/docs/resources/azure_migrate_assessments.md index 1e58ee0c3..35f33e7df 100644 --- a/docs/resources/azure_migrate_assessments.md +++ b/docs/resources/azure_migrate_assessments.md @@ -94,7 +94,7 @@ azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_M end ``` -### Test to ensure Migrate Assessments with local redundancy +### Test to ensure Migrate assessments exist with local redundancy ```ruby describe azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT').where(azureStorageRedundancy: 'LOCALLYREDUNDANT') do From 04cec9837c832bc218a48d4342fcbf4160bd0000 Mon Sep 17 00:00:00 2001 From: Sathish Date: Mon, 13 Sep 2021 11:29:51 +0530 Subject: [PATCH 17/23] fix docs link Signed-off-by: Sathish --- docs/resources/azure_migrate_assessments.md | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/resources/azure_migrate_assessments.md b/docs/resources/azure_migrate_assessments.md index 35f33e7df..bd412d7dd 100644 --- a/docs/resources/azure_migrate_assessments.md +++ b/docs/resources/azure_migrate_assessments.md @@ -50,13 +50,13 @@ The parameter set should be provided for a valid query: | properties | A list of Properties for all the assessments. | `properties` | | azureDiskTypes | Storage type selected for the disk of all the assessments. | `azureDiskType` | | azureHybridUseBenefits | AHUB discount on windows virtual machines of all the assessments. | `azureHybridUseBenefit`| -| azureLocations | Target Azure locations for which the machines should be assessed. | `azureLocation` | +| azureLocations | Target Azure locations for which the machines should be assessed. | `azureLocation` | | azureOfferCodes | Offer codes according to which cost estimation is done. | `azureOfferCode` | | azurePricingTiers | Pricing tiers for Size evaluation. | `azurePricingTier`| | azureStorageRedundancies | Storage Redundancy types offered by Azure. | `azureStorageRedundancy`| | azureVmFamilies | List of azure VM families. | `azureVmFamilies`| | confidenceRatingInPercentages | Confidence rating percentages for assessment. | `confidenceRatingInPercentage`| -| createdTimestamps | Time when this project is created. | `createdTimestamp` | +| createdTimestamps | Time when this project is created. | `createdTimestamp` | | currencies | Currencies to report prices in. | `currency` | | discountPercentages | Custom discount percentages to be applied on final costs. | `discountPercentage`| | eaSubscriptionIds | Enterprise agreement subscription arm ids. | `eaSubscriptionId`| @@ -66,20 +66,20 @@ The parameter set should be provided for a valid query: | monthlyStandardSSDStorageCosts | Monthly standard SSD storage cost estimates for the machines. | `monthlyStandardSSDStorageCost`| | monthlyStorageCosts | Monthly storage cost estimates for the machines. | `monthlyStorageCost` | | numberOfMachines | Number of assessed machines part of the assessments. | `numberOfMachines` | -| percentiles | Percentiles of performance data used to recommend Azure size. | `percentile` | -| perfDataEndTimes | End times to consider performance data for assessments. | `perfDataEndTime` | +| percentiles | Percentiles of performance data used to recommend Azure size. | `percentile` | +| perfDataEndTimes | End times to consider performance data for assessments. | `perfDataEndTime`| | perfDataStartTimes | Start times to consider performance data for assessments. | `perfDataStartTime` | -| pricesTimestamps | Times when the Azure Prices are queried. | `pricesTimestamp` | -| reservedInstances | Azure reserved instances. | `reservedInstance` +| pricesTimestamps | Times when the Azure Prices are queried. | `pricesTimestamp`| +| reservedInstances | Azure reserved instances. | `reservedInstance`| | scalingFactors | Scaling factors used over utilization data to add a performance buffer for new machines to be created in Azure.| `scalingFactor` | -| sizingCriterions | Assessment sizing criterions. | `sizingCriterion` | -| stages | User configurable setting that describes the status of the assessments.| `stage` | -| statuses | Whether the assessments have been created and is valid. | `status` | -| timeRanges | Time ranges of performance data used to recommend a size. | `timeRange` | -| updatedTimestamps | Times when the project is last updated. | `updatedTimestamp`| -| vmUptimes | Specify the durations for which the VMs are up in the on-premises environment.| `vmUptime` | - -Refer to the [Azure Migrate assements documentation](https://docs.microsoft.com/en-us/rest/api/migrate/assessment/assessments/get) for additional information. +| sizingCriterions | Assessment sizing criterions. | `sizingCriterion`| +| stages | User configurable setting that describes the status of the assessments.| `stage` | +| statuses | Whether the assessments have been created and is valid. | `status` | +| timeRanges | Time ranges of performance data used to recommend a size. | `timeRange` | +| updatedTimestamps | Times when the project is last updated. | `updatedTimestamp`| +| vmUptimes | Specify the durations for which the VMs are up in the on-premises environment.| `vmUptime`| + +Refer to the [Azure Migrate assements documentation](https://docs.microsoft.com/en-us/rest/api/migrate/assessment/assessments/list-by-project) for additional information. * For information on how to use filter criteria on plural resources refer to [FilterTable usage](https://github.com/inspec/inspec/blob/master/dev-docs/filtertable-usage.md). ## Examples From 74e8f7b837247762c9c7baee17d198440c396919 Mon Sep 17 00:00:00 2001 From: Deepa Kumaraswamy Date: Mon, 13 Sep 2021 19:48:52 +0530 Subject: [PATCH 18/23] Ian's comments --- docs/resources/azure_generic_resource.md | 49 +++++--- docs/resources/azure_migrate_assessment.md | 28 ++--- docs/resources/azure_migrate_assessments.md | 90 +++++++-------- .../azure_migrate_project_database.md | 105 ++++++++++++++++++ 4 files changed, 196 insertions(+), 76 deletions(-) create mode 100644 docs/resources/azure_migrate_project_database.md diff --git a/docs/resources/azure_generic_resource.md b/docs/resources/azure_generic_resource.md index c2a493482..ba27c1586 100644 --- a/docs/resources/azure_generic_resource.md +++ b/docs/resources/azure_generic_resource.md @@ -5,18 +5,18 @@ platform: azure # azure_generic_resource -Use the `azure_generic_resource` Inspec audit resource to test any valid Azure resource available through Azure Resource Manager. +Use the `azure_generic_resource` Inspec audit resource to test any valid Azure resource available through Azure Resource Manager. ## Availability ### Installation -This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). -For an example `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). +This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). For an example, `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). ## Syntax + ```ruby -describe azure_generic_resource(resource_group: 'MyResourceGroup', name: 'MyResource') do +describe azure_generic_resource(resource_group: 'MYRESOURCEGROUP', name: 'MYRESOURCE') do its('property') { should eq 'value' } end ``` @@ -47,6 +47,7 @@ The following parameters can be passed for targeting a specific Azure resource. * When resources are filtered by a tag name and value, the tags for each resource are not returned in the results. Either one of the parameter sets can be provided for a valid query: + - `resource_id` - `resource_group` and `name` - `name` @@ -57,12 +58,11 @@ Either one of the parameter sets can be provided for a valid query: Different parameter combinations can be tried. If it is not supported, either the InSpec resource or the Azure Rest API will raise an error. -If the Azure Resource Manager endpoint returns multiple resources for a given query, this singular generic resource will fail. In that case, the [plural generic resource](azure_generic_resources.md) should be used. +If the Azure Resource Manager endpoint returns multiple resources for a given query, this singular generic resource will fail. In that case, the [plural generic resource](azure_generic_resources.md) should be used. ## Properties -The properties that can be tested are dependent on the Azure Resource that is tested. One way to see what properties can be tested is checking their API pages. For example for virtual machines, see [here](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/get). -Also the [Azure Resources Portal](https://resources.azure.com) can be used to select the resource you are interested in and see what can be tested. +The properties that can be tested are dependent on the Azure Resource that is tested. One way to see what properties can be tested is checking their API pages. For example for virtual machines, see [here](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/get). Also the [Azure Resources Portal](https://resources.azure.com) can be used to select the resource you are interested in and see what can be tested. The following properties are applicable to almost all resources. @@ -80,55 +80,67 @@ For more properties, refer to specific Azure documents for the resource being te ## Examples ### Test Properties of a Virtual Machine and the Endpoint API Version + ```ruby -describe azure_generic_resource(resource_group: 'my_vms', name: 'my_linux_vm') do +describe azure_generic_resource(resource_group: 'MY_VMS', name: 'MY_LINUX_VM') do its('properties.storageProfile.osDisk.osType') { should cmp 'Linux' } its('properties.storageProfile.osDisk.createOption') { should cmp 'FromImage' } its('properties.storageProfile.osDisk.name') { should cmp 'linux-external-osdisk' } its('properties.storageProfile.osDisk.caching') { should cmp 'ReadWrite' } - + its('api_version_used_for_query_state') { should eq 'latest' } end ``` + ### Test the API Version Used for the Query + ```ruby describe azure_generic_resource(resource_id: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}', api_version: '2017-01-01') do its('api_version_used_for_query_state') { should eq 'user_provided' } its('api_version_used_for_query') { should eq '2017-01-01' } end ``` + ### Test the Tags if Include Specific Values + ```ruby -describe azure_generic_resource(resource_group: 'my_vms', name: 'my_linux_vm') do +describe azure_generic_resource(resource_group: 'MY_VMS', name: 'MY_LINUX_VM') do its('tags') { should include(name: 'MyVM') } # The tag key name can be tested in String or Symbol. its('tags') { should include(:name) } # regardless of the value its('tags') { should include('name') } # regardless of the value end ``` -### Test Properties of a Virtual Machine Resides in an Azure Dev Test Lab + +### Test Properties of a Virtual Machine Resides in an Azure Dev Test Lab + ```ruby -describe azure_generic_resource(resource_provider: 'Microsoft.DevTestLab/labs', resource_path: '{labName}/virtualmachines', resource_group: 'my_group', name: 'my_VM') do +describe azure_generic_resource(resource_provider: 'Microsoft.DevTestLab/labs', resource_path: '{labName}/virtualmachines', resource_group: 'MY_GROUP', name: 'MY_VM') do its('properties.userName') { should cmp 'admin' } its('properties.allowClaim') { should cmp false } end ``` -### Test a Resource Group + +### Test a Resource Group + ```ruby -describe azure_generic_resource(add_subscription_id: true, resource_uri: '/resourcegroups/', name: 'my_group') do +describe azure_generic_resource(add_subscription_id: true, resource_uri: '/resourcegroups/', name: 'MY_GROUP') do it { should exist } its('tags') { should include(:owner) } its('tags') { should include(owner: 'John Doe') } end ``` + ### Test a Policy Definition + ```ruby -describe azure_generic_resource(add_subscription_id: true, resource_uri: 'providers/Microsoft.Authorization/policyDefinitions', name: 'my_policy') do +describe azure_generic_resource(add_subscription_id: true, resource_uri: 'providers/Microsoft.Authorization/policyDefinitions', name: 'MY_POLICY') do it { should exist } its('properties.policyRule.then.effect') { should cmp 'deny' } its('properties.policyType') { should cmp 'Custom' } end ``` + For more examples, please see the [integration tests](/test/integration/verify/controls/azure_generic_resource.rb). ## Matchers @@ -136,18 +148,21 @@ For more examples, please see the [integration tests](/test/integration/verify/c This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [Universal Matchers page](https://www.inspec.io/docs/reference/matchers/). ### exist + ```ruby # Should not exist if there is no resource with a given name -describe azure_generic_resource(name: 'fake_name') do +describe azure_generic_resource(name: 'FAKE_NAME') do it { should_not exist } end ``` + ```ruby # Should exist if there is one resource with a given name -describe azure_generic_resource(name: 'a_very_unique_name_within_subscription') do +describe azure_generic_resource(name: 'A_VERY_UNIQUE_NAME_WITHIN_SUBSCRIPTION') do it { should exist } end ``` + ## Azure Permissions Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be setup with a `contributor` role on the subscription you wish to test. diff --git a/docs/resources/azure_migrate_assessment.md b/docs/resources/azure_migrate_assessment.md index f519caed7..fb62ad219 100644 --- a/docs/resources/azure_migrate_assessment.md +++ b/docs/resources/azure_migrate_assessment.md @@ -5,7 +5,7 @@ platform: azure # azure_migrate_assessment -Use the `azure_migrate_assessment` InSpec audit resource to test the properties related to Azure Migrate Assessments. +Use the `azure_migrate_assessment` InSpec audit resource to test the properties related to Azure Migrate assessment. ## Azure REST API version, Endpoint, and HTTP Client Parameters @@ -22,18 +22,18 @@ This resource is available in the [InSpec Azure resource pack](https://github.co ## Syntax -`name`, `resource_group`, `project_name` & `group_name` is a required parameter. +`name`, `resource_group`, `project_name`, and `group_name` are required parameters. ```ruby -describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', NAME: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do +describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ZONEA_ASSESSMENT_NAME') do it { should exist } - its('name') { should cmp 'ZONEA_MACHINES_MIGRATE_ASSESSMENT' } + its('name') { should cmp 'ZONEA_ASSESSMENT_NAME' } its('type') { should cmp 'Microsoft.Migrate/assessmentprojects/groups/assessments' } end ``` ```ruby -describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', name: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do +describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ZONEA_ASSESSMENT_NAME') do it { should exist } end ``` @@ -42,14 +42,14 @@ end | Name | Description | |----------------|----------------------------------------------------------------------------------| -| name | Name of the Azure Migrate Assessment to test. | -| resource_group | Azure resource group where the targeted resource resides in. `MyResourceGroup` | -| project_name | Azure Migrate Assessment Project. | +| name | Name of the Azure Migrate assessment to test. | +| resource_group | Azure resource group where the targeted resource resides in. | +| project_name | Azure Migrate assessment project. | | group_name | Unique name of a group within a project. | The parameter set should be provided for a valid query: -- `resource_group` and `project_name` and `group_name` and `name` +- `resource_group`, `project_name`, `group_name`, and `name`. ## Properties @@ -57,7 +57,7 @@ The parameter set should be provided for a valid query: |-------------------------------|------------------------------------------------------------------| | id | Path reference to the assessment. | | name | Unique name of an assessment. | -| type | Object type. `Microsoft.Migrate/assessmentProjects/groups/assessments` | +| type | Object type. | | eTag | For optimistic concurrency control. | | properties | Properties of the assessment. | | properties.azureDiskType | Storage type selected for this disk. | @@ -71,10 +71,10 @@ Refer to the [Azure documentation](https://docs.microsoft.com/en-us/rest/api/mig ## Examples -### Test that the Migrate Assessments has a minimum scaling factor +### Test that the migrate assessments has a minimum scaling factor ```ruby -describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', name: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do +describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ZONEA_ASSESSMENT_NAME') do its('properties.scalingFactor') { should eq 1.0 } end ``` @@ -87,12 +87,12 @@ This InSpec audit resource has the following special matchers. For a full list o ```ruby # If a Migrate Assessments is found, it will exist -describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', name: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do +describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ZONEA_ASSESSMENT_NAME') do it { should exist } end # if Migrate Assessments are not found, it will not exist -describe azure_migrate_assessment(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'zONEA_MACHINES_GROUP', name: 'ZONEA_MACHINES_MIGRATE_ASSESSMENT') do +describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ZONEA_ASSESSMENT_NAME') do it { should_not exist } end ``` diff --git a/docs/resources/azure_migrate_assessments.md b/docs/resources/azure_migrate_assessments.md index bd412d7dd..4a2dff4d4 100644 --- a/docs/resources/azure_migrate_assessments.md +++ b/docs/resources/azure_migrate_assessments.md @@ -5,7 +5,7 @@ platform: azure # azure_migrate_assessments -Use the `azure_migrate_assessments` InSpec audit resource to test the properties related to all Azure Migrate Assessments within a project. +Use the `azure_migrate_assessments` InSpec audit resource to test the properties related to all Azure Migrate assessments within a project. ## Azure REST API version, Endpoint, and HTTP Client Parameters @@ -22,10 +22,10 @@ This resource is available in the [InSpec Azure resource pack](https://github.co ## Syntax -An `azure_migrate_assessments` resource block returns all Azure Migrate Assessments within a project. +An `azure_migrate_assessments` resource block returns all Azure Migrate assessments within a project. ```ruby -describe azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT') do +describe azure_migrate_assessments(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME') do #... end ``` @@ -33,8 +33,8 @@ end ## Parameters | Name | Description | |----------------|----------------------------------------------------------------------------------| -| resource_group | Azure resource group that the targeted resource resides in. `MyResourceGroup` | -| project_name | Azure Migrate Assessment Project. | +| resource_group | Azure resource group that the targeted resource resides in. | +| project_name | Azure Migrate assessments project name. | The parameter set should be provided for a valid query: - `resource_group` and `project_name` @@ -42,62 +42,62 @@ The parameter set should be provided for a valid query: ## Properties |Property | Description | Filter Criteria* | -|--------------------------------|------------------------------------------------------------------------|------------------| -| ids | Path reference to the assessments. | `id` | -| names | Unique names for all assessments. | `name` | -| types | Type of the objects. | `type` | -| eTags | A list of eTags for all the assessments. | `eTag` | -| properties | A list of Properties for all the assessments. | `properties` | -| azureDiskTypes | Storage type selected for the disk of all the assessments. | `azureDiskType` | -| azureHybridUseBenefits | AHUB discount on windows virtual machines of all the assessments. | `azureHybridUseBenefit`| -| azureLocations | Target Azure locations for which the machines should be assessed. | `azureLocation` | -| azureOfferCodes | Offer codes according to which cost estimation is done. | `azureOfferCode` | -| azurePricingTiers | Pricing tiers for Size evaluation. | `azurePricingTier`| +|--------------------------------|------------------------------------------------------------------------|-------------------------| +| ids | Path reference to the assessments. | `id` | +| names | Unique names for all assessments. | `name` | +| types | Type of the objects. | `type` | +| eTags | A list of eTags for all the assessments. | `eTag` | +| properties | A list of Properties for all the assessments. | `properties` | +| azureDiskTypes | Storage type selected for the disk of all the assessments. | `azureDiskType` | +| azureHybridUseBenefits | AHUB discount on windows virtual machines of all the assessments. | `azureHybridUseBenefit` | +| azureLocations | Target Azure locations for which the machines should be assessed. | `azureLocation` | +| azureOfferCodes | Offer codes according to which cost estimation is done. | `azureOfferCode` | +| azurePricingTiers | Pricing tiers for Size evaluation. | `azurePricingTier` | | azureStorageRedundancies | Storage Redundancy types offered by Azure. | `azureStorageRedundancy`| -| azureVmFamilies | List of azure VM families. | `azureVmFamilies`| +| azureVmFamilies | List of azure VM families. | `azureVmFamilies` | | confidenceRatingInPercentages | Confidence rating percentages for assessment. | `confidenceRatingInPercentage`| -| createdTimestamps | Time when this project is created. | `createdTimestamp` | -| currencies | Currencies to report prices in. | `currency` | -| discountPercentages | Custom discount percentages to be applied on final costs. | `discountPercentage`| -| eaSubscriptionIds | Enterprise agreement subscription arm ids. | `eaSubscriptionId`| -| monthlyBandwidthCosts | Monthly network cost estimates for the machines. | `monthlyBandwidthCost`| -| monthlyComputeCosts | Monthly compute cost estimates for the machines. | `monthlyComputeCost`| +| createdTimestamps | Time when this project is created. | `createdTimestamp` | +| currencies | Currencies to report prices in. | `currency` | +| discountPercentages | Custom discount percentages to be applied on final costs. | `discountPercentage` | +| eaSubscriptionIds | Enterprise agreement subscription arm ids. | `eaSubscriptionId` | +| monthlyBandwidthCosts | Monthly network cost estimates for the machines. | `monthlyBandwidthCost` | +| monthlyComputeCosts | Monthly compute cost estimates for the machines. | `monthlyComputeCost` | | monthlyPremiumStorageCosts | Monthly premium storage cost estimates for the machines. | `monthlyPremiumStorageCost`| | monthlyStandardSSDStorageCosts | Monthly standard SSD storage cost estimates for the machines. | `monthlyStandardSSDStorageCost`| -| monthlyStorageCosts | Monthly storage cost estimates for the machines. | `monthlyStorageCost` | -| numberOfMachines | Number of assessed machines part of the assessments. | `numberOfMachines` | -| percentiles | Percentiles of performance data used to recommend Azure size. | `percentile` | -| perfDataEndTimes | End times to consider performance data for assessments. | `perfDataEndTime`| -| perfDataStartTimes | Start times to consider performance data for assessments. | `perfDataStartTime` | -| pricesTimestamps | Times when the Azure Prices are queried. | `pricesTimestamp`| -| reservedInstances | Azure reserved instances. | `reservedInstance`| +| monthlyStorageCosts | Monthly storage cost estimates for the machines. | `monthlyStorageCost` | +| numberOfMachines | Number of assessed machines part of the assessments. | `numberOfMachines` | +| percentiles | Percentiles of performance data used to recommend Azure size. | `percentile` | +| perfDataEndTimes | End times to consider performance data for assessments. | `perfDataEndTime` | +| perfDataStartTimes | Start times to consider performance data for assessments. | `perfDataStartTime` | +| pricesTimestamps | Times when the Azure Prices are queried. | `pricesTimestamp` | +| reservedInstances | Azure reserved instances. | `reservedInstance` | | scalingFactors | Scaling factors used over utilization data to add a performance buffer for new machines to be created in Azure.| `scalingFactor` | -| sizingCriterions | Assessment sizing criterions. | `sizingCriterion`| -| stages | User configurable setting that describes the status of the assessments.| `stage` | -| statuses | Whether the assessments have been created and is valid. | `status` | -| timeRanges | Time ranges of performance data used to recommend a size. | `timeRange` | -| updatedTimestamps | Times when the project is last updated. | `updatedTimestamp`| -| vmUptimes | Specify the durations for which the VMs are up in the on-premises environment.| `vmUptime`| - -Refer to the [Azure Migrate assements documentation](https://docs.microsoft.com/en-us/rest/api/migrate/assessment/assessments/list-by-project) for additional information. +| sizingCriterions | Assessment sizing criterions. | `sizingCriterion` | +| stages | User configurable setting that describes the status of the assessments.| `stage` | +| statuses | Whether the assessments have been created and is valid. | `status` | +| timeRanges | Time ranges of performance data used to recommend a size. | `timeRange` | +| updatedTimestamps | Times when the project is last updated. | `updatedTimestamp` | +| vmUptimes | Specify the durations for which the VMs are up in the on-premises environment.| `vmUptime` | + +Refer to the [Azure Migrate assements documentation](https://docs.microsoft.com/en-us/rest/api/migrate/assessment/assessments/list-by-project) for additional information. * For information on how to use filter criteria on plural resources refer to [FilterTable usage](https://github.com/inspec/inspec/blob/master/dev-docs/filtertable-usage.md). ## Examples -### Loop through Migrate Assessments by their names +### Loop through migrate assessments by their names ```ruby -azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT').names.each do |name| - describe azure_container_group(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', group_name: 'ZONEA_MACHINES_GROUP', name: name) do +azure_migrate_assessments(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME'.names.each do |name| + describe azure_container_group (resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', name: name) do it { should exist } end end ``` -### Test to ensure Migrate assessments exist with local redundancy +### Test to ensure migrate assessments exist with local redundancy ```ruby -describe azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT').where(azureStorageRedundancy: 'LOCALLYREDUNDANT') do +describe azure_migrate_assessments(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME').where(azureStorageRedundancy: 'LOCALLYREDUNDANT') do it { should exist } end ``` @@ -110,12 +110,12 @@ This InSpec audit resource has the following special matchers. For a full list o ```ruby # Should not exist if no Migrate Assessments are present in the project and in the resource group -describe azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT') do +describe azure_migrate_assessments(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME') do it { should_not exist } end # Should exist if the filter returns at least one Migrate Assessment in the project and in the resource group -describe azure_migrate_assessments(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT') do +describe azure_migrate_assessments(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME') do it { should exist } end ``` diff --git a/docs/resources/azure_migrate_project_database.md b/docs/resources/azure_migrate_project_database.md new file mode 100644 index 000000000..521fdcb3f --- /dev/null +++ b/docs/resources/azure_migrate_project_database.md @@ -0,0 +1,105 @@ +--- +title: About the azure_migrate_project_database Resource +platform: azure +--- + +# azure_migrate_project_database + +Use the `azure_migrate_project_database` InSpec audit resource to test the properties related to an Azure Migrate Project Database. + +## Azure REST API version, Endpoint, and HTTP Client Parameters + +This resource interacts with API versions supported by the resource provider. The `api_version` is defined as a resource parameter. +If not provided, the latest version is used. For more information, refer to [`azure_generic_resource`](azure_generic_resource.md). + +Unless defined, `azure_cloud` global endpoint and default values for the HTTP client is used. For more information, refer to the resource pack [README](../../README.md). + +## Availability + +### Installation + +This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). For an example, `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). + +## Syntax + +`name` is a required parameter and `resource_group` is an optional parameter. + +```ruby +describe azure_migrate_project_database(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', name: 'SQL_DB') do + it { should exist } + its('name') { should eq 'SQL_DB' } + its('type') { should eq 'Microsoft.Migrate/MigrateProjects/Databases' } + its('solutionNames') { should include 'MIGRATEDBSOLUTION' } +end +``` + +```ruby +describe azure_migrate_project_database(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', name: 'SQL_DB') do + it { should exist } +end +``` + +## Parameters + +| Name | Description | +|----------------|----------------------------------------------------------------------------------| +| name | Name of the Azure Migrate Project Database to test. | +| resource_group | Azure resource group that the targeted resource resides in. `MyResourceGroup` | +| project_name | Azure Migrate Assessment Project. | + +The parameter set should be provided for a valid query: + +- `resource_group` and `project_name` and `name` + +## Properties + +| Property | Description | +|-------------------------------|------------------------------------------------------------------| +| id | Path reference to the Migrate Project Database. | +| name | Unique name of a Migrate Project Database. | +| type | Type of the object. `Microsoft.Migrate/MigrateProjects/Databases`| +| properties | Properties of the assessment. | +| properties.assessmentData | Assessment details of the database published by various sources. | +| assessmentIds | The database assessment scope/Ids. | +| migrationBlockersCounts | The number of blocking changes found. | +| breakingChangesCounts | The number of breaking changes found. | +| assessmentTargetTypes | The assessed target database types. | +| solutionNames | The names of the solutions that sent the data. | +| instanceIds | The database servers' instance Ids. | +| databaseNames | The name of the databases. | + +For properties applicable to all resources, such as `type`, `name`, `id`, and `properties`, refer to [`azure_generic_resource`](azure_generic_resource.md#properties). + +Also, refer to [Azure documentation](https://docs.microsoft.com/en-us/rest/api/migrate/projects/databases/get-database) for other properties available. Any attribute in the response nested within properties is accessed with the key names separated by dots (`.`) and attributes nested in the assessmentData are pluralized and listed as a collection. + +## Examples + +### Test that Migrate Project Database has a SQL assessmentTargetType + +```ruby +describe azure_migrate_project_database(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', name: 'SQL_DB') do + its('assessmentTargetTypes') { should include 'SQL' } +end +``` + +## Matchers + +This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [Universal Matchers page](/inspec/matchers/). + +### exists + +```ruby +# If a Migrate Project Database is found, it will exist +describe azure_migrate_project_database(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', name: 'SQL_DB') do + it { should exist } +end + +# if Migrate Project Database is not found, it will not exist +describe azure_migrate_project_database(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', name: 'SQL_DB') do + it { should_not exist } +end +``` + +## Azure Permissions + +Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be set up with a `contributor` role on the subscription you wish to test. From e523c4295ae6e62651e8ac74bc778be34fb0f4f0 Mon Sep 17 00:00:00 2001 From: Deepa Kumaraswamy Date: Wed, 15 Sep 2021 20:19:24 +0530 Subject: [PATCH 19/23] title case changes --- docs/resources/azure_migrate_assessments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/azure_migrate_assessments.md b/docs/resources/azure_migrate_assessments.md index 4a2dff4d4..2e1c0225c 100644 --- a/docs/resources/azure_migrate_assessments.md +++ b/docs/resources/azure_migrate_assessments.md @@ -97,7 +97,7 @@ end ### Test to ensure migrate assessments exist with local redundancy ```ruby -describe azure_migrate_assessments(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME').where(azureStorageRedundancy: 'LOCALLYREDUNDANT') do +describe azure_migrate_assessments(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME').where(azureStorageRedundancy: 'LocallyRedundant') do it { should exist } end ``` From e80007a9f6d3e322940345e82dbf1d136c403db1 Mon Sep 17 00:00:00 2001 From: Deepa Kumaraswamy Date: Fri, 17 Sep 2021 12:28:54 +0530 Subject: [PATCH 20/23] removing changes to azure_migrate_project_database.md file Signed-off-by: Deepa Kumaraswamy --- docs/resources/azure_generic_resource.md | 51 +++++++++--------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/docs/resources/azure_generic_resource.md b/docs/resources/azure_generic_resource.md index ba27c1586..976b647fb 100644 --- a/docs/resources/azure_generic_resource.md +++ b/docs/resources/azure_generic_resource.md @@ -5,18 +5,18 @@ platform: azure # azure_generic_resource -Use the `azure_generic_resource` Inspec audit resource to test any valid Azure resource available through Azure Resource Manager. +Use the `azure_generic_resource` Inspec audit resource to test any valid Azure resource available through Azure Resource Manager. ## Availability ### Installation -This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). For an example, `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). +This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). +For an example `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). ## Syntax - ```ruby -describe azure_generic_resource(resource_group: 'MYRESOURCEGROUP', name: 'MYRESOURCE') do +describe azure_generic_resource(resource_group: 'MyResourceGroup', name: 'MyResource') do its('property') { should eq 'value' } end ``` @@ -31,7 +31,7 @@ where The following parameters can be passed for targeting a specific Azure resource. -| Name |Description | +| Name | Description | |--------------------------------------|----------------------------------------------------------------------------------------------------------| | resource_group | Azure resource group that the targeted resource has been created in. `MyResourceGroup` | | name | Name of the Azure resource to test. `MyResourceName` | @@ -47,7 +47,6 @@ The following parameters can be passed for targeting a specific Azure resource. * When resources are filtered by a tag name and value, the tags for each resource are not returned in the results. Either one of the parameter sets can be provided for a valid query: - - `resource_id` - `resource_group` and `name` - `name` @@ -58,11 +57,12 @@ Either one of the parameter sets can be provided for a valid query: Different parameter combinations can be tried. If it is not supported, either the InSpec resource or the Azure Rest API will raise an error. -If the Azure Resource Manager endpoint returns multiple resources for a given query, this singular generic resource will fail. In that case, the [plural generic resource](azure_generic_resources.md) should be used. +If the Azure Resource Manager endpoint returns multiple resources for a given query, this singular generic resource will fail. In that case, the [plural generic resource](azure_generic_resources.md) should be used. ## Properties -The properties that can be tested are dependent on the Azure Resource that is tested. One way to see what properties can be tested is checking their API pages. For example for virtual machines, see [here](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/get). Also the [Azure Resources Portal](https://resources.azure.com) can be used to select the resource you are interested in and see what can be tested. +The properties that can be tested are dependent on the Azure Resource that is tested. One way to see what properties can be tested is checking their API pages. For example for virtual machines, see [here](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/get). +Also the [Azure Resources Portal](https://resources.azure.com) can be used to select the resource you are interested in and see what can be tested. The following properties are applicable to almost all resources. @@ -80,67 +80,55 @@ For more properties, refer to specific Azure documents for the resource being te ## Examples ### Test Properties of a Virtual Machine and the Endpoint API Version - ```ruby -describe azure_generic_resource(resource_group: 'MY_VMS', name: 'MY_LINUX_VM') do +describe azure_generic_resource(resource_group: 'my_vms', name: 'my_linux_vm') do its('properties.storageProfile.osDisk.osType') { should cmp 'Linux' } its('properties.storageProfile.osDisk.createOption') { should cmp 'FromImage' } its('properties.storageProfile.osDisk.name') { should cmp 'linux-external-osdisk' } its('properties.storageProfile.osDisk.caching') { should cmp 'ReadWrite' } - + its('api_version_used_for_query_state') { should eq 'latest' } end ``` - ### Test the API Version Used for the Query - ```ruby describe azure_generic_resource(resource_id: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}', api_version: '2017-01-01') do its('api_version_used_for_query_state') { should eq 'user_provided' } its('api_version_used_for_query') { should eq '2017-01-01' } end ``` - ### Test the Tags if Include Specific Values - ```ruby -describe azure_generic_resource(resource_group: 'MY_VMS', name: 'MY_LINUX_VM') do +describe azure_generic_resource(resource_group: 'my_vms', name: 'my_linux_vm') do its('tags') { should include(name: 'MyVM') } # The tag key name can be tested in String or Symbol. its('tags') { should include(:name) } # regardless of the value its('tags') { should include('name') } # regardless of the value end ``` - -### Test Properties of a Virtual Machine Resides in an Azure Dev Test Lab - +### Test Properties of a Virtual Machine Resides in an Azure Dev Test Lab ```ruby -describe azure_generic_resource(resource_provider: 'Microsoft.DevTestLab/labs', resource_path: '{labName}/virtualmachines', resource_group: 'MY_GROUP', name: 'MY_VM') do +describe azure_generic_resource(resource_provider: 'Microsoft.DevTestLab/labs', resource_path: '{labName}/virtualmachines', resource_group: 'my_group', name: 'my_VM') do its('properties.userName') { should cmp 'admin' } its('properties.allowClaim') { should cmp false } end ``` - -### Test a Resource Group - +### Test a Resource Group ```ruby -describe azure_generic_resource(add_subscription_id: true, resource_uri: '/resourcegroups/', name: 'MY_GROUP') do +describe azure_generic_resource(add_subscription_id: true, resource_uri: '/resourcegroups/', name: 'my_group') do it { should exist } its('tags') { should include(:owner) } its('tags') { should include(owner: 'John Doe') } end ``` - ### Test a Policy Definition - ```ruby -describe azure_generic_resource(add_subscription_id: true, resource_uri: 'providers/Microsoft.Authorization/policyDefinitions', name: 'MY_POLICY') do +describe azure_generic_resource(add_subscription_id: true, resource_uri: 'providers/Microsoft.Authorization/policyDefinitions', name: 'my_policy') do it { should exist } its('properties.policyRule.then.effect') { should cmp 'deny' } its('properties.policyType') { should cmp 'Custom' } end ``` - For more examples, please see the [integration tests](/test/integration/verify/controls/azure_generic_resource.rb). ## Matchers @@ -148,21 +136,18 @@ For more examples, please see the [integration tests](/test/integration/verify/c This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [Universal Matchers page](https://www.inspec.io/docs/reference/matchers/). ### exist - ```ruby # Should not exist if there is no resource with a given name -describe azure_generic_resource(name: 'FAKE_NAME') do +describe azure_generic_resource(name: 'fake_name') do it { should_not exist } end ``` - ```ruby # Should exist if there is one resource with a given name -describe azure_generic_resource(name: 'A_VERY_UNIQUE_NAME_WITHIN_SUBSCRIPTION') do +describe azure_generic_resource(name: 'a_very_unique_name_within_subscription') do it { should exist } end ``` - ## Azure Permissions Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be setup with a `contributor` role on the subscription you wish to test. From 7a963a0dd90827cacacc4cd7997472eb6f264349 Mon Sep 17 00:00:00 2001 From: Deepa Kumaraswamy Date: Fri, 17 Sep 2021 12:44:15 +0530 Subject: [PATCH 21/23] removed unwanted changes from project db file Signed-off-by: Deepa Kumaraswamy --- docs/resources/azure_migrate_project_database.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/azure_migrate_project_database.md b/docs/resources/azure_migrate_project_database.md index 521fdcb3f..1f998e2b0 100644 --- a/docs/resources/azure_migrate_project_database.md +++ b/docs/resources/azure_migrate_project_database.md @@ -90,12 +90,12 @@ This InSpec audit resource has the following special matchers. For a full list o ```ruby # If a Migrate Project Database is found, it will exist -describe azure_migrate_project_database(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', name: 'SQL_DB') do +describe azure_migrate_project_database(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', name: 'sql_db') do it { should exist } end # if Migrate Project Database is not found, it will not exist -describe azure_migrate_project_database(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', name: 'SQL_DB') do +describe azure_migrate_project_database(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', name: 'sql_db') do it { should_not exist } end ``` From a600d5d2b247cba3d39cd3f0b977441abc8b2ce6 Mon Sep 17 00:00:00 2001 From: Deepa Kumaraswamy Date: Mon, 20 Sep 2021 15:04:36 +0530 Subject: [PATCH 22/23] removing changes made to docs/resources/azure_migrate_project_database.md Signed-off-by: Deepa Kumaraswamy --- .../azure_migrate_project_database.md | 105 ------------------ 1 file changed, 105 deletions(-) delete mode 100644 docs/resources/azure_migrate_project_database.md diff --git a/docs/resources/azure_migrate_project_database.md b/docs/resources/azure_migrate_project_database.md deleted file mode 100644 index 1f998e2b0..000000000 --- a/docs/resources/azure_migrate_project_database.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -title: About the azure_migrate_project_database Resource -platform: azure ---- - -# azure_migrate_project_database - -Use the `azure_migrate_project_database` InSpec audit resource to test the properties related to an Azure Migrate Project Database. - -## Azure REST API version, Endpoint, and HTTP Client Parameters - -This resource interacts with API versions supported by the resource provider. The `api_version` is defined as a resource parameter. -If not provided, the latest version is used. For more information, refer to [`azure_generic_resource`](azure_generic_resource.md). - -Unless defined, `azure_cloud` global endpoint and default values for the HTTP client is used. For more information, refer to the resource pack [README](../../README.md). - -## Availability - -### Installation - -This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). For an example, `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). - -## Syntax - -`name` is a required parameter and `resource_group` is an optional parameter. - -```ruby -describe azure_migrate_project_database(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', name: 'SQL_DB') do - it { should exist } - its('name') { should eq 'SQL_DB' } - its('type') { should eq 'Microsoft.Migrate/MigrateProjects/Databases' } - its('solutionNames') { should include 'MIGRATEDBSOLUTION' } -end -``` - -```ruby -describe azure_migrate_project_database(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', name: 'SQL_DB') do - it { should exist } -end -``` - -## Parameters - -| Name | Description | -|----------------|----------------------------------------------------------------------------------| -| name | Name of the Azure Migrate Project Database to test. | -| resource_group | Azure resource group that the targeted resource resides in. `MyResourceGroup` | -| project_name | Azure Migrate Assessment Project. | - -The parameter set should be provided for a valid query: - -- `resource_group` and `project_name` and `name` - -## Properties - -| Property | Description | -|-------------------------------|------------------------------------------------------------------| -| id | Path reference to the Migrate Project Database. | -| name | Unique name of a Migrate Project Database. | -| type | Type of the object. `Microsoft.Migrate/MigrateProjects/Databases`| -| properties | Properties of the assessment. | -| properties.assessmentData | Assessment details of the database published by various sources. | -| assessmentIds | The database assessment scope/Ids. | -| migrationBlockersCounts | The number of blocking changes found. | -| breakingChangesCounts | The number of breaking changes found. | -| assessmentTargetTypes | The assessed target database types. | -| solutionNames | The names of the solutions that sent the data. | -| instanceIds | The database servers' instance Ids. | -| databaseNames | The name of the databases. | - -For properties applicable to all resources, such as `type`, `name`, `id`, and `properties`, refer to [`azure_generic_resource`](azure_generic_resource.md#properties). - -Also, refer to [Azure documentation](https://docs.microsoft.com/en-us/rest/api/migrate/projects/databases/get-database) for other properties available. Any attribute in the response nested within properties is accessed with the key names separated by dots (`.`) and attributes nested in the assessmentData are pluralized and listed as a collection. - -## Examples - -### Test that Migrate Project Database has a SQL assessmentTargetType - -```ruby -describe azure_migrate_project_database(resource_group: 'MIGRATED_VMS', project_name: 'ZONEA_MIGRATE_ASSESSMENT_PROJECT', name: 'SQL_DB') do - its('assessmentTargetTypes') { should include 'SQL' } -end -``` - -## Matchers - -This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [Universal Matchers page](/inspec/matchers/). - -### exists - -```ruby -# If a Migrate Project Database is found, it will exist -describe azure_migrate_project_database(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', name: 'sql_db') do - it { should exist } -end - -# if Migrate Project Database is not found, it will not exist -describe azure_migrate_project_database(resource_group: 'migrated_vms', project_name: 'zoneA_migrate_assessment_project', name: 'sql_db') do - it { should_not exist } -end -``` - -## Azure Permissions - -Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be set up with a `contributor` role on the subscription you wish to test. From 81f2d51094f3dc466cb0ea038a68245be2be2fd8 Mon Sep 17 00:00:00 2001 From: Deepa Kumaraswamy Date: Wed, 22 Sep 2021 22:03:40 +0530 Subject: [PATCH 23/23] user defined name changes Signed-off-by: Deepa Kumaraswamy --- docs/resources/azure_migrate_assessment.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/resources/azure_migrate_assessment.md b/docs/resources/azure_migrate_assessment.md index fb62ad219..7e1b715a3 100644 --- a/docs/resources/azure_migrate_assessment.md +++ b/docs/resources/azure_migrate_assessment.md @@ -25,15 +25,15 @@ This resource is available in the [InSpec Azure resource pack](https://github.co `name`, `resource_group`, `project_name`, and `group_name` are required parameters. ```ruby -describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ZONEA_ASSESSMENT_NAME') do +describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ASSESSMENT_NAME') do it { should exist } - its('name') { should cmp 'ZONEA_ASSESSMENT_NAME' } + its('name') { should cmp 'ASSESSMENT_NAME' } its('type') { should cmp 'Microsoft.Migrate/assessmentprojects/groups/assessments' } end ``` ```ruby -describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ZONEA_ASSESSMENT_NAME') do +describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ASSESSMENT_NAME') do it { should exist } end ``` @@ -74,7 +74,7 @@ Refer to the [Azure documentation](https://docs.microsoft.com/en-us/rest/api/mig ### Test that the migrate assessments has a minimum scaling factor ```ruby -describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ZONEA_ASSESSMENT_NAME') do +describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ASSESSMENT_NAME') do its('properties.scalingFactor') { should eq 1.0 } end ``` @@ -87,12 +87,12 @@ This InSpec audit resource has the following special matchers. For a full list o ```ruby # If a Migrate Assessments is found, it will exist -describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ZONEA_ASSESSMENT_NAME') do +describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ASSESSMENT_NAME') do it { should exist } end # if Migrate Assessments are not found, it will not exist -describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ZONEA_ASSESSMENT_NAME') do +describe azure_migrate_assessment(resource_group: 'RESOURCE_GROUP', project_name: 'PROJECT_NAME', group_name: 'GROUP_NAME', NAME: 'ASSESSMENT_NAME') do it { should_not exist } end ```