Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Commit

Permalink
Adding examples and documentation, fixing typos
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudlh committed Jun 30, 2020
1 parent ba37df4 commit 9d70354
Show file tree
Hide file tree
Showing 14 changed files with 346 additions and 131 deletions.
39 changes: 39 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "Azure CAF rover",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
"dockerComposeFile": "docker-compose.yml",

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "rover",

// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a volume mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/tf/caf",

// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
// If you are using an Alpine-based image, change this to /bin/ash
"files.eol": "\n",
"terminal.integrated.shell.linux": "/bin/bash",
"editor.tabSize": 2,
"terminal.integrated.scrollback": 2000,
},

// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],

// Uncomment this like if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",

// Uncomment the next line to run commands after the container is created.
"postCreateCommand": "cp -R /tmp/.ssh-localhost/* ~/.ssh && chmod 700 ~/.ssh && chmod 600 ~/.ssh/*",

// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"4ops.terraform",
"mutantdino.resourcemonitor"
]
}
29 changes: 29 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

version: '3.7'
services:
rover:
image: aztfmod/roverdev:vnext

labels:
- "caf=Azure CAF"

volumes:
- ..:/tf/caf
- volume-caf-vscode:/home/vscode
- ~/.ssh:/tmp/.ssh-localhost:ro

- /var/run/docker.sock:/var/run/docker.sock

# Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done"

volumes:
volume-caf-vscode:
labels:
- "caf=Azure CAF"


22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See http://pre-commit.com for more information
# See http://pre-commit.com/hooks.html for more hooks
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.31.0
hooks:
- id: terraform_fmt
- id: terraform_docs
- id: terraform_tflint
# - id: terraform_validate
- id: terraform_tfsec
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
# - repo: git://github.com/markdownlint/markdownlint
# rev: v0.9.0
# hooks:
# - id: markdownlint
9 changes: 9 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Microsoft Open Source Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).

Resources:

- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [[email protected]](mailto:[email protected]) with questions or concerns
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
144 changes: 38 additions & 106 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
[![Build status](https://dev.azure.com/azure-terraform/Blueprints/_apis/build/status/modules/route_table)](https://dev.azure.com/azure-terraform/Blueprints/_build/latest?definitionId=14)
[![VScodespaces](https://img.shields.io/endpoint?url=https%3A%2F%2Faka.ms%2Fvso-badge)](https://online.visualstudio.com/environments/new?name=terraform-azurerm-caf-route-table&repo=aztfmod/terraform-azurerm-caf-route-table)

# Deploys a route table and routing table entries
Creates a routing table object and a set of routing table entries.

Creates a routing table object and a set of routing table entries.

The route object is not linked to any subnet, you need to attach using azurerm_subnet_route_table_association
as per https://www.terraform.io/docs/providers/azurerm/r/subnet_route_table_association.html

Reference the module to a specific version (recommended):
```hcl
module "route_table" {
source = "git://github.com/aztfmod/route_table.git?ref=v0.1"
route_table = var.route_table
tags = var.tags
}
```
source = "aztfmod/caf-route-table/azurerm"
version = "0.x.y"
Or get the latest version
```hcl
module "route_table" {
source = "git://github.com/aztfmod/route_table.git?ref=latest"
route_table = var.route_table
tags = var.tags
prefix = local.prefix
tags = local.tags
convention = local.convention
resource_group_name = azurerm_resource_group.rg_test.name
location = local.location
route_table = local.route_table
next_hop_in_dynamic_private_ip = local.next_hop_in_dynamic_private_ip
}
```

# Parameters
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| convention | (Required) Naming convention method to use | `string` | n/a | yes |
| max\_length | (Optional) You can speficy a maximum length to the name of the resource | `string` | `"60"` | no |
| next\_hop\_in\_dynamic\_private\_ip | (Optional) dynamically passing private ip address which is an output of another tf resource or module, e.g. azure firewall | `any` | `null` | no |
| postfix | (Optional) You can use a postfix to the name of the resource | `string` | `""` | no |
| prefix | (Optional) You can use a prefix to the name of the resource | `string` | `""` | no |
| route\_table | (Required) route table object to be created | `any` | n/a | yes |
| tags | (Required) map of tags for the deployment | `any` | n/a | yes |


## Parameters

## route_table
(Required) The routing table object describing the route table configuration
Mandatory properties are:
- name
- location
- rg
- at least one route_entries item as follow:
- at least one route_entries item as follow:
```hcl
re1= {
name = "myroute1"
Expand All @@ -41,98 +53,18 @@ Mandatory properties are:
},
```

Optional properties are:
Optional fields:
- disable_bgp_route_propagation

```hcl
variable "route_table" {
description = "(Required) route table object to be created"
}
```
Example
```hcl
route_table = {
name = "route_test"
rg = "uqvh-HUB-CORE-NET"
location = "southeastasia"
disable_bgp_route_propagation = false #optional
route_entries = {
re1= {
name = "myroute1"
prefix = "255.0.0.0/8"
next_hop_type = "None"
},
re2= {
name = "myroute2"
prefix = "255.255.0.0/16"
next_hop_type = "VirtualAppliance"
next_hop_in_ip_address = "192.168.10.5" #required if next_hop_type is "VirtualAppliance"
},
re3= {
name = "defaulroute"
prefix = "0.0.0.0/0"
next_hop_type = "VirtualAppliance"
next_hop_in_ip_address = "192.168.10.5" #required if next_hop_type is "VirtualAppliance"
},
}
}
```

## next_hop_in_dynamic_private_ip
(Optional) String in CIDR format of next hop ip address in route. If parameter 'next_hop_in_dynamic_private_ip' is not passed in to the module, then property 'next_hop_in_ip_address' is mandatory for next_hop_type = "VitualAppliance" in tfvars file as defined above.
If the parameter 'next_hop_in_dynamic_private_ip' is passed in to the module, it has priority over 'next_hop_in_ip_address' in tfvars file and always overrides it.


## tags
(Required) Map of tags for the deployment
```hcl
variable "tags" {
description = "(Required) map of tags for the deployment"
}
```
Example
```hcl
tags = {
environment = "DEV"
owner = "Arnaud"
deploymentType = "Terraform"
}
```

# Output
## object
Returns the resource object of the created route table.
```hcl
output "object" {
value = azurerm_route_table.route_table
}
```
## Outputs

## name
Returns the resource name of the created route table.
```hcl
output "name" {
value = azurerm_route_table.route_table.name
}
```

## id
Returns the resource ID of the created route table.
```hcl
output "id" {
value = azurerm_route_table.route_table.id
}
```

## subnets
Returns the list of subnets where the routing table is attaced.
```hcl
output "subnets" {
value = azurerm_route_table.route_table.subnets
}
```
| Name | Description |
|------|-------------|
| id | Returns the ID of the created route table |
| name | Returns the name of the created route table |
| object | Returns the full object of the created route table |
24 changes: 24 additions & 0 deletions examples/route_table/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Azure route table

Creates a simple route table for Azure.

## Usage

To run this example, simply execute:

```hcl
terraform init
terraform plan
terraform apply
```

Once you are done, just run
```hcl
terraform destroy
```

## Outputs

| Name | Type | Description |
| -- | -- | -- |
| object | object | Full object as returned per the module |
46 changes: 46 additions & 0 deletions examples/route_table/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
locals {
convention = "cafrandom"
name = "caftest-route-table"
name_la = "caftestlavalid"
name_diags = "caftestdiags"
location = "southeastasia"
prefix = ""
postfix = ""
max_length = 60
enable_event_hub = false
resource_groups = {
test = {
name = "test-caf-route-table"
location = "southeastasia"
},
}
tags = {
environment = "DEV"
owner = "CAF"
}
next_hop_in_dynamic_private_ip = "192.168.10.6"

route_table = {
name = "test_route"
route_entries = {
re1 = {
name = "myroute1"
prefix = "255.0.0.0/8"
next_hop_type = "None"
},
re2 = {
name = "myroute2"
prefix = "255.255.0.0/16"
next_hop_type = "VirtualAppliance"
next_hop_in_ip_address = "192.168.10.6"
},
re3 = {
name = "defaultroute"
prefix = "0.0.0.0/0"
next_hop_type = "VirtualAppliance"
next_hop_in_ip_address = "192.168.10.5"
},
}
}

}
5 changes: 5 additions & 0 deletions examples/route_table/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
output object {
value = module.route_table
sensitive = false
description = "Full object"
}
Loading

0 comments on commit 9d70354

Please sign in to comment.