Skip to content

Commit

Permalink
Merge pull request #5 from zachreborn/dev_terraform_overhaul
Browse files Browse the repository at this point in the history
updated the readme names
  • Loading branch information
zachreborn authored Apr 3, 2023
2 parents 070ecbf + cab95b8 commit 422f045
Show file tree
Hide file tree
Showing 9 changed files with 491 additions and 1 deletion.
17 changes: 16 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: List all files
run: ls -lha

- name: stat .git/objects
run: stat .git/objects

- name: Terraform fmt on all files
id: fmt
Expand All @@ -29,7 +35,16 @@ jobs:
config-file: ./modules/.terraform-docs.yml
find-dir: ./modules

- name: List all files
run: ls -lha

- name: stat .git/objects
run: stat .git/objects

- name: Fix .git owner
run: sudo chown runner:docker -R .git

- name: Git stage all, commit, and push
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Continuous Integration - terraform fmt and terraform-docs
commit_message: Continuous Integration - terraform fmt and terraform-docs
171 changes: 171 additions & 0 deletions modules/terraform/organization/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<!-- Blank module readme template: Do a search and replace with your text editor for the following: `module_name`, `module_description` -->
<!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 -->
<a name="readme-top"></a>


<!-- PROJECT SHIELDS -->
<!--
*** I'm using markdown "reference style" links for readability.
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
*** See the bottom of this document for the declaration of the reference variables
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]


<!-- PROJECT LOGO -->
<br />
<div align="center">
<a href="https://github.com/zachreborn/terraform-modules">
<img src="/images/terraform_modules_logo.webp" alt="Logo" width="300" height="300">
</a>

<h3 align="center">Terraform Cloud Organization</h3>
<p align="center">
This module creates or manages a terraform cloud organization.
<br />
<a href="https://github.com/zachreborn/terraform-modules"><strong>Explore the docs »</strong></a>
<br />
<br />
<a href="https://zacharyhill.co">Zachary Hill</a>
·
<a href="https://github.com/zachreborn/terraform-modules/issues">Report Bug</a>
·
<a href="https://github.com/zachreborn/terraform-modules/issues">Request Feature</a>
</p>
</div>


<!-- TABLE OF CONTENTS -->
<details>
<summary>Table of Contents</summary>
<ol>
<li><a href="#usage">Usage</a></li>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#providers">Providers</a></li>
<li><a href="#modules">Modules</a></li>
<li><a href="#Resources">Resources</a></li>
<li><a href="#inputs">Inputs</a></li>
<li><a href="#outputs">Outputs</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#acknowledgments">Acknowledgments</a></li>
</ol>
</details>


<!-- USAGE EXAMPLES -->
## Usage
### Simple Example
```
module test {
source =
variable =
}
```

