-
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 MySQL Resources #213
Merged
Merged
Adds MySQL Resources #213
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
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
File renamed without changes.
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,122 @@ | ||
--- | ||
title: About the azurerm_mysql_database Resource | ||
platform: azure | ||
--- | ||
|
||
# azurerm\_mysql\_database | ||
|
||
Use the `azurerm_mysql_database` InSpec audit resource to test properties and configuration of | ||
an Azure MySQL Database on a MySQL Server. | ||
<br /> | ||
|
||
## Azure REST API version | ||
|
||
This resource interacts with version `2017-12-01` of the Azure Management API. For more | ||
information see the [Official Azure Documentation](https://docs.microsoft.com/en-us/rest/api/mysql/databases/get). | ||
|
||
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: | ||
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.6.0 of the inspec-azure resource pack. | ||
|
||
## Syntax | ||
|
||
The `resource_group`, `server_name` and `database_name` must be given as a parameter. | ||
|
||
describe azurerm_mysql_database(resource_group: 'inspec-rg', server_name: 'customer_server', database_name: 'order-db') do | ||
it { should exist } | ||
end | ||
|
||
<br /> | ||
|
||
## Examples | ||
|
||
If a MySQL Database is referenced with a valid `Resource Group`, `Server Name` and `Database name` | ||
|
||
describe azurerm_mysql_database(resource_group: 'inspec-rg', server_name: 'customer_server', database_name: 'order-db') do | ||
it { should exist } | ||
its('name') { should be 'order-db' } | ||
end | ||
|
||
If a MySQL Database is referenced with an invalid `Resource Group`, `Server Name` or `Database Name` | ||
|
||
describe azurerm_mysql_database(resource_group: 'inspec-rg', server_name: 'customer_server', database_name: 'invalid-db-name') do | ||
it { should_not exist } | ||
end | ||
<br /> | ||
|
||
## Parameters | ||
|
||
- `resource_group` - The resource Group to which the MySQL Server belongs. | ||
- `server_name` - The unique name of the MySQL Server. | ||
- `database_name` - The unique name of the MySQL Database. | ||
|
||
## Attributes | ||
|
||
- `id` | ||
- `name` | ||
- `type` | ||
- `properties` | ||
|
||
### id | ||
Azure resource ID. | ||
|
||
### name | ||
SQL Server name, e.g. `customer-database`. | ||
|
||
### type | ||
The type of Resource, typically `Microsoft.DBforMySQL/servers/databases`. | ||
|
||
### properties | ||
A collection of additional configuration properties related to the MySQL Database, e.g. `collation`. | ||
|
||
### Other Attributes | ||
|
||
There are additional attributes that may be accessed that we have not | ||
documented. Please take a look at the [Azure documentation](#-Azure-REST-API-version). | ||
Any attribute in the response may be accessed with the key names separated by | ||
dots (`.`). | ||
|
||
The API may not always return keys that do not have any associated data. There | ||
may be cases where the deeply nested property may not have the desired | ||
attribute along your call chain. If you find yourself writing tests against | ||
properties that may be nil, fork this resource pack and add an accessor to the | ||
resource. Within that accessor you'll be able to guard against nil keys. Pull | ||
requests are always welcome. | ||
|
||
## 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 | ||
|
||
describe azurerm_mysql_database(resource_group: 'my-rg', server_name: 'server-name-1', database_name: 'customer-db') 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. |
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,115 @@ | ||
--- | ||
title: About the azurerm_mysql_databases Resource | ||
platform: azure | ||
--- | ||
|
||
# azurerm\_mysql\_databases | ||
|
||
Use the `azurerm_mysql_databases` InSpec audit resource to test properties and configuration of Azure MySQL Databases. | ||
<br /> | ||
|
||
## Azure REST API version | ||
|
||
This resource interacts with version `2017-12-01` of the Azure Management API. For more | ||
information see the [Official Azure Documentation](https://docs.microsoft.com/en-us/rest/api/mysql/databases/listbyserver). | ||
|
||
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: | ||
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.6.0 of the inspec-azure resource pack. | ||
|
||
## Syntax | ||
|
||
An `azurerm_mysql_databases` resource block returns all MySQL Databases on a MySQL Server, within a Rsource Group. | ||
|
||
describe azurerm_mysql_databases(resource_group: ..., server_name: ...) do | ||
... | ||
end | ||
|
||
<br /> | ||
|
||
## Examples | ||
|
||
The following examples show how to use this InSpec audit resource. | ||
|
||
### Check MySQL Databases are present | ||
|
||
describe azurerm_mysql_databases(resource_group: 'resource-group-1', server_name: 'production') do | ||
it { should exist } | ||
its('names') { should include 'my-database-name' } | ||
end | ||
<br /> | ||
|
||
## Filter Criteria | ||
|
||
* `azure_mysql_databases` resources are filterable on all available properties. Below are some examples. | ||
|
||
### names | ||
|
||
Filters the results to include only those databases that match the given | ||
name. This is a string value. | ||
|
||
describe azurerm_mysql_databases(resource_group: 'rg', server_name: 'server').where{ name.eql?('production-database') } do | ||
it { should exist } | ||
end | ||
|
||
## Attributes | ||
|
||
- `id` | ||
- `name` | ||
- `type` | ||
- `properties` | ||
|
||
### ids | ||
Azure resource ID. | ||
|
||
### names | ||
SQL Database name, e.g. `my-sql-database`. | ||
|
||
its('names') { should include 'my-sql-database' } | ||
|
||
### type | ||
The type of Resource, typically `Microsoft.Sql/servers/databases`. | ||
|
||
|
||
### properties | ||
A collection of additional configuration properties related to the MySQL Database, e.g. `collation`. | ||
|
||
## 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. | ||
|
||
describe azurerm_mysql_databases 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. |
Oops, something went wrong.
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.
This probably isn't an issue with this PR, but I was wondering whether there is a need for
exist
in plural resources. I believe the same thing could be achieved throughit { should_not be_empty }
.