Skip to content

Commit

Permalink
Add table of contents to the resource creation guide
Browse files Browse the repository at this point in the history
Signed-off-by: Omer Demirok <odemirok@chef.io>
  • Loading branch information
Omer Demirok committed Oct 28, 2020
1 parent 3095d47 commit 2649114
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
44 changes: 35 additions & 9 deletions docs/resource_creation_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,35 @@ For the Azure Key Vault resource, the inheritance order is:
- `AzureResourceBase`: Initiate an HTTP client, provide tools for validation and decision making.
- `Inspec.resource(1)`: InSpec base class for resources.

## Table of Contents

- [Singular Resource](#Singular Resource)
- [Singular Resource Initiation Logic](#Singular Resource Initiation Logic)
- [Singular Resource Creation](#Singular Resource Creation)
- [Resource Identifier](#Resource Identifier)
- [Additional Resource Properties](#Additional Resource Properties)
- [Processing Additional Resource Properties](#Processing Additional Resource Properties)
- [Allowed Parameters](#Allowed Parameters)
- [Plural Resource](#Plural Resource)
- [Plural Resource Initiation Logic](#Plural Resource Initiation Logic)
- [Plural Resource Creation](#Plural Resource Creation)
- [Manipulating Data in FilterTable](#Manipulating Data in FilterTable)
- [Resources Living in/on Another Resources](#Resources Living in/on Another Resources)
- [Required Parameters](#Required Parameters)
- [Resource Path](#Resource Path)
- [Resources without a Resource Group](#Resources without a Resource Group)
- [Resource URI](#Resource URI)
- [Common Parameters](#Common Parameters)
- [Display Name](#Display Name)
- [Update Terraform Outputs](#Update Terraform Outputs)
- [Apply the Terraform Plan](#Apply the Terraform Plan)
- [Create Controls](#Create Controls)
- [Create Documentation](#Create Documentation)
- [Create a Pull Request](#Create a Pull Request)

## Singular Resource

### Resource Initiation Logic:
### Singular Resource Initiation Logic

Find the Azure REST API documentation for the resource being developed, [Azure key vault](https://docs.microsoft.com/en-us/rest/api/keyvault/vaults/get), and follow the instructions here.

Expand All @@ -39,7 +65,7 @@ Find the Azure REST API documentation for the resource being developed, [Azure k
- `resource_provider` has to be defined/created with the help of the `specific_resource_constraint` method for input validation.
- For parameters applicable to all resources, see the project's [README](../README.md).

### Resource Creation
### Singular Resource Creation

- Create the library file: All of the InSpec resource extensions are located in the `libraries` directory. Copy a similar resource as a starting point.
- Change the name to match the resource you are creating.
Expand Down Expand Up @@ -101,7 +127,6 @@ class AzureKeyVault < AzureGenericResource
end
end
```

### Resource Identifier
Even though using the `name` keyword as a resource identifier is advised, a more specific keyword can be defined with the `resource_identifiers` parameter.
```ruby
Expand Down Expand Up @@ -271,7 +296,7 @@ end

## Plural Resource

### Resource Initiation Logic:
### Plural Resource Initiation Logic

Find the Azure REST API documentation for the resource being developed, [Azure key vaults](https://docs.microsoft.com/en-us/rest/api/keyvault/vaults/list), and follow the instructions here.

Expand All @@ -288,7 +313,7 @@ Find the Azure REST API documentation for the resource being developed, [Azure k
- `resource_provider` has to be defined/created with the help of `specific_resource_constraint` method for input validation.
- For parameters applicable to all resources, see project's [README](../README.md).

### Resource Creation
### Plural Resource Creation

- Create the library file: All of the InSpec resource extensions are located in the `libraries` directory. Copy a similar resource as a starting point.
- Change the name to match the resource you are creating.
Expand Down Expand Up @@ -601,7 +626,7 @@ opts[:display_name] = "Databases on #{opts[:server_name]} SQL Server"
```
The display name will be: `Azure Sql Databases - api_version: 2020-08-01-preview latest Databases on {serverName} SQL Server`

## Update Terraform outputs
## Update Terraform Outputs

- Background:
- The `rake tf:apply` command creates Azure infrastructure based on `terraform/azure.tf`. It then takes the Terraform outputs and creates `.$(whoami)-attributes.yml` with them.
Expand All @@ -610,12 +635,13 @@ The display name will be: `Azure Sql Databases - api_version: 2020-08-01-preview
- Resources may need to be built by adding them to `azure.tf` and/or outputs may need to be added to `outputs.tf`.
- Ensure Rake command `tf:apply` is run after updating `outputs.tf` so that it updates the attributes file.

### Run `rake tf:apply`
### Apply the Terraform Plan

- Run `rake tf:apply`
- Make sure Terraform runs successfully and creates all of the infrastructures.
- Verify that `/terraform/.$(whoami)-attributes.yml` contains output with property values for the resource being developed.

## Create controls
## Create Controls

Azure controls are located in `test/integration/verify/controls/`. Copy two of the files (singular and plural) for a similar resource as a starting point. This is where InSpec tests are defined to ensure the resources that are being developed are working correctly.
Consider the following:
Expand Down Expand Up @@ -657,7 +683,7 @@ control 'azure_key_vault' do

end
```
## Create Documentation in `docs/resources`
## Create Documentation

Once everything is working, documentation must be added for the resources that have been added. Copy similar resource documents in `docs/resources/` and edit them as appropriate. Include enough examples to give a good idea of how the resource works. Make sure to include any special case examples that might exist.
After writing the documentation:
Expand Down
2 changes: 1 addition & 1 deletion test/integration/verify/controls/azure_key_vault.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource_group = input('resource_group', value: nil)
vault_name = input('key_vault_name', value: nil)

control 'azurerm_key_vault' do
control 'azure_key_vault' do

describe azure_key_vault(resource_group: resource_group, vault_name: vault_name) do
it { should exist }
Expand Down

0 comments on commit 2649114

Please sign in to comment.