From 64f49c532bf2e9f42b54ff7bc5efbd48fc66b3b9 Mon Sep 17 00:00:00 2001 From: ocobleseqx Date: Tue, 16 Jan 2024 12:14:13 +0100 Subject: [PATCH 1/4] pre-commit changes Signed-off-by: ocobleseqx --- .github/workflows/documentation.yaml | 53 +++++++++++ .github/workflows/pre-commit.yaml | 72 +++++++++++++++ .github/workflows/release.yaml | 28 ++++++ .pre-commit-config.yaml | 87 +++++++++++++++++++ .tflint.hcl | 5 ++ .vscode/settings.json | 2 + CHANGELOG.md | 36 +------- CODEOWNERS | 2 +- CODE_OF_CONDUCT.md | 76 ++++++++++++++++ CONTRIBUTING.md | 31 +++++++ README.md | 86 +++++++++--------- .../fabric-port-connection-to-sp/README.md | 14 ++- 12 files changed, 413 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/documentation.yaml create mode 100644 .github/workflows/pre-commit.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 .tflint.hcl create mode 100644 .vscode/settings.json create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml new file mode 100644 index 0000000..416f7af --- /dev/null +++ b/.github/workflows/documentation.yaml @@ -0,0 +1,53 @@ +name: generate-terraform-docs +# This workflow will generate terraform docs into README.md in the root, examples, and modules folders. +# Source: https://github.com/equinix-labs/terraform-equinix-kubernetes-addons/blob/main/.github/workflows/documentation.yaml + +on: + push: + branches: + - main + paths: + - '**/*.tpl' + - '**/*.tf' + +jobs: + tf-docs: + name: TF docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + id: actions-checkout + with: + ref: main + + - name: Render terraform docs inside the main and the modules README.md files and push changes back to PR branch + id: terraform-docs + uses: terraform-docs/gh-actions@v1.0.0 + with: + find-dir: . + args: --sort-by required + indention: 2 + git-push: "false" + + # terraform-docs/gh-actions@v1.0.0 modifies .git files with owner root:root, and the following steps fail with + # insufficient permission for adding an object to repository database .git/objects + # since the expected user is runner:docker. See https://github.com/terraform-docs/gh-actions/issues/90 + - name: Fix .git owner + run: sudo chown runner:docker -R .git + + - name: Create Pull Request + if: steps.terraform-docs.outputs.num_changed != '0' + uses: peter-evans/create-pull-request@v5 + with: + commit-message: 'docs: generate-terraform-docs: automated action' + committer: GitHub + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + title: 'generate-terraform-docs: automated action' + body: | + Update terraform docs + branch-suffix: timestamp + base: main + signoff: true + delete-branch: true + + # TODO(ocobleseqx): https://github.com/peter-evans/enable-pull-request-automerge diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 0000000..2e914ab --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -0,0 +1,72 @@ +name: 'run-pre-commit-hooks' +# This workflow runs the pre-commit hooks defined in .pre-commit-config.yaml + +on: + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + pre-commit: + runs-on: ${{ matrix.os }} + env: + TF_VERSION: ${{ matrix.tf }} + TFLINT_VERSION: ${{ matrix.tflint }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + strategy: + matrix: + os: [ubuntu-latest] + tf: [1.3.0] + tflint: [v0.44.1] + permissions: + pull-requests: write + id-token: write + contents: read + steps: + - name: Checkout from Github + uses: actions/checkout@v4 + + - name: Install Python3 + uses: actions/setup-python@v5 + + - name: Install tflint + uses: terraform-linters/setup-tflint@v4 + with: + tflint_version: ${{ env.TFLINT_VERSION }} + + - name: Cache tflint plugin dir + uses: actions/cache@v3 + with: + path: ~/.tflint.d/plugins + key: ${{ matrix.os }}-tflint-${{ hashFiles('.tflint.hcl') }} + + - name: Install Terraform + uses: hashicorp/setup-terraform@v3 + with: + terraform_version: ${{ env.TF_VERSION }} + + - name: Config Terraform plugin cache + run: | + echo 'plugin_cache_dir="$HOME/.terraform.d/plugin-cache"' >~/.terraformrc + mkdir --parents ~/.terraform.d/plugin-cache + + - name: Cache Terraform + uses: actions/cache@v3 + with: + path: | + ~/.terraform.d/plugin-cache + key: ${{ runner.os }}-terraform-${{ hashFiles('**/.terraform.lock.hcl') }} + restore-keys: | + ${{ runner.os }}-terraform- + + - name: Install tfsec + uses: jaxxstorm/action-install-gh-release@v1.5.0 + with: + repo: aquasecurity/tfsec + platform: linux + arch: x86-64 + + - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..01ca2f7 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,28 @@ +name: generate-release +# This workflow will generate changelog and release notes. +# Source: https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/master/.github/workflows/release.yml + +on: + workflow_dispatch: + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Release + uses: cycjimmy/semantic-release-action@v3 + with: + semantic_version: 19.0.5 + extra_plugins: | + @semantic-release/changelog@6.0.0 + @semantic-release/git@10.0.0 + conventional-changelog-conventionalcommits@4.6.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d37af30 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,87 @@ +--- +fail_fast: false +repos: + +- repo: https://github.com/antonbabenko/pre-commit-terraform + rev: v1.77.1 + hooks: + - id: terraform_fmt + args: + - "--args=-recursive" + - id: terraform_validate + exclude: "^[^/]+$" + - id: terraform_tflint + args: + - "--args=--config=__GIT_WORKING_DIR__/.tflint.hcl" + - id: terraform_tfsec + args: + - "--args=--soft-fail" + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + # Git style + - id: check-added-large-files + - id: check-merge-conflict + - id: check-vcs-permalinks + - id: forbid-new-submodules + - id: no-commit-to-branch + args: ['--branch', 'master'] + + # Common errors + - id: end-of-file-fixer + - id: trailing-whitespace + args: + - "--markdown-linebreak-ext=md" + exclude: CHANGELOG.md + - id: check-yaml + args: + - "--allow-multiple-documents" + exclude: | + (?x)^( + examples/| + \.*?.yaml$" + )$ + - id: check-json + - id: check-symlinks + - id: check-executables-have-shebangs + + # Cross platform + - id: check-case-conflict + - id: mixed-line-ending + args: + - "--fix=lf" + + # Security + - id: detect-private-key + +# Shell Script Formatter and Markdown Linter +- repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 + hooks: + - id: shfmt + exclude: | + (?x)^( + helpers/helper-script.sh| + scripts/template-script.sh + )$ + - id: shellcheck + args: + - "--severity=warning" + - "--source-path=SCRIPTDIR scripts/* helpers/*" + - "--shell=bash" + exclude: | + (?x)^( + helpers/helper-script.sh| + scripts/template-script.sh + )$ + - id: markdownlint + exclude: "CHANGELOG.md" + +# JSON5 and Yaml Prettyfier +- repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.0.0-alpha.4 + hooks: + - id: prettier + types: [json5, yaml] + exclude: "^examples/" diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..18e65e4 --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,5 @@ +plugin "terraform" { + enabled = true + version = "0.5.0" + source = "github.com/terraform-linters/tflint-ruleset-terraform" +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} diff --git a/CHANGELOG.md b/CHANGELOG.md index d3391dc..0cf3ded 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,35 +1 @@ -## 0.3.1 (July 20, 2022) - -BUG FIXES: - -- `equinix_ecx_l2_connection.seller_metro_code` and `equinix_ecx_l2_connection.seller_region` must be null if `seller_profile_name` is not specified - -## 0.3.0 (July 19, 2022) - -FEATURES: - -- Added input variable `zside_service_token_id` to support single connections using z-side Equinix Service Tokens - -BUG FIXES: - -- typo `purchase_order` was `purcharse_order` [#1](https://github.com/equinix-labs/terraform-equinix-fabric-connection/issues/1) - -## 0.2.0 (April 27, 2022) - -FEATURES: - -- Supported definition of `additional_info` blocks. - -## 0.1.1 (April 18, 2022) - -BUG FIXES: - -- `-PRI` suffix was added to the name of primary connection even if there was no secondary connection. - -## 0.1.0 (March 25, 2022) - -Initial release. - -FEATURES: - -- Supported single and redundant connections from Equinix Fabric Port , Network Edge Device, Equinix Service Token. +Release notes for this repository can be found on the [releases page](https://github.com/equinix-labs/terraform-equinix-fabric-connection/releases) diff --git a/CODEOWNERS b/CODEOWNERS index 71917cd..024e229 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,3 +1,3 @@ # TEMPLATE: add your username after terraform # TEMPLATE: * equinix-labs/terraform myusername -* @ocobleseqx +* @equinix-labs/terraform diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..eecaf7d --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at devrel [at] packet [dot] com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 1.4, available at + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..72390fc --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# Contributing + +This document provides guidelines for contributing to the module. + +Contributors to this project must abide by the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md). + +## File structure + +The project has the following folders and files: + +- /: root folder. +- /docs: Examples for using this module. +- /examples: Examples for using this module. +- /files: Static files referenced but not executed by Terraform. +- /helpers: Helper scripts NOT called by Terraform. +- /modules: Inline local modules called by this module. +- /scripts: Scripts for specific tasks on module. +- /templates: Template files used to be execute by data sources. +- /main.tf: Main file for this module, contains all the resources to operate + the module. +- /variables.tf: All the variables necessary for run the module. +- /output.tf: The outputs generate from the module. +- /README.md: Main repo README document. +- /CHANGELOG.md: Module release changelog file. +- /CODEOWNERS: Module contributing developers. +- /CODE_OF_CONDUCT.md: Code of Conduct file. +- /CONTRIBUTING.md: This file. + +## Issues and Change Requests + +Please submit change requests and / or features via [Issues](https://github.com/equinix-labs/terraform-equinix-fabric-connection/issues). diff --git a/README.md b/README.md index 8e41a07..3f39061 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,64 @@ -## Equinix Fabric L2 Connection Terraform module +# Equinix Fabric L2 Connection Terraform module [![Experimental](https://img.shields.io/badge/Stability-Experimental-red.svg)](https://github.com/equinix-labs/standards#about-uniform-standards) [![terraform](https://github.com/equinix-labs/terraform-equinix-template/actions/workflows/integration.yaml/badge.svg)](https://github.com/equinix-labs/terraform-equinix-template/actions/workflows/integration.yaml) -`terraform-equinix-fabric-connection` is a minimal Terraform module that utilizes [Terraform provider for Equinix](https://registry.terraform.io/providers/equinix/equinix/latest) to set up an Equinix Fabric L2 connection. +`terraform-equinix-fabric-connection` is a minimal Terraform module that +utilizes the [Terraform provider for Equinix](https://registry.terraform.io/providers/equinix/equinix/latest) +to set up an Equinix Fabric L2 connection. -As part of Platform Equinix, your infrastructure can connect with other parties, such as public cloud providers, network service providers, or your own colocation cages in Equinix by defining an [Equinix Fabric - software-defined interconnection](https://docs.equinix.com/en-us/Content/Interconnection/Fabric/Fabric-landing-main.htm). +As part of Platform Equinix, your infrastructure can connect with other +parties, such as public cloud providers, network service providers, or your own +colocation cages in Equinix by defining an [Equinix Fabric - software-defined interconnection](https://docs.equinix.com/en-us/Content/Interconnection/Fabric/Fabric-landing-main.htm). -```html - Origin Destination - (A-side) (Z-side) +```mermaid +graph LR +subgraph A-side["Origin (A-side)"] +A-side-node1[Equinix Fabric Port /
Network Edge Device /
Service Token] +end -┌────────────────┐ ┌────────────────────┐ -│ Equinix Fabric │ Equinix Fabric │ │ -│ Port / Network ├───── l2 connection ───────►│ Service Provider / │ -│ Edge Device / │ (50 Mbps - 10 Gbps) │ Customer / My self │ -│ Service Token │ │ │ -└────────────────┘ └────────────────────┘ +subgraph Z-side["Destination (Z-side)"] +Z-side-node1[Service Provider /
Customer /
Colo] +end + +A-side-node1 -->|"Equinix Fabric
L2 Connection
(50Mbps - 10Gbps)"| Z-side-node1 ``` --> **NOTE:** -Setting Up an Equinix Fabric connection requires combine and configure several parameters depending on the origin and destination types. It also requires configuration in the platform of the service you are connecting to, such as creating an Interconnect Attachment in Google Cloud platform, or approving a Direct Connect request in AWS. Although this module can be used directly, it is intended to be consumed by other service-specific modules to abstract you from this process and to include also all the necessary configuration on the target platform. +--> **NOTE:** +To establish an Equinix Fabric connection, you need to combine and configure +various parameters based on the types of origin and destination. Additionally, +you must configure the platform of the service you are connecting to, such as +creating an Interconnect Attachment in Google Cloud platform or approving a +Direct Connect request in AWS. While this module can be utilized independently, +its primary purpose is to be utilized by other service-specific modules. This +abstraction simplifies the process and includes all the required configuration +on the target platform. -Follow the link below and checkout the available service-specific modules: +Please click on the link below to explore the available service-specific +modules: -https://registry.terraform.io/search/modules?namespace=equinix-labs&q=fabric-connection +[Available service-specific modules](https://registry.terraform.io/search/modules?namespace=equinix-labs&q=fabric-connection) -### Usage +## Usage -This project is experimental and supported by the user community. Equinix does not provide support for this project. +Please note that this project is experimental and is supported by the user +community. Equinix does not provide support for this project. -Install Terraform using the official guides at . +To install Terraform, please refer to the official guides at [Install Terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli). -This project may be forked, cloned, or downloaded and modified as needed as the base in your integrations and deployments. +You are free to fork, clone, or download this project and modify it as needed +for your integrations and deployments. -This project may also be used as a [Terraform module](https://learn.hashicorp.com/collections/terraform/modules). +Additionally, you can use this project as a [Terraform module](https://learn.hashicorp.com/collections/terraform/modules). -To use this module in a new project, create a file such as: +To utilize this module in a new project, create a file such as: ```hcl # main.tf provider "equinix" {} module "equinix_fabric_connection" { - source = "equinix-labs/fabric-connection/equinix" + source = "equinix-labs/fabric-connection/equinix" # required variables notification_users = ["example@equinix.com"] @@ -63,25 +78,18 @@ module "equinix_fabric_connection" { Run `terraform init -upgrade` and `terraform apply`. -### Variables - -See for a description of all variables. + + -### Outputs +## Examples -See for a description of all outputs. +- [Fabric Port connection to Service Provider](https://registry.terraform.io/modules/equinix-labs/fabric-connection/equinix/latest/examples/fabric-port-connection-to-sp/) -### Resources +## Contributing -| Name | Type | -|------|------| -| [random_string.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource | -| [equinix_ecx_l2_connection.this](https://registry.terraform.io/providers/equinix/equinix/latest/docs/resources/equinix_ecx_l2_connection) | resource | -| [equinix_ecx_l2_sellerprofile.this](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/equinix_ecx_l2_sellerprofile) | data source | -| [equinix_ecx_port.primary](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/equinix_ecx_port) | data source | -| [equinix_ecx_port.secondary](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/equinix_ecx_port) | data source | -| [equinix_ecx_port.zside](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/equinix_ecx_port) | data source | +If you would like to contribute to this module, see the [CONTRIBUTING](CONTRIBUTING.md) +page. -### Examples +## License -- [Fabric Port connection to Service Provider](https://registry.terraform.io/modules/equinix-labs/fabric-connection/equinix/latest/examples/fabric-port-connection-to-sp/) +Apache License, Version 2.0. See [LICENSE](LICENSE). diff --git a/examples/fabric-port-connection-to-sp/README.md b/examples/fabric-port-connection-to-sp/README.md index 9db794a..c32c385 100644 --- a/examples/fabric-port-connection-to-sp/README.md +++ b/examples/fabric-port-connection-to-sp/README.md @@ -1,11 +1,13 @@ -## Fabric Port connection to Service Provider Example +# Fabric Port connection to Service Provider Example -This example demonstrates usage of the Equinix Connection module to establish a non-redundant Equinix Fabric L2 Connection from a +This example demonstrates usage of the Equinix Connection module to establish +a non-redundant Equinix Fabric L2 Connection from a Network Edge Device to AWS Direct Connect. ## Usage -To provision this example, you should clone the github repository and run terraform from within this directory: +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-fabric-connection.git @@ -14,4 +16,8 @@ terraform init terraform apply ``` -Note that this example may create resources which cost money. Run 'terraform destroy' when you don't need these resources. +Note that this example may create resources which cost money. Run +'terraform destroy' when you don't need these resources. + + + From 6593c5ade307a10dfa1b72af209723763be6d3ff Mon Sep 17 00:00:00 2001 From: ocobleseqx Date: Tue, 16 Jan 2024 12:27:34 +0100 Subject: [PATCH 2/4] add mdlrc style config Signed-off-by: ocobleseqx --- .mdl_style.rb | 7 +++++++ .mdlrc | 1 + 2 files changed, 8 insertions(+) create mode 100644 .mdl_style.rb create mode 100644 .mdlrc diff --git a/.mdl_style.rb b/.mdl_style.rb new file mode 100644 index 0000000..3896394 --- /dev/null +++ b/.mdl_style.rb @@ -0,0 +1,7 @@ +all + +exclude_rule 'MD013' +rule 'MD029', style: ['ordered'] +exclude_rule 'MD033' +exclude_rule 'MD041' +exclude_rule 'MD047' diff --git a/.mdlrc b/.mdlrc new file mode 100644 index 0000000..1f82ca2 --- /dev/null +++ b/.mdlrc @@ -0,0 +1 @@ +style '.mdl_style.rb' From f4e6d520cfa59fa2443d3f7a9ce8938791091b9c Mon Sep 17 00:00:00 2001 From: ocobleseqx Date: Tue, 16 Jan 2024 12:32:44 +0100 Subject: [PATCH 3/4] configure gh action to generate changelog Signed-off-by: ocobleseqx --- .releaserc.json | 44 ++++++++++++++++++++++++++++++++++++++++++++ CHANGELOG.md | 1 - 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .releaserc.json diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..4e8212e --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,44 @@ +{ + "branches": [ + "main" + ], + "ci": false, + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits" + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits" + } + ], + [ + "@semantic-release/github", + { + "successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:", + "labels": false, + "releasedLabels": false + } + ], + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md", + "changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file." + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "CHANGELOG.md" + ], + "message": "chore(release): version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + } + ] + ] + } diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cf3ded..e69de29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +0,0 @@ -Release notes for this repository can be found on the [releases page](https://github.com/equinix-labs/terraform-equinix-fabric-connection/releases) From b4388edcb051ffc498b0219a9aee0cf4056a8029 Mon Sep 17 00:00:00 2001 From: ocobleseqx Date: Tue, 16 Jan 2024 13:44:46 +0100 Subject: [PATCH 4/4] fixed pre-commit errors Signed-off-by: ocobleseqx --- .github/workflows/documentation.yaml | 2 +- .gitignore | 29 ++++++++--- examples/fabric-port-connection-to-sp/main.tf | 18 ++----- .../fabric-port-connection-to-sp/outputs.tf | 14 +++++ .../fabric-port-connection-to-sp/variables.tf | 0 .../fabric-port-connection-to-sp/versions.tf | 2 +- locals.tf | 24 ++++----- main.tf | 52 +++++++++---------- variables.tf | 8 +-- versions.tf | 4 ++ 10 files changed, 90 insertions(+), 63 deletions(-) create mode 100644 examples/fabric-port-connection-to-sp/outputs.tf rename .terraform.lock.hcl => examples/fabric-port-connection-to-sp/variables.tf (100%) diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 416f7af..effbd63 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -50,4 +50,4 @@ jobs: signoff: true delete-branch: true - # TODO(ocobleseqx): https://github.com/peter-evans/enable-pull-request-automerge + # TODO(ocobles): https://github.com/peter-evans/enable-pull-request-automerge diff --git a/.gitignore b/.gitignore index a7ac1de..432bd68 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,33 @@ +# OSX leaves these everywhere on SMB shares +._* + +# OSX trash +**/.DS_Store +*.pyc* + +# Emacs save files +*~ +\#*\# +.\#* + +# Vim-related files +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +*.un~ +Session.vim +.netrwhist + # Local .terraform directories **/.terraform/* +**/*/.terraform/* .terraform* # .tfstate files *.tfstate *.tfstate.* +.terraform.lock.hcl + # Crash log files crash.log @@ -22,14 +44,9 @@ override.tf.json *_override.tf *_override.tf.json -# Include override files you do wish to add to version control using negated pattern -# -# !example_override.tf -!.terraform.lock.hcl - # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan # example: *tfplan* -terraform.tfvars +**/terraform.tfvars util/keys *-kubeconfig diff --git a/examples/fabric-port-connection-to-sp/main.tf b/examples/fabric-port-connection-to-sp/main.tf index a90ef05..751e72b 100644 --- a/examples/fabric-port-connection-to-sp/main.tf +++ b/examples/fabric-port-connection-to-sp/main.tf @@ -3,8 +3,10 @@ provider "equinix" { client_secret = "someSecret" } -module "equinix-fabric-connection" { - source = "equinix-labs/fabric-connection/equinix" +module "equinix_fabric_connection" { + # TEMPLATE: Replace this path with the Git repo path or Terraform Registry path + # source = "equinix-labs/fabric-connection/equinix" + source = "../.." # required variables notification_users = ["example@equinix.com"] @@ -15,15 +17,3 @@ module "equinix-fabric-connection" { seller_authorization_key = "AWS-account-ID" network_edge_id = "NE-device-Uuid" } - -output "fabric_connection_id" { - value = module.equinix-fabric-connection.primary_connection.id -} - -output "fabric_connection_status" { - value = module.equinix-fabric-connection.primary_connection.status -} - -output "fabric_connection_provider_status" { - value = module.equinix-fabric-connection.primary_connection.provider_status -} diff --git a/examples/fabric-port-connection-to-sp/outputs.tf b/examples/fabric-port-connection-to-sp/outputs.tf new file mode 100644 index 0000000..72d3d33 --- /dev/null +++ b/examples/fabric-port-connection-to-sp/outputs.tf @@ -0,0 +1,14 @@ +output "fabric_connection_id" { + description = "Primary connection id." + value = module.equinix_fabric_connection.primary_connection.id +} + +output "fabric_connection_status" { + description = "Primary connection equinix status." + value = module.equinix_fabric_connection.primary_connection.status +} + +output "fabric_connection_provider_status" { + description = "Primary connection provider status." + value = module.equinix_fabric_connection.primary_connection.provider_status +} diff --git a/.terraform.lock.hcl b/examples/fabric-port-connection-to-sp/variables.tf similarity index 100% rename from .terraform.lock.hcl rename to examples/fabric-port-connection-to-sp/variables.tf diff --git a/examples/fabric-port-connection-to-sp/versions.tf b/examples/fabric-port-connection-to-sp/versions.tf index d650ff0..1a28bf0 100644 --- a/examples/fabric-port-connection-to-sp/versions.tf +++ b/examples/fabric-port-connection-to-sp/versions.tf @@ -1,4 +1,4 @@ -terraform { +terraform { required_version = ">= 0.13" required_providers { diff --git a/locals.tf b/locals.tf index 739b978..b4661f6 100644 --- a/locals.tf +++ b/locals.tf @@ -40,25 +40,25 @@ locals { } ) : var.notification_users_by_type - // TODO (ocobles) consider VG, IGW, SUBNET, GW use cases - // TODO (ocobles) replace aside_ap_type line below to support FCR + # TODO (ocobles) consider VG, IGW, SUBNET, GW use cases + # TODO (ocobles) replace aside_ap_type line below to support FCR # aside_ap_type = var.network_edge_id != "" ? "VD" : var.cloud_router_id != "" ? "CLOUD_ROUTER" : "COLO" aside_ap_type = var.network_edge_id != "" ? "VD" : "COLO" - // TODO (ocobles) replace zside_ap_type line below to support Fabric Network + # TODO (ocobles) replace zside_ap_type line below to support Fabric Network # zside_ap_type = (var.zside_port_name != "" || var.zside_service_token_id != "") ? "COLO" : var.network_id != "" ? "NETWORK" : "SP" - zside_ap_type = (var.zside_port_name != "" || var.zside_service_token_id != "") ? "COLO" : "SP" + zside_ap_type = (var.zside_port_name != "" || var.zside_service_token_id != "") ? "COLO" : "SP" - link_protocol_type = var.port_name != "" ? one(data.equinix_fabric_ports.primary[0].data.0.encapsulation).type : "" - secondary_link_protocol_type = var.redundancy_type == "REDUNDANT" && var.port_name != "" ? one(data.equinix_fabric_ports.secondary[0].data.0.encapsulation).type : "" - zside_link_protocol_type = var.zside_port_name != "" ? one(data.equinix_fabric_ports.zside[0].data.0.encapsulation).type : "" + link_protocol_type = var.port_name != "" ? one(data.equinix_fabric_ports.primary[0].data[0].encapsulation).type : "" + secondary_link_protocol_type = var.redundancy_type == "REDUNDANT" && var.port_name != "" ? one(data.equinix_fabric_ports.secondary[0].data[0].encapsulation).type : "" + zside_link_protocol_type = var.zside_port_name != "" ? one(data.equinix_fabric_ports.zside[0].data[0].encapsulation).type : "" connection_type = var.connection_type != "" ? var.connection_type : ( - local.link_protocol_type == "UNTAGGEDEPL" && local.zside_link_protocol_type == "UNTAGGEDEPL" + local.link_protocol_type == "UNTAGGEDEPL" && local.zside_link_protocol_type == "UNTAGGEDEPL" ) ? "EPL_VC" : ( - (local.link_protocol_type == "QINQ" && local.zside_link_protocol_type == "UNTAGGEDEPL") || - (local.link_protocol_type == "UNTAGGEDEPL" && local.zside_link_protocol_type == "QINQ") - ) ? "ACCESS_EPL_VC" : "EVPL_VC" # Default value EVPL_VC should cover use cases: COLO2COLO, COLO2SP, VD2COLO, VD2COLO(TOKEN), COLO(TOKEN)2SP - # // TODO (ocobles) replace last ACCESS_EPL_VC condition with below code to support FCR and Fabric Network + (local.link_protocol_type == "QINQ" && local.zside_link_protocol_type == "UNTAGGEDEPL") || + (local.link_protocol_type == "UNTAGGEDEPL" && local.zside_link_protocol_type == "QINQ") + ) ? "ACCESS_EPL_VC" : "EVPL_VC" # Default value EVPL_VC should cover use cases: COLO2COLO, COLO2SP, VD2COLO, VD2COLO(TOKEN), COLO(TOKEN)2SP + # # TODO (ocobles) replace last ACCESS_EPL_VC condition with below code to support FCR and Fabric Network # # ) ? "ACCESS_EPL_VC" : ( # # local.aside_ap_type == "CLOUD_ROUTER" && (local.zside_ap_type == "COLO" || local.zside_ap_type == "SP") # # ) ? "IP_VC" : ( diff --git a/main.tf b/main.tf index c58d714..49e602c 100644 --- a/main.tf +++ b/main.tf @@ -4,7 +4,7 @@ data "equinix_fabric_service_profiles" "sp" { filter { property = "/name" operator = "=" - values = [var.seller_profile_name] + values = [var.seller_profile_name] } } @@ -37,14 +37,14 @@ resource "random_string" "this" { special = false } -resource "equinix_fabric_connection" "primary"{ +resource "equinix_fabric_connection" "primary" { name = var.redundancy_type == "REDUNDANT" && var.secondary_name == "" && var.name == "" ? format("%s-PRI", local.primary_name) : local.primary_name type = local.connection_type dynamic "notifications" { for_each = local.notification_users_by_type content { - type = notifications.key + type = notifications.key emails = notifications.value } } @@ -57,11 +57,11 @@ resource "equinix_fabric_connection" "primary"{ bandwidth = local.bandwidth redundancy { - priority= "PRIMARY" + priority = "PRIMARY" } order { - purchase_order_number= var.purchase_order_number != "" ? var.purchase_order_number : null + purchase_order_number = var.purchase_order_number != "" ? var.purchase_order_number : null } a_side { @@ -91,15 +91,15 @@ resource "equinix_fabric_connection" "primary"{ for_each = var.port_name != "" ? [1] : [] content { type = local.link_protocol_type == "UNTAGGEDEPL" ? "UNTAGGED" : local.link_protocol_type - vlan_tag = local.link_protocol_type == "DOT1Q" ? var.vlan_stag : null // vlanTag value specified for DOT1Q connections - vlan_s_tag = local.link_protocol_type == "QINQ" ? var.vlan_stag : null // vlanSTag value specified for QINQ connections + vlan_tag = local.link_protocol_type == "DOT1Q" ? var.vlan_stag : null # vlanTag value specified for DOT1Q connections + vlan_s_tag = local.link_protocol_type == "QINQ" ? var.vlan_stag : null # vlanSTag value specified for QINQ connections # This is adding ctag for any connection that is QINQ Aside AND not COLO on Zside OR when COLO on Zside is not QINQ Encapsulation Type vlan_c_tag = local.link_protocol_type == "QINQ" && (local.zside_ap_type != "COLO" || (local.zside_ap_type == "COLO" ? local.zside_link_protocol_type != "QINQ" : false)) ? var.vlan_ctag : null } } - // TODO (ocobles) support FCR + # TODO (ocobles) support FCR # dynamic "router" { # for_each = var.cloud_router_id != "" ? [var.cloud_router_id] : [] # content { @@ -112,12 +112,12 @@ resource "equinix_fabric_connection" "primary"{ content { type = "EDGE" uuid = virtual_device.value - // TODO (ocobles) allow use name instead of uuid - // name = var.network_edge_name + # TODO (ocobles) allow use name instead of uuid + # name = var.network_edge_name } } - // Virtual device interface + # Virtual device interface dynamic "interface" { for_each = var.network_edge_interface_id != 0 ? [var.network_edge_interface_id] : [] content { @@ -141,9 +141,9 @@ resource "equinix_fabric_connection" "primary"{ dynamic "access_point" { for_each = var.zside_service_token_id == "" ? [1] : [] content { - type = local.zside_ap_type + type = local.zside_ap_type authentication_key = var.seller_authorization_key != "" ? var.seller_authorization_key : null - seller_region = local.primary_region + seller_region = local.primary_region dynamic "profile" { for_each = var.seller_profile_name != "" ? [1] : [] @@ -160,7 +160,7 @@ resource "equinix_fabric_connection" "primary"{ } } - // TODO (ocobles) support Fabric Network + # TODO (ocobles) support Fabric Network # dynamic "network" { # for_each = var.network_id != "" ? [var.network_id] : [] # content { @@ -190,7 +190,7 @@ resource "equinix_fabric_connection" "primary"{ } # SECONDARY CONNECTION -resource "equinix_fabric_connection" "secondary"{ +resource "equinix_fabric_connection" "secondary" { count = var.redundancy_type == "REDUNDANT" ? 1 : 0 name = local.secondary_name @@ -199,7 +199,7 @@ resource "equinix_fabric_connection" "secondary"{ dynamic "notifications" { for_each = local.notification_users_by_type content { - type = notifications.key + type = notifications.key emails = notifications.value } } @@ -217,7 +217,7 @@ resource "equinix_fabric_connection" "secondary"{ } order { - purchase_order_number= var.purchase_order_number != "" ? var.purchase_order_number : null + purchase_order_number = var.purchase_order_number != "" ? var.purchase_order_number : null } a_side { @@ -247,15 +247,15 @@ resource "equinix_fabric_connection" "secondary"{ for_each = var.port_name != "" ? [1] : [] content { type = local.secondary_link_protocol_type == "UNTAGGEDEPL" ? "UNTAGGED" : local.secondary_link_protocol_type - vlan_tag = local.secondary_link_protocol_type == "DOT1Q" ? var.secondary_vlan_stag : null // vlanTag value specified for DOT1Q connections - vlan_s_tag = local.secondary_link_protocol_type == "QINQ" ? var.secondary_vlan_stag : null // vlanSTag value specified for QINQ connections + vlan_tag = local.secondary_link_protocol_type == "DOT1Q" ? var.secondary_vlan_stag : null # vlanTag value specified for DOT1Q connections + vlan_s_tag = local.secondary_link_protocol_type == "QINQ" ? var.secondary_vlan_stag : null # vlanSTag value specified for QINQ connections # This is adding ctag for any connection that is QINQ Aside AND not COLO on Zside OR when COLO on Zside is not QINQ Encapsulation Type vlan_c_tag = local.secondary_link_protocol_type == "QINQ" && (local.zside_ap_type != "COLO" || (local.zside_ap_type == "COLO" ? local.zside_link_protocol_type != "QINQ" : false)) ? var.secondary_vlan_ctag : null } } - // TODO (ocobles) support FCR + # TODO (ocobles) support FCR # dynamic "router" { # for_each = var.cloud_router_id != "" ? [coalesce(var.cloud_router_secondary_id, var.cloud_router_id)] : [] # content { @@ -268,12 +268,12 @@ resource "equinix_fabric_connection" "secondary"{ content { type = "EDGE" uuid = virtual_device.value - // TODO (ocobles) allow use name instead of uuid - // name = var.network_edge_name + # TODO (ocobles) allow use name instead of uuid + # name = var.network_edge_name } } - // Virtual device interface + # Virtual device interface dynamic "interface" { for_each = var.network_edge_secondary_interface_id != 0 ? [var.network_edge_secondary_interface_id] : [] content { @@ -297,9 +297,9 @@ resource "equinix_fabric_connection" "secondary"{ dynamic "access_point" { for_each = var.secondary_zside_service_token_id == "" ? [1] : [] content { - type = local.zside_ap_type + type = local.zside_ap_type authentication_key = var.secondary_seller_authorization_key != "" ? var.secondary_seller_authorization_key : null - seller_region = var.secondary_seller_region != "" ? var.secondary_seller_region : local.primary_region + seller_region = var.secondary_seller_region != "" ? var.secondary_seller_region : local.primary_region dynamic "profile" { for_each = var.seller_profile_name != "" ? [1] : [] @@ -316,7 +316,7 @@ resource "equinix_fabric_connection" "secondary"{ } } - // TODO (ocobles) support Fabric Network + # TODO (ocobles) support Fabric Network # dynamic "network" { # for_each = var.network_id != "" ? [var.network_id] : [] # content { diff --git a/variables.tf b/variables.tf index f57ef08..70f76d4 100644 --- a/variables.tf +++ b/variables.tf @@ -45,6 +45,7 @@ variable "speed" { default = 0 } +# tflint-ignore: terraform_unused_declarations variable "speed_unit" { type = string description = <