From e0da9d39877a0fde29d42ef9efc5f1629c211d3c Mon Sep 17 00:00:00 2001 From: Sathish Date: Tue, 14 Dec 2021 00:42:21 +0530 Subject: [PATCH 1/6] support service fabric mesh services (s) Signed-off-by: Sathish --- .../azure_service_fabric_mesh_service.rb | 23 ++++++++++++ .../azure_service_fabric_mesh_services.rb | 35 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 libraries/azure_service_fabric_mesh_service.rb create mode 100644 libraries/azure_service_fabric_mesh_services.rb diff --git a/libraries/azure_service_fabric_mesh_service.rb b/libraries/azure_service_fabric_mesh_service.rb new file mode 100644 index 000000000..961b4e112 --- /dev/null +++ b/libraries/azure_service_fabric_mesh_service.rb @@ -0,0 +1,23 @@ +require 'azure_generic_resource' + +class AzureServiceFabricMeshService < AzureGenericResource + name 'azure_service_fabric_mesh_service' + desc 'Retrieves and verifies the settings of an Azure Service Fabric Mesh Service.' + example <<-EXAMPLE + describe azure_service_fabric_mesh_service(application_name: 'fabric-svc', name: 'svc') 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.ServiceFabricMesh/applications', opts) + opts[:resource_path] = [opts[:application_name], 'services'].join('/') + super(opts, true) + end + + def to_s + super(AzureServiceFabricMeshService) + end +end diff --git a/libraries/azure_service_fabric_mesh_services.rb b/libraries/azure_service_fabric_mesh_services.rb new file mode 100644 index 000000000..9672c8a44 --- /dev/null +++ b/libraries/azure_service_fabric_mesh_services.rb @@ -0,0 +1,35 @@ +require 'azure_generic_resources' + +class AzureServiceFabricMeshServices < AzureGenericResources + name 'azure_service_fabric_mesh_services' + desc 'Verifies settings for a collection of Azure Service Fabric Mesh Services' + example <<-EXAMPLE + describe azure_service_fabric_mesh_services(application_name: 'fabric-svc') 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.ServiceFabricMesh/applications', opts) + opts[:resource_path] = [opts[:application_name], 'services'].join('/') + super(opts, true) + return if failed_resource? + + populate_filter_table_from_response + end + + def to_s + super(AzureServiceFabricMeshServices) + end + + private + + def populate_table + @resources.each do |resource| + resource = resource.merge(resource[:properties]) + @table << resource.merge(resource[:codePackages]).merge(resource[:networkRefs]) + end + end +end From 0701d0377c25865f47a6244605931f4f506b06f2 Mon Sep 17 00:00:00 2001 From: Sathish Date: Tue, 14 Dec 2021 00:43:18 +0530 Subject: [PATCH 2/6] unit test service fabric mesh services (s) Signed-off-by: Sathish --- .../azure_service_fabric_mesh_service_test.rb | 17 +++++++++++++++ ...azure_service_fabric_mesh_services_test.rb | 21 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/unit/resources/azure_service_fabric_mesh_service_test.rb create mode 100644 test/unit/resources/azure_service_fabric_mesh_services_test.rb diff --git a/test/unit/resources/azure_service_fabric_mesh_service_test.rb b/test/unit/resources/azure_service_fabric_mesh_service_test.rb new file mode 100644 index 000000000..cd1a20b73 --- /dev/null +++ b/test/unit/resources/azure_service_fabric_mesh_service_test.rb @@ -0,0 +1,17 @@ +require_relative 'helper' +require 'azure_service_fabric_mesh_service' + +class AzureServiceFabricMeshServiceConstructorTest < Minitest::Test + def test_empty_param_not_ok + assert_raises(ArgumentError) { AzureServiceFabricMeshService.new } + end + + # resource_provider should not be allowed. + def test_resource_provider_not_ok + assert_raises(ArgumentError) { AzureServiceFabricMeshService.new(resource_provider: 'some_type') } + end + + def test_resource_group_name_alone_not_ok + assert_raises(ArgumentError) { AzureServiceFabricMeshService.new(resource_group: 'test') } + end +end diff --git a/test/unit/resources/azure_service_fabric_mesh_services_test.rb b/test/unit/resources/azure_service_fabric_mesh_services_test.rb new file mode 100644 index 000000000..27918aa9a --- /dev/null +++ b/test/unit/resources/azure_service_fabric_mesh_services_test.rb @@ -0,0 +1,21 @@ +require_relative 'helper' +require 'azure_service_fabric_mesh_services' + +class AzureServiceFabricMeshServicesConstructorTest < Minitest::Test + # resource_type should not be allowed. + def test_resource_type_not_ok + assert_raises(ArgumentError) { AzureServiceFabricMeshServices.new(resource_provider: 'some_type') } + end + + def tag_value_not_ok + assert_raises(ArgumentError) { AzureServiceFabricMeshServices.new(tag_value: 'some_tag_value') } + end + + def tag_name_not_ok + assert_raises(ArgumentError) { AzureServiceFabricMeshServices.new(tag_name: 'some_tag_name') } + end + + def test_name_not_ok + assert_raises(ArgumentError) { AzureServiceFabricMeshServices.new(name: 'some_name') } + end +end From 8cc35d02d89895d381333510f05fd79a163b93d2 Mon Sep 17 00:00:00 2001 From: Sathish Date: Tue, 14 Dec 2021 00:43:27 +0530 Subject: [PATCH 3/6] integral test service fabric mesh services (s) Signed-off-by: Sathish --- .../controls/azure_service_fabric_mesh_service.rb | 11 +++++++++++ .../controls/azure_service_fabric_mesh_services.rb | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/integration/verify/controls/azure_service_fabric_mesh_service.rb create mode 100644 test/integration/verify/controls/azure_service_fabric_mesh_services.rb diff --git a/test/integration/verify/controls/azure_service_fabric_mesh_service.rb b/test/integration/verify/controls/azure_service_fabric_mesh_service.rb new file mode 100644 index 000000000..43a01d1b4 --- /dev/null +++ b/test/integration/verify/controls/azure_service_fabric_mesh_service.rb @@ -0,0 +1,11 @@ +resource_group = input(:resource_group, value: '') + +control 'test the properties of an Azure Service Fabric Mesh Service' do + describe azure_service_fabric_mesh_service(resource_group: resource_group, name: 'fabric-svc') do + it { should exist } + its('name') { should eq 'fabric-svc' } + its('replicaCount') { should eq '2' } + its('type') { should eq 'Microsoft.ServiceFabricMesh/services' } + its('healthState') { should eq 'Ok' } + end +end diff --git a/test/integration/verify/controls/azure_service_fabric_mesh_services.rb b/test/integration/verify/controls/azure_service_fabric_mesh_services.rb new file mode 100644 index 000000000..a20a31e8a --- /dev/null +++ b/test/integration/verify/controls/azure_service_fabric_mesh_services.rb @@ -0,0 +1,11 @@ +resource_group = input(:resource_group, value: '') + +control 'test the properties of all Azure Service Fabric Mesh Services' do + describe azure_service_fabric_mesh_services(resource_group: resource_group) do + it { should exist } + its('names') { should include 'fabric-svc' } + its('replicaCounts') { should include '2' } + its('types') { should include 'Microsoft.ServiceFabricMesh/services' } + its('healthStates') { should include 'Ok' } + end +end From 38eed80662bcb98b6e90ec04a81e5fee65d94551 Mon Sep 17 00:00:00 2001 From: Sathish Date: Tue, 14 Dec 2021 00:43:45 +0530 Subject: [PATCH 4/6] doc test service fabric mesh services (s) Signed-off-by: Sathish --- .../azure_service_fabric_mesh_service.md | 99 +++++++++++++++++++ .../azure_service_fabric_mesh_services.md | 96 ++++++++++++++++++ 2 files changed, 195 insertions(+) create mode 100644 docs/resources/azure_service_fabric_mesh_service.md create mode 100644 docs/resources/azure_service_fabric_mesh_services.md diff --git a/docs/resources/azure_service_fabric_mesh_service.md b/docs/resources/azure_service_fabric_mesh_service.md new file mode 100644 index 000000000..2e3da7627 --- /dev/null +++ b/docs/resources/azure_service_fabric_mesh_service.md @@ -0,0 +1,99 @@ +--- +title: About the azure_service_fabric_mesh_service Resource +platform: azure +--- + +# azure_service_fabric_mesh_service + +Use the `azure_service_fabric_mesh_service` InSpec audit resource to test properties related to an Azure Service Fabric Mesh Service. + +## 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`, `resource_group` is a required parameter. + +```ruby +describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do + it { should exist } + its('type') { should eq 'Microsoft.ServiceFabricMesh/applications' } +end +``` + +```ruby +describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do + it { should exist } +end +``` +## Parameters + +| Name | Description | +|----------------|----------------------------------------------------------------------------------| +| name | Name of the Azure SERVICE FABRIC MESH SERVICE to test. | +| resource_group | Azure resource group that the targeted resource resides in. `MyResourceGroup` | + +The parameter set should be provided for a valid query: +- `resource_group` and `name` + +## Properties + +| Property | Description | +|--------------------------|------------------------------------------------------------------| +| id | Resource Id. | +| name | Resource name. | +| type | Resource type. `Microsoft.ServiceFabricMesh/services` | +| properties | The properties of the SERVICE FABRIC MESH SERVICE. | +| properties.osType | The Operating system type required by the code in service. | +| properties.replicaCount | The number of replicas of the service to create. Defaults to 1 if not specified.| +| properties.healthState | Describes the health state of an services resource. | + + +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/servicefabric/sfmeshrp-api-service_get) for other properties available. + +## Examples + +### Test that the SERVICE FABRIC MESH SERVICE is healthy. + +```ruby +describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do + its('properties.healthState') { should eq 'Ok' } +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 SERVICE FABRIC MESH SERVICE is found it will exist +describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do + it { should exist } +end +# if SERVICE FABRIC MESH SERVICE is not found it will not exist +describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') 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 `reader` role on the subscription you wish to test. \ No newline at end of file diff --git a/docs/resources/azure_service_fabric_mesh_services.md b/docs/resources/azure_service_fabric_mesh_services.md new file mode 100644 index 000000000..2a8b13147 --- /dev/null +++ b/docs/resources/azure_service_fabric_mesh_services.md @@ -0,0 +1,96 @@ +--- +title: About the azure_service_fabric_mesh_services Resource +platform: azure +--- + +# azure_service_fabric_mesh_services + +Use the `azure_service_fabric_mesh_services` InSpec audit resource to test properties related to all Azure Service Fabric Mesh Services 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_service_fabric_mesh_services` resource block returns all Azure Service Fabric Mesh Services within a project. + +```ruby +describe azure_service_fabric_mesh_services do + #... +end +``` + +## Parameters +| Name | Description | +|----------------|----------------------------------------------------------------------------------| +| resource_group | Azure resource group that the targeted resource resides in. `MyResourceGroup` (Optional) | + +The parameter set optionally be provided for a valid query: +- `resource_group` + +## Properties + +|Property | Description | Filter Criteria* | +|--------------------------|------------------------------------------------------------------------|------------------| +| ids | A list of resource IDs. | `id` | +| names | A list of resource Names. | `name` | +| types | A list of the resource types. | `type` | +| properties | A list of Properties for all the Service Fabric Mesh Services. | `properties` | +| osTypes | The Operating system type required by the code in services. | `replicaCount` | +| replicaCounts | The number of replicas of the service to create. Defaults to 1 if not specified.| `metricId` | +| healthStates | health state of an services resource | `healthState` | + +* 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 Service Fabric Mesh Services by their names. + +```ruby +azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP').names.each do |name| + describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: name) do + it { should exist } + end +end +``` +### Test that there are Service Fabric Mesh Services that are healthy. + +```ruby +describe azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP').where(replicaCounts: 2) 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 Service Fabric Mesh Services are present +describe azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP') do + it { should_not exist } +end +# Should exist if the filter returns at least one Service Fabric Mesh Services +describe azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP') 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 `reader` role on the subscription you wish to test. From d8f6f00c0a379f7903026a09d43b5dbc6dff6cb1 Mon Sep 17 00:00:00 2001 From: Sathish Date: Tue, 14 Dec 2021 00:45:28 +0530 Subject: [PATCH 5/6] update read me with test service fabric mesh services (s) Signed-off-by: Sathish --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2126c478f..594790b07 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,8 @@ The following is a list of static resources. - [azure_security_center_policies](docs/resources/azure_security_center_policies.md) - [azure_sentinel_alert_rule_template](docs/resources/azure_sentinel_alert_rule_template.md) - [azure_sentinel_alert_rule_templates](docs/resources/azure_sentinel_alert_rule_templates.md) +- [azure_service_fabric_mesh_service](docs/resources/azure_service_fabric_mesh_service.md) +- [azure_service_fabric_mesh_services](docs/resources/azure_service_fabric_mesh_services.md) - [azure_sql_database](docs/resources/azure_sql_database.md) - [azure_sql_databases](docs/resources/azure_sql_databases.md) - [azure_sql_server](docs/resources/azure_sql_server.md) From 6519884f32da0e9de1110a7a8c6c1009da10aafa Mon Sep 17 00:00:00 2001 From: Ian Maddaus Date: Fri, 11 Mar 2022 13:31:53 -0500 Subject: [PATCH 6/6] Docs edits Signed-off-by: Ian Maddaus --- .../azure_service_fabric_mesh_service.md | 105 ++++++++++++++++ .../azure_service_fabric_mesh_services.md | 118 ++++++++++++++++++ .../azure_service_fabric_mesh_service.md | 99 --------------- .../azure_service_fabric_mesh_services.md | 96 -------------- 4 files changed, 223 insertions(+), 195 deletions(-) create mode 100644 docs-chef-io/content/inspec/resources/azure_service_fabric_mesh_service.md create mode 100644 docs-chef-io/content/inspec/resources/azure_service_fabric_mesh_services.md delete mode 100644 docs/resources/azure_service_fabric_mesh_service.md delete mode 100644 docs/resources/azure_service_fabric_mesh_services.md diff --git a/docs-chef-io/content/inspec/resources/azure_service_fabric_mesh_service.md b/docs-chef-io/content/inspec/resources/azure_service_fabric_mesh_service.md new file mode 100644 index 000000000..31cdcc2ab --- /dev/null +++ b/docs-chef-io/content/inspec/resources/azure_service_fabric_mesh_service.md @@ -0,0 +1,105 @@ ++++ +title = "azure_service_fabric_mesh_service Resource" +platform = "azure" +draft = false +gh_repo = "inspec-azure" + +[menu.inspec] +title = "azure_service_fabric_mesh_service" +identifier = "inspec/resources/azure/azure_service_fabric_mesh_service Resource" +parent = "inspec/resources/azure" ++++ + +Use the `azure_service_fabric_mesh_service` InSpec audit resource to test properties of an Azure Service Fabric Mesh service. + +## Azure REST API Version, Endpoint, and HTTP Client Parameters + +{{% inspec_azure_common_parameters %}} + +## Installation + +{{% inspec_azure_install %}} + +## Syntax + +```ruby +describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do + it { should exist } + its('type') { should eq 'Microsoft.ServiceFabricMesh/applications' } +end +``` + +```ruby +describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do + it { should exist } +end +``` + +## Parameters + +`name` _(required)_ +: Name of the Azure Service Fabric Mesh service to test. + +`resource_group` _(required)_ +: Azure resource group that the targeted resource resides in. + +## Properties + +`id` +: Resource Id. + +`name` +: Resource name. + +`type` +: Resource type. `Microsoft.ServiceFabricMesh/services`. + +`properties` +: The properties of the SERVICE FABRIC MESH SERVICE. + +`properties.osType` +: The Operating system type required by the code in service. + +`properties.replicaCount` +: The number of replicas of the service to create. Defaults to 1 if not specified. + +`properties.healthState` +: Describes the health state of an services resource. + + +For properties applicable to all resources, such as `type`, `name`, `id`, `properties`, refer to [`azure_generic_resource`]({{< relref "azure_generic_resource.md#properties" >}}). + +Also, refer to [Azure documentation](https://docs.microsoft.com/en-us/rest/api/servicefabric/sfmeshrp-api-service_get) for other properties available. + +## Examples + +**Test that the SERVICE FABRIC MESH SERVICE is healthy.** + +```ruby +describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do + its('properties.healthState') { should eq 'Ok' } +end +``` + +## Matchers + +{{% inspec_matchers_link %}} + +### exists + +```ruby +# If a SERVICE FABRIC MESH SERVICE is found it will exist + +describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do + it { should exist } +end +# if SERVICE FABRIC MESH SERVICE is not found it will not exist + +describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do + it { should_not exist } +end +``` + +## Azure Permissions + +{{% azure_permissions_service_principal role="reader" %}} diff --git a/docs-chef-io/content/inspec/resources/azure_service_fabric_mesh_services.md b/docs-chef-io/content/inspec/resources/azure_service_fabric_mesh_services.md new file mode 100644 index 000000000..2f065383f --- /dev/null +++ b/docs-chef-io/content/inspec/resources/azure_service_fabric_mesh_services.md @@ -0,0 +1,118 @@ ++++ +title = "azure_service_fabric_mesh_services Resource" +platform = "azure" +draft = false +gh_repo = "inspec-azure" + +[menu.inspec] +title = "azure_service_fabric_mesh_services" +identifier = "inspec/resources/azure/azure_service_fabric_mesh_services Resource" +parent = "inspec/resources/azure" ++++ + +Use the `azure_service_fabric_mesh_services` InSpec audit resource to test properties of all Azure service Fabric Mesh services within a project. + +## Azure REST API Version, Endpoint, and HTTP Client Parameters + +{{% inspec_azure_common_parameters %}} + +## Installation + +{{% inspec_azure_install %}} + +## Syntax + +An `azure_service_fabric_mesh_services` resource block returns all Azure service Fabric Mesh services within a project. + +```ruby +describe azure_service_fabric_mesh_services do + #... +end +``` + +## Parameters + +`resource_group` _(optional)_ +: Azure resource group that the targeted resource resides in. + +## Properties + +`ids` +: A list of resource IDs. + +: **Field**: `id` + +`names` +: A list of resource Names. + +: **Field**: `name` + +`types` +: A list of the resource types. + +: **Field**: `type` + +`properties` +: A list of Properties for all the service Fabric Mesh services. + +: **Field**: `properties` + +`osTypes` +: The Operating system type required by the code in services. + +: **Field**: `replicaCount` + +`replicaCounts` +: The number of replicas of the service to create. Defaults to 1 if not specified. + +: **Field**: `metricId` + +`healthStates` +: health state of an services resource. + +: **Field**: `healthState` + +{{% inspec_filter_table %}} + +## Examples + +**Loop through service Fabric Mesh services by their names.** + +```ruby +azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP').names.each do |name| + describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: name) do + it { should exist } + end +end +``` + +**Test that there are service Fabric Mesh services that are healthy.** + +```ruby +describe azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP').where(replicaCounts: 2) do + it { should exist } +end +``` + +## Matchers + +{{% inspec_matchers_link %}} + +### exists + +```ruby +# Should not exist if no service Fabric Mesh services are present + +describe azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP') do + it { should_not exist } +end +# Should exist if the filter returns at least one service Fabric Mesh services + +describe azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP') do + it { should exist } +end +``` + +## Azure Permissions + +{{% azure_permissions_service_principal role="reader" %}} diff --git a/docs/resources/azure_service_fabric_mesh_service.md b/docs/resources/azure_service_fabric_mesh_service.md deleted file mode 100644 index 2e3da7627..000000000 --- a/docs/resources/azure_service_fabric_mesh_service.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: About the azure_service_fabric_mesh_service Resource -platform: azure ---- - -# azure_service_fabric_mesh_service - -Use the `azure_service_fabric_mesh_service` InSpec audit resource to test properties related to an Azure Service Fabric Mesh Service. - -## 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`, `resource_group` is a required parameter. - -```ruby -describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do - it { should exist } - its('type') { should eq 'Microsoft.ServiceFabricMesh/applications' } -end -``` - -```ruby -describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do - it { should exist } -end -``` -## Parameters - -| Name | Description | -|----------------|----------------------------------------------------------------------------------| -| name | Name of the Azure SERVICE FABRIC MESH SERVICE to test. | -| resource_group | Azure resource group that the targeted resource resides in. `MyResourceGroup` | - -The parameter set should be provided for a valid query: -- `resource_group` and `name` - -## Properties - -| Property | Description | -|--------------------------|------------------------------------------------------------------| -| id | Resource Id. | -| name | Resource name. | -| type | Resource type. `Microsoft.ServiceFabricMesh/services` | -| properties | The properties of the SERVICE FABRIC MESH SERVICE. | -| properties.osType | The Operating system type required by the code in service. | -| properties.replicaCount | The number of replicas of the service to create. Defaults to 1 if not specified.| -| properties.healthState | Describes the health state of an services resource. | - - -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/servicefabric/sfmeshrp-api-service_get) for other properties available. - -## Examples - -### Test that the SERVICE FABRIC MESH SERVICE is healthy. - -```ruby -describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do - its('properties.healthState') { should eq 'Ok' } -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 SERVICE FABRIC MESH SERVICE is found it will exist -describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') do - it { should exist } -end -# if SERVICE FABRIC MESH SERVICE is not found it will not exist -describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_SERVICE_NAME') 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 `reader` role on the subscription you wish to test. \ No newline at end of file diff --git a/docs/resources/azure_service_fabric_mesh_services.md b/docs/resources/azure_service_fabric_mesh_services.md deleted file mode 100644 index 2a8b13147..000000000 --- a/docs/resources/azure_service_fabric_mesh_services.md +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: About the azure_service_fabric_mesh_services Resource -platform: azure ---- - -# azure_service_fabric_mesh_services - -Use the `azure_service_fabric_mesh_services` InSpec audit resource to test properties related to all Azure Service Fabric Mesh Services 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_service_fabric_mesh_services` resource block returns all Azure Service Fabric Mesh Services within a project. - -```ruby -describe azure_service_fabric_mesh_services do - #... -end -``` - -## Parameters -| Name | Description | -|----------------|----------------------------------------------------------------------------------| -| resource_group | Azure resource group that the targeted resource resides in. `MyResourceGroup` (Optional) | - -The parameter set optionally be provided for a valid query: -- `resource_group` - -## Properties - -|Property | Description | Filter Criteria* | -|--------------------------|------------------------------------------------------------------------|------------------| -| ids | A list of resource IDs. | `id` | -| names | A list of resource Names. | `name` | -| types | A list of the resource types. | `type` | -| properties | A list of Properties for all the Service Fabric Mesh Services. | `properties` | -| osTypes | The Operating system type required by the code in services. | `replicaCount` | -| replicaCounts | The number of replicas of the service to create. Defaults to 1 if not specified.| `metricId` | -| healthStates | health state of an services resource | `healthState` | - -* 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 Service Fabric Mesh Services by their names. - -```ruby -azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP').names.each do |name| - describe azure_service_fabric_mesh_service(resource_group: 'RESOURCE_GROUP', name: name) do - it { should exist } - end -end -``` -### Test that there are Service Fabric Mesh Services that are healthy. - -```ruby -describe azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP').where(replicaCounts: 2) 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 Service Fabric Mesh Services are present -describe azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP') do - it { should_not exist } -end -# Should exist if the filter returns at least one Service Fabric Mesh Services -describe azure_service_fabric_mesh_services(resource_group: 'RESOURCE_GROUP') 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 `reader` role on the subscription you wish to test.