diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..58ab73c --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @silinternational/tf-devs diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..767bad8 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,17 @@ +### Added +- + +### Changed +- + +### Deprecated +- + +### Removed +- + +### Fixed +- + +### Security +- diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml new file mode 100644 index 0000000..7ea5157 --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,38 @@ +# This workflow installs the latest version of Terraform CLI. On pull request events, this workflow will run +# `terraform init`, `terraform fmt`, and `terraform plan`. +# +# Documentation for `hashicorp/setup-terraform` is located here: https://github.com/hashicorp/setup-terraform + +name: 'Terraform' + +on: + push: + branches: ["**"] + +jobs: + terraform: + name: 'Terraform' + runs-on: ubuntu-latest + + steps: + # Checkout the repository to the GitHub Actions runner + - name: Checkout + uses: actions/checkout@v4 + + # Install the latest version of Terraform CLI + - name: Setup Terraform + uses: hashicorp/setup-terraform@v3 + with: + terraform_version: "<1.6.0" # only use open source version of Terraform + + # Checks that all Terraform configuration files adhere to a canonical format + - name: Terraform Format + run: terraform fmt -check -diff -recursive + + # Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc. + - name: Terraform Init + run: terraform -chdir=test init + + # Validate the files, referring only to the configuration and not accessing any remote services + - name: Terraform Validate + run: terraform -chdir=test validate diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa0741d --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# environment files typically containing secrets +*.env + +# directories created by developer tools +.idea/ + +*.tfstate +*.tfstate.* +# Local .terraform directories +.terraform/ + +# Since this is a module, we don't want to retain version locks +.terraform.lock.hcl + +# Exclude all .tfvars files, which are likely to contain sensitive 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. +*.tfvars +*.tfvars.json + +# Ignore CLI configuration files +.terraformrc +terraform.rc diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4b3ce5d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 SIL International + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..03399ba --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# Terraform module for ... + +TODO: First https://developer.hashicorp.com/terraform/registry/modules/publish if you have never developed a publishable Terraform module. Then follow those requirements when creating your new module. + +This module ... + +TODO: Change the path in this link: + +This module is published in [Terraform Registry](https://registry.terraform.io/modules/silinternational/module-name/provider-name/latest). + +## Usage Example + +TODO: Update the following as a simple, brief representative sample of the module: + +```hcl +module "this" { + source = "silinternational/module-name/aws" + version = "0.1.0" + + variable_name = "my variable value" +} + +provider "aws" { + region = "us-east-1" +} +``` + +## Working Example + +TODO: Update or remove this section: + +A working [example](https://github.com/silinternational/terraform-module-name/tree/main/example) usage of this module is included in the source repository. + diff --git a/example/main.tf b/example/main.tf new file mode 100644 index 0000000..5697465 --- /dev/null +++ b/example/main.tf @@ -0,0 +1,12 @@ +/* + * TODO: This example folder is a place to provide a fully-functional example, proving any other required + * resources and typical root module outputs with appropriate `sensitive` flags. It can be removed + * entirely if time does not allow for making it complete. + */ + +module "this" { + source = "silinternational/module_name/aws" + version = ">= 0.1.0" + + variable_name = "a variable value" +} diff --git a/example/providers.tf b/example/providers.tf new file mode 100644 index 0000000..324dc92 --- /dev/null +++ b/example/providers.tf @@ -0,0 +1,10 @@ +provider "aws" { + region = var.aws_region + + default_tags { + tags = { + managed_by = "terraform" + workspace = terraform.workspace + } + } +} diff --git a/example/variables.tf b/example/variables.tf new file mode 100644 index 0000000..2cdb1b7 --- /dev/null +++ b/example/variables.tf @@ -0,0 +1,3 @@ +variable "aws_region" { + default = "us-east-1" +} diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..4236f1d --- /dev/null +++ b/main.tf @@ -0,0 +1,7 @@ + +// TODO: define locals at the top of main.tf + +locals { + a = "a" +} + diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..bdd4577 --- /dev/null +++ b/outputs.tf @@ -0,0 +1,5 @@ +output "output_name" { + value = var.variable_name + description = "description of the output" + sensitive = true +} diff --git a/test/main.tf b/test/main.tf new file mode 100644 index 0000000..939673e --- /dev/null +++ b/test/main.tf @@ -0,0 +1,39 @@ + +/* + * TODO: complete these basic instantiations of the module, with the base purpose of + * validating the syntax of module code automatically when pushed to version control. + * One instance should use the minimum allowable set of inputs. The other should have + * the full complement of inputs. You may also wish to include module outputs to + * enforce the presence of module outputs. + */ + +module "minimal" { + source = "../" + + variable_name = "foo" +} + +module "full" { + source = "../" + + variable_name = "foo" +} + +output "an_output" { + value = module.minimal.output_name +} + +provider "aws" { + region = "us-east-1" +} + +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.0" + } + } +} diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..61678e4 --- /dev/null +++ b/variables.tf @@ -0,0 +1,6 @@ +variable "variable_name" { + description = "Use this order of variable properties: description, type, default, sensitive" + type = string + default = "" + sensitive = true +} diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..5ba3ffe --- /dev/null +++ b/versions.tf @@ -0,0 +1,15 @@ +terraform { + required_version = ">= 1.0" + + /* + * TODO: add any provider version constraints required by provider features + * only available in later versions. + */ + + required_providers { + aws = { + version = ">=5.0.0, <6.0" + source = "hashicorp/aws" + } + } +}