Skip to content

Commit

Permalink
feat: add type definitions in usage examples (#135)
Browse files Browse the repository at this point in the history
* feat: add type definitions in usage examples

* feat: fix formatting

* feat: update documentation

---------

Co-authored-by: dkool <[email protected]>
  • Loading branch information
dkooll and dkool authored Aug 12, 2024
1 parent 39d3e59 commit 0a6461a
Show file tree
Hide file tree
Showing 31 changed files with 285 additions and 884 deletions.
File renamed without changes.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ A primary goal is to utilize keys and values in the object that correspond to th

A last key goal is to separate logic from configuration in the module, thereby enhancing its scalability, ease of customization, and manageability.

## Non-Goals

These modules are not intended to be complete, ready-to-use solutions; they are designed as components for creating your own patterns.

They are not tailored for a single use case but are meant to be versatile and applicable to a range of scenarios.

Security standardization is applied at the pattern level, while the modules include default values based on best practices but do not enforce specific security standards.

End-to-end testing is not conducted on these modules, as they are individual components and do not undergo the extensive testing reserved for complete patterns or solutions.

## Features

- flexibility to incorporate multiple extensions
Expand Down Expand Up @@ -110,6 +120,12 @@ Authentication for linux virtual machines can be done with either ssh keys or pa

Module is maintained by [these awesome contributors](https://github.com/cloudnationhq/terraform-azure-vm/graphs/contributors).

## Contributing

We welcome contributions from the community! Whether it's reporting a bug, suggesting a new feature, or submitting a pull request, your input is highly valued.

For more information, please see our contribution [guidelines](https://github.com/CloudNationHQ/terraform-azure-vm/blob/main/CONTRIBUTING.md).

## License

MIT Licensed. See [LICENSE](https://github.com/cloudnationhq/terraform-azure-vm/blob/main/LICENSE) for full details.
Expand Down
103 changes: 19 additions & 84 deletions examples/authentication/README.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,27 @@
This module enables flexible virtual machine setup by supporting both auto generated and user supplied (bring your own) ssh keys and passwords for tailored access.
# Authentication

## Usage: generated password or ssh key
This displays authentication settings available for deployment.

To utilize the generated password or ssh key, simply specify the key vault id in your configuration:
## Types

```hcl
module "vm" {
source = "cloudnationhq/vm/azure"
version = "~> 3.0"
naming = local.naming
depends_on = [module.kv]
instance = {
name = module.naming.linux_virtual_machine.name
location = module.rg.groups.demo.location
resourcegroup = module.rg.groups.demo.name
type = "linux"
interfaces = {
int1 = {
subnet = module.network.subnets.int.id
ip_configurations = {
config1 = {
private_ip_address_allocation = "Dynamic"
}
}
}
}
keyvault_id = module.kv.vault.id
}
}
instance = object({
name = string
location = string
resource_group = string
public_key = optional(string)
type = string
interfaces = map(object({
subnet = string
ip_configurations = map(object({
private_ip_address_allocation = string
}))
}))
})
```

## Usage: bringing your own password or ssh key

To use your own password or SSH key, use the below properties in your configuration:

```hcl
module "vm" {
source = "cloudnationhq/vm/azure"
version = "~> 1.3"
naming = local.naming
depends_on = [module.kv]
## Notes

instance = {
name = module.naming.linux_virtual_machine.name
location = module.rg.groups.demo.location
resourcegroup = module.rg.groups.demo.name
public_key = module.kv.tls_public_keys.vm-linux-demo-dev-key.value
type = "linux"
public_key is used for linux machines, while password is used for windows machines in a BYO (Bring Your Own) configuration.

interfaces = {
int1 = {
subnet = module.network.subnets.int.id
ip_configurations = {
config1 = {
private_ip_address_allocation = "Dynamic"
}
}
}
}
}
}
```

```hcl
module "vm" {
source = "cloudnationhq/vm/azure"
version = "~> 1.3"
naming = local.naming
depends_on = [module.kv]
instance = {
name = module.naming.linux_virtual_machine.name
location = module.rg.groups.demo.location
resourcegroup = module.rg.groups.demo.name
password = module.kv.secrets.vm-linux-demo-dev-password.value
type = "linux"
interfaces = {
int1 = {
subnet = module.network.subnets.int.id
}
}
}
}
```
Both are optional; if omitted, secrets will be automatically generated.
File renamed without changes.
75 changes: 30 additions & 45 deletions examples/availability-sets/README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,36 @@
This example outlines the configuration and deployment of availability sets to ensure high availability and fault tolerance.
# Availability Sets

## Usage
This deploys availability sets on the virtual machine to be utilized.

```hcl
module "vm" {
source = "cloudnationhq/vm/azure"
version = "~> 3.0"
## Types

naming = local.naming
keyvault = module.kv.vault.id
resourcegroup = module.rg.groups.demo.name
location = module.rg.groups.demo.location
depends_on = [module.kv]
```hcl
instance = object({
type = string
name = string
resource_group = string
location = string
custom_data = optional(string)
interfaces = map(object({
subnet = string
ip_configurations = map(object({
private_ip_address_allocation = optional(string)
private_ip_address = optional(string)
primary = optional(bool)
}))
}))
availability_set_id = optional(string)
})
```

instance = {
name = module.naming.virtual_machine.name
type = "linux"
interfaces = {
dcroot001 = {
subnet = module.network.subnets.int.id
ip_configurations = {
config1 = {
private_ip_address_allocation = "Dynamic"
}
}
}
}
disks = {
dcroot001 = {
disk_size_gb = 128
lun = 0
}
}
availability_set_id = module.availability.sets.demo.id
}
}
```hcl
availability_sets = map(object({
name = string
resource_group = string
location = string
}))
```

module "availability" {
source = "cloudnationhq/vm/azure//modules/availability-sets"
version = "~> 0.1"
## Notes

availability_sets = {
demo = {
name = module.naming.availability_set.name
resourcegroup = module.rg.groups.demo.name
location = module.rg.groups.demo.location
}
}
}
```
The submodule enables setting up multiple availability sets and assigning virtual machines to specific zones.
10 changes: 2 additions & 8 deletions examples/availability-sets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module "kv" {

module "vm" {
source = "cloudnationhq/vm/azure"
version = "~> 1.12"
version = "~> 3.0"

naming = local.naming
keyvault = module.kv.vault.id
Expand All @@ -73,19 +73,13 @@ module "vm" {
}
}
}
disks = {
dcroot001 = {
disk_size_gb = 128
lun = 0
}
}
availability_set_id = module.availability.sets.demo.id
}
}

module "availability" {
source = "cloudnationhq/vm/azure//modules/availability-sets"
version = "~> 0.1"
version = "~> 3.0"

availability_sets = {
demo = {
Expand Down
File renamed without changes.
82 changes: 0 additions & 82 deletions examples/complete/.terraform.lock.hcl

This file was deleted.

Loading

0 comments on commit 0a6461a

Please sign in to comment.