Skip to content

Commit

Permalink
Add project module
Browse files Browse the repository at this point in the history
  • Loading branch information
posquit0 committed Apr 29, 2024
1 parent 448fa56 commit 98287da
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 0 deletions.
53 changes: 53 additions & 0 deletions modules/project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# project

This module creates following resources.

- `tfe_project`
- `tfe_project_policy_set` (optional)
- `tfe_project_variable_set` (optional)

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

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

## Providers

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

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [tfe_project.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/project) | resource |
| [tfe_project_policy_set.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/project_policy_set) | resource |
| [tfe_project_variable_set.this](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/project_variable_set) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_name"></a> [name](#input\_name) | (Required) The name of the project. | `string` | n/a | yes |
| <a name="input_description"></a> [description](#input\_description) | (Optional) A description to help you identify the project. | `string` | `"Managed by Terraform."` | no |
| <a name="input_organization"></a> [organization](#input\_organization) | (Optional) A name of the organization. If omitted, organization must be defined in the provider config. | `string` | `null` | no |
| <a name="input_policy_set"></a> [policy\_set](#input\_policy\_set) | (Optional) The ID of the policy set to configure. | `string` | `null` | no |
| <a name="input_variable_set"></a> [variable\_set](#input\_variable\_set) | (Optional) A name of the variable set to configure. | `string` | `null` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_description"></a> [description](#output\_description) | The description of the project. |
| <a name="output_id"></a> [id](#output\_id) | The ID of the project. |
| <a name="output_name"></a> [name](#output\_name) | The name of the project. |
| <a name="output_organization"></a> [organization](#output\_organization) | The name of the organization. |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
34 changes: 34 additions & 0 deletions modules/project/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
###################################################
# Project in Terraform Enterprise
###################################################

resource "tfe_project" "this" {
organization = var.organization

name = var.name
description = var.description
}


###################################################
# Policy Set for Project
###################################################

resource "tfe_project_policy_set" "this" {
count = var.policy_set != null ? 1 : 0

project_id = tfe_project.this.id
policy_set_id = var.policy_set
}


###################################################
# Variable Set for Project
###################################################

resource "tfe_project_variable_set" "this" {
count = var.variable_set != null ? 1 : 0

project_id = tfe_project.this.id
variable_set_id = var.variable_set
}
35 changes: 35 additions & 0 deletions modules/project/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
output "id" {
description = "The ID of the project."
value = tfe_project.this.id
}

output "organization" {
description = "The name of the organization."
value = tfe_project.this.organization
}

output "name" {
description = "The name of the project."
value = tfe_project.this.name
}

output "description" {
description = "The description of the project."
value = tfe_project.this.description
}

# output "debug" {
# value = {
# for k, v in tfe_project.this :
# k => v
# if !contains(["name", "id", "organization", "description"], k)
# }
# }

# output "debug2" {
# value = tfe_project_policy_set.this
# }
#
# output "debug3" {
# value = tfe_project_variable_set.this
# }
37 changes: 37 additions & 0 deletions modules/project/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
variable "organization" {
description = "(Optional) A name of the organization. If omitted, organization must be defined in the provider config."
type = string
default = null
nullable = true
}

variable "name" {
description = "(Required) The name of the project."
type = string
nullable = false
}

variable "description" {
description = "(Optional) A description to help you identify the project."
type = string
default = "Managed by Terraform."
nullable = false
}

variable "policy_set" {
description = <<EOF
(Optional) The ID of the policy set to configure.
EOF
type = string
default = null
nullable = true
}

variable "variable_set" {
description = <<EOF
(Optional) A name of the variable set to configure.
EOF
type = string
default = null
nullable = true
}
10 changes: 10 additions & 0 deletions modules/project/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.6"

required_providers {
tfe = {
source = "hashicorp/tfe"
version = ">= 0.53"
}
}
}

0 comments on commit 98287da

Please # to comment.