-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds azurerm_locks #203
Merged
Merged
Adds azurerm_locks #203
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
title: About the azurerm_locks Resource | ||
platform: azure | ||
--- | ||
|
||
# azurerm\_locks | ||
|
||
Use the `azurerm_locks` InSpec audit resource to test properties of | ||
some or all Azure Resource Locks. | ||
|
||
<br /> | ||
|
||
## Azure REST API version | ||
|
||
This resource interacts with version `2016-09-01` of the Azure | ||
Management API. For more information see the [official Azure documentation](https://docs.microsoft.com/en-us/rest/api/resources/managementlocks/listatresourcelevel). | ||
|
||
At the moment, there doesn't appear to be a way to select the version of the | ||
Azure API docs. If you notice a newer version being referenced in the official | ||
documentation please open an issue or submit a pull request using the updated | ||
version. | ||
|
||
## Availability | ||
|
||
### Installation | ||
|
||
This resource is available in the `inspec-azure` [resource | ||
pack](https://www.inspec.io/docs/reference/glossary/#resource-pack). To use it, add the | ||
following to your `inspec.yml` in your top-level profile: | ||
|
||
depends: | ||
- name: inspec-azure | ||
git: https://github.com/inspec/inspec-azure.git | ||
|
||
You'll also need to setup your Azure credentials; see the resource pack | ||
[README](https://github.com/inspec/inspec-azure#inspec-for-azure). | ||
|
||
### Version | ||
|
||
This resource first became available in 1.3.8 of the inspec-azure resource pack. | ||
|
||
## Syntax | ||
|
||
An `azurerm_locks` resource block returns all Locks on a given Resource. | ||
|
||
describe azurerm_locks(resource_group: 'rg', resource_name: 'my-vm', resource_type: 'Microsoft.Compute/virtualMachines') do | ||
... | ||
end | ||
|
||
<br /> | ||
|
||
## Examples | ||
|
||
The following examples show how to use this InSpec audit resource. | ||
|
||
### Ensure a Lock exists | ||
|
||
describe azurerm_locks(resource_group: 'my-rg', resource_name: 'my-vm', resource_type: 'Microsoft.Compute/virtualMachines') do | ||
it { should exist } | ||
end | ||
|
||
## Filter Criteria | ||
|
||
* `ids` | ||
* `names` | ||
* `properties` | ||
|
||
## 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 | ||
|
||
The control will pass if the filter returns at least one result. Use | ||
`should_not` if you expect zero matches. | ||
|
||
## 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'azurerm_resource' | ||
|
||
class AzurermLocks < AzurermPluralResource | ||
name 'azurerm_locks' | ||
desc 'Verifies settings for an Azure Lock on a Resource' | ||
example <<-EXAMPLE | ||
describe azurerm_locks(resource_group: 'my-rg', resource_name: 'my-vm', resource_type: 'Microsoft.Compute/virtualMachines') do | ||
it { should exist } | ||
end | ||
EXAMPLE | ||
|
||
attr_reader :table | ||
|
||
FilterTable.create | ||
.register_column(:ids, field: :id) | ||
.register_column(:names, field: :name) | ||
.register_column(:properties, field: :properties) | ||
.install_filter_methods_on_resource(self, :table) | ||
|
||
def initialize(resource_group: nil, resource_name: nil, resource_type: nil) | ||
resp = management.locks(resource_group, resource_name, resource_type) | ||
return if has_error?(resp) | ||
|
||
@table = resp | ||
end | ||
|
||
def to_s | ||
'Azure Locks' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
resource_group = attribute('resource_group', default: nil) | ||
resource_name = attribute('windows_vm_name', default: nil) | ||
resource_type = 'Microsoft.Compute/virtualMachines' | ||
|
||
control 'azurerm_locks' do | ||
describe azurerm_locks(resource_group: resource_group, resource_name: resource_name, resource_type: resource_type) do | ||
it { should_not exist } | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this just be
exist
?