Skip to content

Commit 903ca0d

Browse files
authored
Merge pull request #6 from equinix-labs/add_metal_eksa_modules
Added eksa metal and workshop-project modules
2 parents dc79439 + 709b0d0 commit 903ca0d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+846
-612
lines changed

.terraform.lock.hcl

Lines changed: 96 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 23 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,48 @@
1-
# terraform-equinix-labs
2-
3-
<!-- TEMPLATE: Review all "TEMPLATE" comments and remove them when applied. -->
4-
<!-- 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. -->
5-
[![Experimental](https://img.shields.io/badge/Stability-Experimental-red.svg)](https://github.com/equinix-labs/standards#about-uniform-standards)
6-
[![run-pre-commit-hooks](https://github.com/equinix-labs/terraform-equinix-labs/actions/workflows/pre-commit.yaml/badge.svg)](https://github.com/equinix-labs/terraform-equinix-template/actions/workflows/pre-commit.yaml)
7-
[![generate-terraform-docs](https://github.com/equinix-labs/terraform-equinix-labs/actions/workflows/documentation.yaml/badge.svg)](https://github.com/equinix-labs/terraform-equinix-template/actions/workflows/documentation.yaml)
8-
9-
## Usage
10-
11-
This project is experimental and supported by the user community. Equinix does not provide support for this project.
12-
13-
Install Terraform using the [tfenv](https://github.com/tfutils/tfenv) utility.
14-
15-
This project may be forked, cloned, or downloaded and modified as needed as the base in your integrations and deployments.
16-
17-
This project may also be used as a [Terraform module](https://learn.hashicorp.com/collections/terraform/modules).
18-
19-
To use this module in a new project, create a file such as:
20-
21-
```hcl
22-
# main.tf
23-
terraform {
24-
required_providers {
25-
equinix = {
26-
source = "equinix/equinix"
27-
}
28-
}
29-
30-
module "example" {
31-
source = "github.com/equinix-labs/template"
32-
# TEMPLATE: replace "template" with the name of the repo after the terraform-equinix- prefix.
33-
34-
# Published modules can be sourced as:
35-
# source = "equinix-labs/template/equinix"
36-
# See https://www.terraform.io/docs/registry/modules/publish.html for details.
37-
38-
# version = "0.1.0"
39-
40-
# TEMPLATE: insert required variables here
41-
}
42-
```
43-
44-
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/).
45-
46-
Configure pre-commit: `pre-commit install`.
47-
48-
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).
49-
50-
Run `terraform init -upgrade` and `terraform apply`.
51-
52-
## Module Documentation
53-
54-
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.
55-
56-
## Examples
57-
58-
To view examples for how you can leverage this module, please see the [examples](examples/) directory.
1+
# Terraform Equinix Labs Project
592

603
<!-- BEGIN_TF_DOCS -->
614
## Requirements
625

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

6810
## Providers
6911

7012
No providers.
7113

7214
## Modules
7315

74-
No modules.
16+
| Name | Source | Version |
17+
|------|--------|---------|
18+
| <a name="module_deploy_eksa"></a> [deploy\_eksa](#module\_deploy\_eksa) | ./modules/eksa | n/a |
19+
| <a name="module_deploy_metal"></a> [deploy\_metal](#module\_deploy\_metal) | ./modules/metal | n/a |
20+
| <a name="module_project_setup"></a> [project\_setup](#module\_project\_setup) | ./modules/invite-from-csv | n/a |
7521

7622
## Resources
7723

7824
No resources.
7925

8026
## Inputs
8127

82-
No inputs.
28+
| Name | Description | Type | Default | Required |
29+
|------|-------------|------|---------|:--------:|
30+
| <a name="input_eksa_config"></a> [eksa\_config](#input\_eksa\_config) | Module configuration for EKSA module | <pre>object({<br> cluster_name = string<br> cp_device_count = number<br> worker_device_count = number<br> })</pre> | <pre>{<br> "cluster_name": "equinix-labs-cluster",<br> "cp_device_count": 3,<br> "worker_device_count": 3<br>}</pre> | no |
31+
| <a name="input_enable_eksa"></a> [enable\_eksa](#input\_enable\_eksa) | Enable EKSA module | `bool` | `false` | no |
32+
| <a name="input_enable_metal"></a> [enable\_metal](#input\_enable\_metal) | Enable Metal module | `bool` | `false` | no |
33+
| <a name="input_enable_workshop_setup"></a> [enable\_workshop\_setup](#input\_enable\_workshop\_setup) | Enable Workshop Setup module | `bool` | `false` | no |
34+
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes |
35+
| <a name="input_metal_config"></a> [metal\_config](#input\_metal\_config) | Configuration for Metal module | <pre>object({<br> device_count = number<br> os = string<br> billing_cycle = string<br> cluster_name = string<br> device_type = string<br> })</pre> | <pre>{<br> "billing_cycle": "hourly",<br> "cluster_name": "metal-cluster",<br> "device_count": 3,<br> "device_type": "m3.small.x86",<br> "os": "ubuntu_20_04"<br>}</pre> | no |
36+
| <a name="input_metal_metro"></a> [metal\_metro](#input\_metal\_metro) | Equinix Metal metro | `string` | `"sv"` | no |
37+
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes |
38+
| <a name="input_metal_project_id"></a> [metal\_project\_id](#input\_metal\_project\_id) | Project ID | `string` | `""` | no |
39+
| <a name="input_metal_tags"></a> [metal\_tags](#input\_metal\_tags) | String list of common tags for Equinix resources | `list(string)` | <pre>[<br> "terraform",<br> "equinix-labs"<br>]</pre> | no |
8340

8441
## Outputs
8542

86-
No outputs.
43+
| Name | Description |
44+
|------|-------------|
45+
| <a name="output_deploy_eksa_outputs"></a> [deploy\_eksa\_outputs](#output\_deploy\_eksa\_outputs) | Outputs of the Deploy EKSA module |
46+
| <a name="output_deploy_metal_outputs"></a> [deploy\_metal\_outputs](#output\_deploy\_metal\_outputs) | Outputs of the Deploy Metal module |
47+
| <a name="output_project_setup_outputs"></a> [project\_setup\_outputs](#output\_project\_setup\_outputs) | Outputs of the Project Setup module |
8748
<!-- END_TF_DOCS -->
88-
## Contributing
89-
90-
If you would like to contribute to this module, see [CONTRIBUTING](CONTRIBUTING.md) page.
91-
92-
## License
93-
94-
Apache License, Version 2.0. See [LICENSE](LICENSE).
95-
<!-- TEMPLATE: Expand this section with any additional information or requirements. -->

examples/eksa-setup/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Terraform Equinix Labs Metal Setup Example
2+
3+
<!-- BEGIN_TF_DOCS -->
4+
## Requirements
5+
6+
| Name | Version |
7+
|------|---------|
8+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
9+
| <a name="requirement_equinix"></a> [equinix](#requirement\_equinix) | >= 1.10.0 |
10+
11+
## Providers
12+
13+
No providers.
14+
15+
## Modules
16+
17+
| Name | Source | Version |
18+
|------|--------|---------|
19+
| <a name="module_deploy_eksa"></a> [deploy\_eksa](#module\_deploy\_eksa) | ../../ | n/a |
20+
| <a name="module_workshop_setup"></a> [workshop\_setup](#module\_workshop\_setup) | ../../ | n/a |
21+
22+
## Resources
23+
24+
No resources.
25+
26+
## Inputs
27+
28+
| Name | Description | Type | Default | Required |
29+
|------|-------------|------|---------|:--------:|
30+
| <a name="input_eksa_config"></a> [eksa\_config](#input\_eksa\_config) | Module configuration for EKSA module | <pre>object({<br> cluster_name = string<br> cp_device_count = number<br> worker_device_count = number<br> })</pre> | <pre>{<br> "cluster_name": "equinix-labs-cluster",<br> "cp_device_count": 3,<br> "worker_device_count": 3<br>}</pre> | no |
31+
| <a name="input_enable_eksa"></a> [enable\_eksa](#input\_enable\_eksa) | Enable EKSA module | `bool` | `true` | no |
32+
| <a name="input_enable_workshop_setup"></a> [enable\_workshop\_setup](#input\_enable\_workshop\_setup) | Enable Workshop Setup module | `bool` | `true` | no |
33+
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes |
34+
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes |
35+
36+
## Outputs
37+
38+
| Name | Description |
39+
|------|-------------|
40+
| <a name="output_deploy_eksa_outputs"></a> [deploy\_eksa\_outputs](#output\_deploy\_eksa\_outputs) | Outputs of the Deploy EKSA module |
41+
| <a name="output_workshop_setup_outputs"></a> [workshop\_setup\_outputs](#output\_workshop\_setup\_outputs) | Outputs of the Workshop Setup module |
42+
<!-- END_TF_DOCS -->

examples/eksa-setup/main.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Setup provider block
2+
terraform {
3+
required_version = ">= 1.3"
4+
5+
required_providers {
6+
equinix = {
7+
source = "equinix/equinix"
8+
version = ">= 1.10.0"
9+
}
10+
}
11+
}
12+
13+
# Setup metal auth token for provider
14+
provider "equinix" {
15+
auth_token = var.metal_auth_token
16+
}
17+
18+
# Setup the workshop
19+
module "workshop_setup" {
20+
enable_workshop_setup = var.enable_workshop_setup
21+
source = "../../"
22+
metal_organization_id = var.metal_organization_id
23+
metal_auth_token = var.metal_auth_token
24+
}
25+
26+
# Deploy the EKSA module if platform of choice is EKSA
27+
module "deploy_eksa" {
28+
for_each = { for k, v in module.workshop_setup.project_setup_outputs[0].invite_from_csv_outputs : k => v if var.enable_eksa }
29+
enable_eksa = var.enable_eksa
30+
source = "../../"
31+
metal_organization_id = var.metal_organization_id
32+
metal_auth_token = var.metal_auth_token
33+
metal_project_id = each.value.collaborator_project_id
34+
eksa_config = var.eksa_config
35+
}

examples/eksa-setup/outputs.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Module Workshop Setup Outputs
2+
output "workshop_setup_outputs" {
3+
description = "Outputs of the Workshop Setup module"
4+
5+
value = { for k, v in module.workshop_setup.project_setup_outputs : k => v }
6+
}
7+
8+
# Module Deploy Metal Outputs
9+
output "deploy_eksa_outputs" {
10+
description = "Outputs of the Deploy EKSA module"
11+
12+
value = { for k, v in var.eksa_config : k => v }
13+
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
metal_api_token="your_token_here" #This must be a user API token
2-
organization_id="your_organization_id"
2+
metal_organization_id="your_organization_id"

examples/eksa-setup/variables.tf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Module Vars
2+
variable "metal_auth_token" {
3+
description = "Equinix Metal user api token."
4+
type = string
5+
sensitive = true
6+
}
7+
8+
variable "metal_organization_id" {
9+
type = string
10+
description = "Equinix Metal organization id"
11+
}
12+
13+
variable "enable_workshop_setup" {
14+
type = bool
15+
description = "Enable Workshop Setup module"
16+
default = true
17+
}
18+
19+
variable "enable_eksa" {
20+
type = bool
21+
description = "Enable EKSA module"
22+
default = true
23+
}
24+
25+
variable "eksa_config" {
26+
description = "Module configuration for EKSA module"
27+
type = object({
28+
cluster_name = string
29+
cp_device_count = number
30+
worker_device_count = number
31+
})
32+
default = {
33+
cluster_name = "equinix-labs-cluster"
34+
cp_device_count = 3
35+
worker_device_count = 3
36+
}
37+
}

0 commit comments

Comments
 (0)