Skip to content
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

feat: onboarding NGINX module #9

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions CONTRIBUTING.md

This file was deleted.

147 changes: 22 additions & 125 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,138 +1,35 @@
# terraform-equinix-network-edge

<!-- TEMPLATE: Review all "TEMPLATE" comments and remove them when applied. -->
<!-- TEMPLATE: replace "template" with the name of your project. The prefix "terraform-equinix-" informs the Terraform registry that this project is a Terraform module associated with the Equinix provider, preserve this prefix. -->
[![Experimental](https://img.shields.io/badge/Stability-Experimental-red.svg)](https://github.com/equinix-labs/standards#about-uniform-standards)
[![run-pre-commit-hooks](https://github.com/equinix-labs/terraform-equinix-network-edge/actions/workflows/pre-commit.yaml/badge.svg)](https://github.com/equinix/terraform-equinix-network-edge/actions/workflows/pre-commit.yaml)
[![generate-terraform-docs](https://github.com/equinix/terraform-equinix-network-edge/actions/workflows/documentation.yaml/badge.svg)](https://github.com/equinix/terraform-equinix-network-edge/actions/workflows/documentation.yaml)
[![Maintainer](https://img.shields.io/badge/maintained%20by-equinix-red?style=flat-square)](https://www.equinix.com/)
[![License](https://img.shields.io/github/license/equinix/terraform-equinix-network-edge?style=flat-square)](LICENSE)
[![Release](https://img.shields.io/github/v/release/equinix/terraform-equinix-network-edge?style=flat-square)](https://github.com/equinix/terraform-equinix-network-edge/releases)
[![Terraform version](https://img.shields.io/badge/terraform-%3E%3D1.5.4-623CE4.svg?style=flat-square&logo=terraform)](https://github.com/hashicorp/terraform)
[![Terraform registry](https://img.shields.io/badge/terraform-registry-623CE4.svg?style=flat-square&logo=terraform)](https://registry.terraform.io/modules/equinix/network-edge/equinix/latest)

`terraform-equinix-network-edge` is a minimal Terraform module that
utilizes [Terraform providers for Equinix](https://registry.terraform.io/namespaces/equinix) to provision digital
infrastructure and demonstrate higher level integrations.
> This is a empty module that houses multiple submodules for Equinix Network Edge Terraform usage. Please view the Submodules
> and the Examples in this module's registry to view details on what they are and how to leverage them.

<!-- TEMPLATE: Insert an image here of the infrastructure diagram. You can generate a starting image using instructions found at https://www.terraform.io/docs/cli/commands/graph.html#generating-images -->
## Equinix Network Edge Developer Documentation

## Usage

This project is experimental and supported by the user community. Equinix does not provide support for this project.

Install Terraform using the [tfenv](https://github.com/tfutils/tfenv) utility.

This project may be forked, cloned, or downloaded and modified as needed as the base in your integrations and
deployments.

This project may also be used as a [Terraform module](https://learn.hashicorp.com/collections/terraform/modules).

To use this module in a new project, create a file such as:

```hcl
# main.tf
terraform {
required_providers {
equinix = {
source = "equinix/equinix"
}
}

module "example" {
source = "github.com/equinix-labs/template"
# TEMPLATE: replace "template" with the name of the repo after the terraform-equinix- prefix.

# Published modules can be sourced as:
# source = "equinix-labs/template/equinix"
# See https://www.terraform.io/docs/registry/modules/publish.html for details.

# version = "0.1.0"

# TEMPLATE: insert required variables here
}
}
```

Install [pre-commit](https://pre-commit.com/#install) with its
prerequesites: [python](https://docs.python.org/3/using/index.html)
and [pip](https://pip.pypa.io/en/stable/installation/).

Configure pre-commit: `pre-commit install`.

Install required
packages: [tflint](https://github.com/terraform-linters/tflint), [tfsec](https://aquasecurity.github.io/tfsec/v1.0.11/getting-started/installation/), [shfmt](https://github.com/mvdan/sh), [shellcheck](https://github.com/koalaman/shellcheck),
and [markdownlint](https://github.com/markdownlint/markdownlint).

Run `terraform init -upgrade` and `terraform apply`.

## Module Documentation

The main README.md, the modules README.md and the examples README.md are populated
by [terraform-docs worflow job](.github/workflows/documentation.yaml). The following sections are appended between the
terraform-docs delimeters: Requiremenents, Providers, Modules, Resources, Inputs, and Outputs.

## Module Release and Changelog Generation

The module git release and [changelog](CHANGELOG.md) are generated by
the [release workflow job](.github/workflows/release.yaml). The release worflow follows
the [conventional commits convention](https://www.conventionalcommits.org/). To submit a commit, please follow
the [commit message format guidelines](https://www.conventionalcommits.org/en/v1.0.0/#specification). This job is set to
run manually by default.

Example commit message: `fix: disabled log generation for system services`

For more examples, please
see [conventional commit message examples](https://www.conventionalcommits.org/en/v1.0.0/#examples).

## Examples

To view examples for how you can leverage this module, please see the [examples](examples/) directory.

<!-- TEMPLATE: The following block has been generated by terraform-docs util: https://github.com/terraform-docs/terraform-docs -->
<!-- BEGIN_TF_DOCS -->
displague marked this conversation as resolved.
Show resolved Hide resolved

## Requirements

| Name | Version |
|---------------------------------------------------------------------------|----------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
| <a name="requirement_equinix"></a> [equinix](#requirement\_equinix) | >= 1.8.0 |

## Providers

| Name | Version |
|---------------------------------------------------------------|----------|
| <a name="provider_equinix"></a> [equinix](#provider\_equinix) | >= 1.8.1 |
To see the documentation for the APIs that the Network Edge Terraform Provider is built on
and to learn how to procure your own Client_Id and Client_Secret follow the link below:
[Equinix Network Edge Developer Portal](https://developer.equinix.com/docs?page=/dev-docs/NE/overview)

## Modules

| Name | Source | Version |
|-----------------------------------------------------------------------------|-------------------------|---------|
| <a name="module_inline-module"></a> [inline-module](#module\_inline-module) | ./modules/inline-module | n/a |

## Resources

| Name | Type |
|----------------------------------------------------------------------------------------------------------------------------|----------|
| [equinix_metal_device.example](https://registry.terraform.io/providers/equinix/equinix/latest/docs/resources/metal_device) | resource |

## Inputs
This repository consists of a collection of modules designed to accelerate your adoption of Equinix Terraform for Network Edge use cases.
Each module is fully independent and dedicated for use as individual modules. They are placed here to organize all Network Edge use cases
and to facilitate efficient discovery and selection of product offerings beyond the base Network Edge data sources and resources.

| Name | Description | Type | Default | Required |
|----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|----------|---------|:--------:|
| <a name="input_example_auth_token"></a> [example\_auth\_token](#input\_example\_auth\_token) | The example auth token value defines what will be included in the example resource in main.tf. This example is descriptive. | `string` | n/a | yes |
| <a name="input_example_project_id"></a> [example\_project\_id](#input\_example\_project\_id) | The example project id value defines what will be included in the example resource in main.tf. This example is descriptive. | `string` | n/a | yes |
Each module has:

## Outputs
* Terraform source code to be used as a module
* README.md file containing instructions and specific notes to work with the module

| Name | Description |
|---------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
| <a name="output_example_device_hostname"></a> [example\_device\_hostname](#output\_example\_device\_hostname) | The example output. In practice, output value reference implicit resource attributes declared in main.tf |
| <a name="output_example_gateway_id"></a> [example\_gateway\_id](#output\_example\_gateway\_id) | The example output. In practice, output value reference implicit resource attributes declared in main.tf |

<!-- END_TF_DOCS -->

## Contributing

If you would like to contribute to this module, see [CONTRIBUTING](CONTRIBUTING.md) page.
## Examples

## License
Each example is a specific use case in Equinix Network Edge that the specific sub-module can be used for. Each example has the following:

Apache License, Version 2.0. See [LICENSE](LICENSE).
<!-- TEMPLATE: Expand this section with any additional information or requirements. -->
* Terraform code leveraging the module for a simple use case
* Example definition of .tfvars file
* README.md explaining multiple ways the example can be leveraged.
28 changes: 28 additions & 0 deletions examples/nginx/nginx-cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Network Edge Device Nginx cluster Device Example

This example demonstrates creation of Network Edge NGINX HA pair device. It will:

- Create a management ACL template
- Create a SSH key
- Provision NGINX cluster device

## Usage

To provision this example, you should clone the github repository and run terraform from within this directory:

```bash
git clone https://github.com/equinix-labs/terraform-equinix-nework-edge-device-nginx.git
cd terraform-equinix-nework-edge-device-nginx/examples/nginx-cluster
terraform init
terraform apply
```

Note that this example may create resources which cost money. Run 'terraform destroy' when you don't need these resources.

## Variables

See <https://registry.terraform.io/modules/equinix-labs/network-edge-device-nginx/equinix/latest?tab=inputs> for a description of all variables.

## Outputs

See <https://registry.terraform.io/modules/equinix-labs/network-edge-device-nginx/equinix/latest?tab=outputs> for a description of all outputs.
43 changes: 43 additions & 0 deletions examples/nginx/nginx-cluster/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
provider "equinix" {
client_id = var.equinix_client_id
client_secret = var.equinix_client_secret
}

module "nginx_cluster" {
source = "../../../modules/nginx"
name = "terraform-test-NGINX-cluster1"
metro_code = var.metro_code_primary
account_number = "123456"
platform = "small"
software_package = "STD"
term_length = 1
notifications = ["[email protected]"]
additional_bandwidth = 50
mgmt_acl_template_uuid = equinix_network_acl_template.nginx_cluster.id
ssh_key = {
userName = "johndoe"
keyName = equinix_network_ssh_key.jd_cluster.name
}
cluster = {
enabled = true
name = "test-nginx-cluster"
node0_vendor_configuration_hostname = "node0"
node1_vendor_configuration_hostname = "node1"
}
}

resource "equinix_network_ssh_key" "jd_cluster" {
name = "jd-cluster"
public_key = var.ssh_rsa_public_key
}

resource "equinix_network_acl_template" "nginx_cluster" {
name = "tf-nginx-cluster"
description = "Cluster NGINX ACL template"
inbound_rule {
subnet = "172.16.25.0/24"
protocol = "TCP"
src_port = "any"
dst_port = "22"
}
}
4 changes: 4 additions & 0 deletions examples/nginx/nginx-cluster/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "device_details" {
description = "Virtual device details"
value = module.nginx_cluster
}
18 changes: 18 additions & 0 deletions examples/nginx/nginx-cluster/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
variable "equinix_client_id" {
type = string
description = "API Consumer Key available under 'My Apps' in developer portal. This argument can also be specified with the EQUINIX_API_CLIENTID shell environment variable."
}

variable "equinix_client_secret" {
type = string
description = "API Consumer secret available under 'My Apps' in developer portal. This argument can also be specified with the EQUINIX_API_CLIENTSECRET shell environment variable."
}

variable "metro_code_primary" {
description = "Device location metro code"
type = string
}
variable "ssh_rsa_public_key" {
description = "SSH RSA public key"
type = string
}
9 changes: 9 additions & 0 deletions examples/nginx/nginx-cluster/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_version = ">= 1.3"
required_providers {
equinix = {
source = "equinix/equinix"
version = "~> 1.34.0"
}
}
}
28 changes: 28 additions & 0 deletions examples/nginx/nginx-ha/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Network Edge Device Nginx HA pair Device Example

This example demonstrates creation of Network Edge NGINX HA pair device. It will:

- Create a management ACL template for primary and secondary device
- Create a SSH key
- Provision NGINX HA pair device

## Usage

To provision this example, you should clone the github repository and run terraform from within this directory:

```bash
git clone https://github.com/equinix-labs/terraform-equinix-nework-edge-device-nginx.git
cd terraform-equinix-nework-edge-device-nginx/examples/nginx-ha
terraform init
terraform apply
```

Note that this example may create resources which cost money. Run 'terraform destroy' when you don't need these resources.

## Variables

See <https://registry.terraform.io/modules/equinix-labs/network-edge-device-nginx/equinix/latest?tab=inputs> for a description of all variables.

## Outputs

See <https://registry.terraform.io/modules/equinix-labs/network-edge-device-nginx/equinix/latest?tab=outputs> for a description of all outputs.
57 changes: 57 additions & 0 deletions examples/nginx/nginx-ha/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
provider "equinix" {
client_id = var.equinix_client_id
client_secret = var.equinix_client_secret
}

module "nginx_ha" {
source = "../../../modules/nginx"
name = "terraform-test-NGINX-ha"
hostname = "nginx-pri"
metro_code = var.metro_code_primary
account_number = "123456"
platform = "small"
software_package = "STD"
term_length = 1
notifications = ["[email protected]"]
additional_bandwidth = 50
mgmt_acl_template_uuid = equinix_network_acl_template.nginx_pri.id
ssh_key = {
userName = "johndoe-primary"
keyName = equinix_network_ssh_key.johndoe.name
}
secondary = {
enabled = true
metro_code = var.metro_code_secondary
hostname = "nginx-sec"
account_number = "135887"
additional_bandwidth = 50
mgmt_acl_template_uuid = equinix_network_acl_template.nginx_sec.id
}
}

resource "equinix_network_ssh_key" "johndoe" {
name = "johndoe-secondary"
public_key = var.ssh_rsa_public_key
}

resource "equinix_network_acl_template" "nginx_pri" {
name = "tf-nginx-pri"
description = "Primary NGINX management ACL template"
inbound_rule {
subnet = "172.16.25.0/24"
protocol = "TCP"
src_port = "any"
dst_port = "22"
}
}

resource "equinix_network_acl_template" "nginx_sec" {
name = "tf-vsrx-sec"
description = "Secondary NGINX management ACL template"
inbound_rule {
subnet = "193.39.0.0/16"
protocol = "TCP"
src_port = "any"
dst_port = "22"
}
}
4 changes: 4 additions & 0 deletions examples/nginx/nginx-ha/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "device_details" {
description = "Virtual device details"
value = module.nginx_ha
}
Loading
Loading