-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d144333
commit 5b6b226
Showing
18 changed files
with
589 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: "test-scheduler" | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
|
||
schedule: | ||
- cron: '*/30 5 * * *' # triggers the workflow every day at 5:30 UTC | ||
|
||
# ┌───────────── minute (0 - 59) | ||
# │ ┌───────────── hour (0 - 23) | ||
# │ │ ┌───────────── day of the month (1 - 31) | ||
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) | ||
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) | ||
# │ │ │ │ │ | ||
# │ │ │ │ │ | ||
# │ │ │ │ │ | ||
# * * * * * | ||
|
||
jobs: | ||
continuous-tests: | ||
name: Run Test cases | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: checkout # action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it. | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15 | ||
|
||
- name: Install dependencies | ||
run: | | ||
go get -u "github.com/gruntwork-io/terratest/modules/random" | ||
go get -u "github.com/gruntwork-io/terratest/modules/terraform" | ||
- | ||
name: setup terraform | ||
uses: hashicorp/setup-terraform@v1 # sets up Terraform CLI in your GitHub Actions workflow | ||
with: | ||
terraform_version: 0.13.0 | ||
|
||
- name: Run Test | ||
working-directory: test | ||
run: go test -v ./... | ||
env: | ||
IC_API_KEY: ${{ secrets.ACCESS_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: ci | ||
|
||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
terraform_validate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: prepare | ||
# tfswitch command line tool lets you switch between different versions of terraform. | ||
# If you do not have a particular version of terraform installed, tfswitch will download the version you desire. | ||
run: | | ||
echo "$HOME/.bin" >> $GITHUB_PATH | ||
curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh > /tmp/tfswitch-install.sh | ||
chmod +x /tmp/tfswitch-install.sh | ||
/tmp/tfswitch-install.sh -b $HOME/.bin | ||
- | ||
name: checkout # action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it. | ||
uses: actions/checkout@v2 | ||
- | ||
name: setup terraform | ||
uses: hashicorp/setup-terraform@v1 # sets up Terraform CLI in your GitHub Actions workflow | ||
with: | ||
terraform_version: 0.13.0 | ||
- | ||
name: Install pre-commit | ||
run: pip install pre-commit | ||
- | ||
name: Run pre-commit command | ||
run: pre-commit run -a | ||
- | ||
name: terraform init # initialize a working directory containing Terraform configuration files. | ||
run: find . -type f -name "*.tf" -exec dirname {} \;|sort -u | while read m; do (cd "$m" && echo "$m - init" && terraform init -input=false -backend=false) || exit 1; done | ||
- | ||
name: terraform validate # validates the configuration files in a directory | ||
run: find . -name ".terraform" -prune -o -type f -name "*.tf" -exec dirname {} \;|sort -u | while read m; do (cd "$m" && echo "$m - validate" && terraform validate && echo "√ $m") || exit 1 ; done | ||
- | ||
name: terraform fmt check # perform format checks | ||
run: terraform fmt -list=true -write=false -check -recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Local .terraform directories | ||
**/.terraform/* | ||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
*.terraform.lock.hcl | ||
# Crash log files | ||
crash.log | ||
# Exclude all .tfvars files, which are likely to contain sentitive data, such as | ||
# password, private keys, and other secrets. These should not be part of version | ||
# control as they are data points which are potentially sensitive and subject | ||
# to change depending on the environment. | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
default_stages: [commit] | ||
# TFLint : Checks for possible errors, best practices, etc. It will also help identify provider-specific issues before errors occur during a Terraform run. | ||
# TFSec : Uses static analysis of your Terraform templates to spot potential security issues. TFSec checks for sensitive data inclusion | ||
# Terraform Docs : Utility to automatically generate documentation from Terraform modules and base repositories in various output formats. | ||
# Terraform Fmt : Used to rewrite Terraform configuration files to a canonical format and style. | ||
# Terraform Validate : Validates the configuration files in a directory, referring only to the configuration and not accessing any remote services such as remote state, provider APIs, etc | ||
repos: | ||
- repo: git://github.com/antonbabenko/pre-commit-terraform | ||
rev: v1.45.0 | ||
hooks: | ||
- id: terraform_fmt | ||
- repo: git://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.4.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: trailing-whitespace | ||
- id: detect-private-key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
Extending the adopted spec, each change should have a link to its | ||
corresponding pull request appended. | ||
|
||
## [1.0.0] - 2021-03-18 | ||
|
||
This is the initial release of the module, with support for transit gateway resources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Contributing | ||
|
||
This document provides guidelines for contributing to the module. | ||
|
||
Basic guidelines, to develop a new module or contributing to existing module, are captured in below link | ||
|
||
https://github.com/terraform-ibm-modules/getting-started |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,97 @@ | ||
# terraform-ibm-transit-gateway | ||
Terraform module to provision Transit Gateway in the IBM Cloud account | ||
# IBM Cloud Transit Gateway - Terraform Module | ||
|
||
This is a collection of modules that make it easier to provision transit gateway and configure multiple connections to it on IBM Cloud Platform: | ||
* [tg-gateway-connection](modules/tg-gateway-connection) | ||
|
||
## Compatibility | ||
|
||
This module is meant for use with Terraform 0.13 (and higher). | ||
|
||
## Usage | ||
|
||
Full examples are in the [examples](./examples/) folder, demonstarte how to use a module through a template: | ||
|
||
e.g: | ||
|
||
```hcl | ||
data "ibm_resource_group" "resource_group" { | ||
name = var.resource_group_name | ||
} | ||
module "tg-gateway-connection" { | ||
source = "terraform-ibm-modules/transit-gateway/ibm//modules/tg-gateway-connection" | ||
transit_gateway_name = var.transit_gateway_name | ||
location = var.location | ||
global_routing = var.global_routing | ||
tags = var.tags | ||
resource_group_id = data.ibm_resource_group.resource_group.id | ||
vpc_connections = var.vpc_connections | ||
classic_connections_count = var.classic_connections_count | ||
} | ||
``` | ||
|
||
## Requirements | ||
|
||
### Terraform plugins | ||
|
||
- [Terraform](https://www.terraform.io/downloads.html) 0.13 (or later) | ||
- [terraform-provider-ibm](https://github.com/IBM-Cloud/terraform-provider-ibm) | ||
|
||
## Install | ||
|
||
### Terraform | ||
|
||
Be sure you have the correct Terraform version (0.13), you can choose the binary here: | ||
- https://releases.hashicorp.com/terraform/ | ||
|
||
### Terraform plugins | ||
|
||
Be sure you have the compiled plugins on $HOME/.terraform.d/plugins/ | ||
|
||
- [terraform-provider-ibm](https://github.com/IBM-Cloud/terraform-provider-ibm) | ||
|
||
### Pre-commit hooks | ||
|
||
Run the following command to execute the pre-commit hooks defined in .pre-commit-config.yaml file | ||
``` | ||
pre-commit run -a | ||
``` | ||
You can install pre-coomit tool using | ||
|
||
``` | ||
pip install pre-commit | ||
``` | ||
or | ||
``` | ||
pip3 install pre-commit | ||
``` | ||
## How to input variable values through a file | ||
|
||
To review the plan for the configuration defined (no resources actually provisioned) | ||
``` | ||
terraform plan -var-file=./input.tfvars | ||
``` | ||
To execute and start building the configuration defined in the plan (provisions resources) | ||
``` | ||
terraform apply -var-file=./input.tfvars | ||
``` | ||
|
||
To destroy the VPC and all related resources | ||
``` | ||
terraform destroy -var-file=./input.tfvars | ||
``` | ||
|
||
To run the test case execute | ||
``` | ||
go test -v -timeout 15m -run <TestCaseName> | ||
``` | ||
|
||
## Note | ||
|
||
All optional parameters, by default, will be set to `null` in respective example's variable.tf file. You can also override these optional parameters. | ||
|
||
To create a transit gateway connection of network type `classic`, in the respective account virtual routing and forwarding (VRF) has to be enabled. please refer following doc to enable the VRF | ||
|
||
https://cloud.ibm.com/docs/account?topic=account-vrf-service-endpoint#vrf | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Transit Gateway Module Example | ||
|
||
This example illustrates how to provision a transit gateway and configure multiple connections to it. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|-----------------------------------|-----------------------------------------------------------------|--------------|---------|----------| | ||
| transit_gateway_name | Name of the transit gateway. | string | n/a | yes | | ||
| location | Location of the transit gateway. | string | n/a | yes | | ||
| resource_group_name | Name of the resource group. | string | n/a | yes | | ||
| global_routing | On true, connect to the networks outside their associated region| bool | false | no | | ||
| vpc_connections | List of vpc crn to connect | list(string) | n/a | yes | | ||
| classic_connections_count | Number of classic connections. | number | n/a | yes | | ||
| tags | List of tags | list(string) | n/a | no | | ||
|
||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
|
||
## How to input variable values through a file | ||
|
||
To review the plan for the configuration defined (no resources actually provisioned) | ||
|
||
`terraform plan -var-file=./input.tfvars` | ||
|
||
To execute and start building the configuration defined in the plan (provisions resources) | ||
|
||
`terraform apply -var-file=./input.tfvars` | ||
|
||
To destroy the VPC and all related resources | ||
|
||
`terraform destroy -var-file=./input.tfvars` | ||
|
||
All optional parameters by default will be set to null in respective example's variable.tf file. If user wants to configure any optional paramter he has overwrite the default value. | ||
|
||
## Note | ||
|
||
For all optional fields, default values (Eg: `null`) are given in variable.tf file. User can configure the same by overwriting with appropriate values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/*************************************************** | ||
Example Inputs | ||
vpc_connections = ["vpc_crn_1","vpc_crn_2","vpc_crn_3] | ||
classic_connnections_count = 3 | ||
tags = ["Tag1","Tag2"] | ||
***************************************************/ | ||
|
||
vpc_connections = ["crn:v1:bluemix:public:is:us-south:a/db764102154c7ea8e1b79d3a64afe0::vpc:r006-295247-a00b-4f11-94da-b7098918c28c"] | ||
|
||
classic_connnections_count = 2 | ||
|
||
tags = ["T1", "T2"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
##################################################### | ||
# Module Example | ||
# Copyright 2020 IBM | ||
##################################################### | ||
data "ibm_resource_group" "resource_group" { | ||
name = var.resource_group_name | ||
} | ||
|
||
module "tg-gateway-connection" { | ||
source = "terraform-ibm-modules/transit-gateway/ibm//modules/tg-gateway-connection" | ||
|
||
transit_gateway_name = var.transit_gateway_name | ||
location = var.location | ||
global_routing = var.global_routing | ||
tags = var.tags | ||
resource_group_id = data.ibm_resource_group.resource_group.id | ||
vpc_connections = var.vpc_connections | ||
classic_connnections_count = var.classic_connnections_count | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
variable "transit_gateway_name" { | ||
description = "Name of the transit gateway" | ||
type = string | ||
} | ||
|
||
variable "location" { | ||
description = "Location of the transit gateway." | ||
type = string | ||
} | ||
|
||
variable "resource_group_name" { | ||
description = "Name of the resource group." | ||
type = string | ||
} | ||
|
||
variable "global_routing" { | ||
description = "Gateways with global routing (true) to connect to the networks outside their associated region" | ||
type = bool | ||
default = false | ||
} | ||
|
||
variable "vpc_connections" { | ||
type = list(string) | ||
description = "The list of vpc instance resource_crn to add network connections for." | ||
} | ||
|
||
variable "classic_connnections_count" { | ||
type = number | ||
description = "Number of classic connections to add." | ||
} | ||
|
||
variable "tags" { | ||
type = list(string) | ||
description = "List of tags" | ||
default = null | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
##################################################### | ||
# Transit Gateway Module | ||
# Copyright 2020 IBM | ||
##################################################### | ||
|
||
/*************************************************** | ||
NOTE: To source a particular version of IBM terraform provider, configure the parameter `version` as follows | ||
terraform { | ||
required_version = ">=0.13" | ||
required_providers { | ||
ibm = { | ||
source = "IBM-Cloud/ibm" | ||
version = "1.21.0" | ||
} | ||
} | ||
} | ||
If we dont configure the version parameter, it fetches the latest provider version. | ||
****************************************************/ | ||
|
||
terraform { | ||
required_version = ">=0.13" | ||
required_providers { | ||
ibm = { | ||
source = "IBM-Cloud/ibm" | ||
} | ||
} | ||
} |
Oops, something went wrong.