_For more examples, please refer to the [Documentation](https://github.com/zachreborn/terraform-modules)_

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- terraform-docs output will be input automatically below-->
<!-- terraform-docs markdown table --output-file README.md --output-mode inject .-->
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_tfe"></a> [tfe](#requirement\_tfe) | >=0.42.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_tfe"></a> [tfe](#provider\_tfe) | >=0.42.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [tfe_organization.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/organization) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_allow_force_delete_workspaces"></a> [allow\_force\_delete\_workspaces](#input\_allow\_force\_delete\_workspaces) | (Optional) Whether workspace administrators are permitted to delete workspaces with resources under management. If false, only organization owners may delete these workspaces. Defaults to false. | `bool` | `false` | no |
| <a name="input_assessments_enforced"></a> [assessments\_enforced](#input\_assessments\_enforced) | (Optional) (Available only in Terraform Cloud) Whether to force health assessments (drift detection) on all eligible workspaces or allow workspaces to set thier own preferences. Defaults to false. | `bool` | `false` | no |
| <a name="input_collaborator_auth_policy"></a> [collaborator\_auth\_policy](#input\_collaborator\_auth\_policy) | (Optional) Authentication policy (password or two\_factor\_mandatory). Defaults to two\_factor\_mandatory. | `string` | `"two_factor_mandatory"` | no |
| <a name="input_cost_estimation_enabled"></a> [cost\_estimation\_enabled](#input\_cost\_estimation\_enabled) | (Optional) Whether or not the cost estimation feature is enabled for all workspaces in the organization. Defaults to true. In a Terraform Cloud organization which does not have Teams & Governance features, this value is always false and cannot be changed. In Terraform Enterprise, Cost Estimation must also be enabled in Site Administration. | `bool` | `false` | no |
| <a name="input_email"></a> [email](#input\_email) | (Required) Admin email address. | `string` | n/a | yes |
| <a name="input_name"></a> [name](#input\_name) | (Required) Name of the organization. | `string` | n/a | yes |
| <a name="input_owners_team_saml_role_id"></a> [owners\_team\_saml\_role\_id](#input\_owners\_team\_saml\_role\_id) | (Optional) The name of the 'owners' team. | `string` | `"owners"` | no |
| <a name="input_send_passing_statuses_for_untriggered_speculative_plans"></a> [send\_passing\_statuses\_for\_untriggered\_speculative\_plans](#input\_send\_passing\_statuses\_for\_untriggered\_speculative\_plans) | (Optional) Whether or not to send VCS status updates for untriggered speculative plans. This can be useful if large numbers of untriggered workspaces are exhausting request limits for connected version control service providers like GitHub. Defaults to false. In Terraform Enterprise, this setting has no effect and cannot be changed but is also available in Site Administration. | `bool` | `false` | no |
| <a name="input_session_remember_minutes"></a> [session\_remember\_minutes](#input\_session\_remember\_minutes) | (Optional) Session expiration in minutes. Defaults to 720. | `number` | `720` | no |
| <a name="input_session_timeout_minutes"></a> [session\_timeout\_minutes](#input\_session\_timeout\_minutes) | (Optional) Session timeout after inactivity in minutes. Defaults to 720. | `number` | `720` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_id"></a> [id](#output\_id) | The ID of the organization. |
<!-- END_TF_DOCS -->

<!-- LICENSE -->
## License

Distributed under the MIT License. See `LICENSE.txt` for more information.

<p align="right">(<a href="#readme-top">back to top</a>)</p>



<!-- CONTACT -->
## Contact

Zachary Hill - [![LinkedIn][linkedin-shield]][linkedin-url] - [email protected]

Project Link: [https://github.com/zachreborn/terraform-modules](https://github.com/zachreborn/terraform-modules)

<p align="right">(<a href="#readme-top">back to top</a>)</p>



<!-- ACKNOWLEDGMENTS -->
## Acknowledgments

* [Zachary Hill](https://zacharyhill.co)
* [Jake Jones](https://github.com/jakeasarus)

<p align="right">(<a href="#readme-top">back to top</a>)</p>


<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/zachreborn/terraform-modules.svg?style=for-the-badge
[contributors-url]: https://github.com/zachreborn/terraform-modules/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/zachreborn/terraform-modules.svg?style=for-the-badge
[forks-url]: https://github.com/zachreborn/terraform-modules/network/members
[stars-shield]: https://img.shields.io/github/stars/zachreborn/terraform-modules.svg?style=for-the-badge
[stars-url]: https://github.com/zachreborn/terraform-modules/stargazers
[issues-shield]: https://img.shields.io/github/issues/zachreborn/terraform-modules.svg?style=for-the-badge
[issues-url]: https://github.com/zachreborn/terraform-modules/issues
[license-shield]: https://img.shields.io/github/license/zachreborn/terraform-modules.svg?style=for-the-badge
[license-url]: https://github.com/zachreborn/terraform-modules/blob/master/LICENSE.txt
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://www.linkedin.com/in/zachary-hill-5524257a/
[product-screenshot]: /images/screenshot.webp
[Terraform.io]: https://img.shields.io/badge/Terraform-7B42BC?style=for-the-badge&logo=terraform
[Terraform-url]: https://terraform.io
23 changes: 23 additions & 0 deletions modules/terraform/organization/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
terraform {
required_version = ">= 1.0.0"
required_providers {
tfe = {
source = "hashicorp/tfe"
version = ">=0.42.0"
}
}
}

# Organization: https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/organization
resource "tfe_organization" "this" {
allow_force_delete_workspaces = var.allow_force_delete_workspaces
assessments_enforced = var.assessments_enforced
collaborator_auth_policy = var.collaborator_auth_policy
cost_estimation_enabled = var.cost_estimation_enabled
email = var.email
name = var.name
owners_team_saml_role_id = var.owners_team_saml_role_id
session_timeout_minutes = var.session_timeout_minutes
session_remember_minutes = var.session_remember_minutes
send_passing_statuses_for_untriggered_speculative_plans = var.send_passing_statuses_for_untriggered_speculative_plans
}
4 changes: 4 additions & 0 deletions modules/terraform/organization/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "id" {
description = "The ID of the organization."
value = tfe_organization.this.id
}
85 changes: 85 additions & 0 deletions modules/terraform/organization/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
variable "allow_force_delete_workspaces" {
type = bool
description = "(Optional) Whether workspace administrators are permitted to delete workspaces with resources under management. If false, only organization owners may delete these workspaces. Defaults to false."
default = false
validation {
condition = can(regex("true|false", var.allow_force_delete_workspaces))
error_message = "The value of allow_force_delete_workspaces must be either true or false."
}
}

variable "assessments_enforced" {
type = bool
description = "(Optional) (Available only in Terraform Cloud) Whether to force health assessments (drift detection) on all eligible workspaces or allow workspaces to set thier own preferences. Defaults to false."
default = false
validation {
condition = can(regex("true|false", var.assessments_enforced))
error_message = "The value of assessments_enforced must be either true or false."
}
}

variable "collaborator_auth_policy" {
type = string
description = "(Optional) Authentication policy (password or two_factor_mandatory). Defaults to two_factor_mandatory."
default = "two_factor_mandatory"
validation {
condition = can(regex("password|two_factor_mandatory", var.collaborator_auth_policy))
error_message = "The value of collaborator_auth_policy must be either password or two_factor_mandatory."
}
}

variable "cost_estimation_enabled" {
type = bool
description = "(Optional) Whether or not the cost estimation feature is enabled for all workspaces in the organization. Defaults to true. In a Terraform Cloud organization which does not have Teams & Governance features, this value is always false and cannot be changed. In Terraform Enterprise, Cost Estimation must also be enabled in Site Administration."
default = false
validation {
condition = can(regex("true|false", var.cost_estimation_enabled))
error_message = "The value of cost_estimation_enabled must be either true or false."
}
}

variable "email" {
type = string
description = "(Required) Admin email address."
}

variable "name" {
type = string
description = "(Required) Name of the organization."
}

variable "owners_team_saml_role_id" {
type = string
description = "(Optional) The name of the 'owners' team."
default = "owners"
}

variable "session_timeout_minutes" {
type = number
description = "(Optional) Session timeout after inactivity in minutes. Defaults to 720."
default = 720
validation {
condition = can(regex("^[0-9]+$", var.session_timeout_minutes))
error_message = "The value of session_timeout_minutes must be a number."
}
}

variable "session_remember_minutes" {
type = number
description = "(Optional) Session expiration in minutes. Defaults to 720."
default = 720
validation {
condition = can(regex("^[0-9]+$", var.session_remember_minutes))
error_message = "The value of session_remember_minutes must be a number."
}
}

variable "send_passing_statuses_for_untriggered_speculative_plans" {
type = bool
description = "(Optional) Whether or not to send VCS status updates for untriggered speculative plans. This can be useful if large numbers of untriggered workspaces are exhausting request limits for connected version control service providers like GitHub. Defaults to false. In Terraform Enterprise, this setting has no effect and cannot be changed but is also available in Site Administration."
default = false
validation {
condition = can(regex("true|false", var.send_passing_statuses_for_untriggered_speculative_plans))
error_message = "The value of send_passing_statuses_for_untriggered_speculative_plans must be either true or false."
}
}
Loading

0 comments on commit 422f045

Please sign in to comment.