Skip to content

Commit ad1f7ee

Browse files
authored
Merge pull request #1 from dsodk/feat-initial-version
feat-initial-version-module-built
2 parents 29f9ddb + 55b97cf commit ad1f7ee

File tree

11 files changed

+446
-73
lines changed

11 files changed

+446
-73
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*.tfstate
66
*.tfstate.*
77

8+
# terraform lock file
9+
examples/.terraform.lock.hcl
10+
811
# Crash log files
912
crash.log
1013

README.md

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
# DevSecOps Dev Kit - Template terraform module
1+
# DSODK - Terraform Module for GitHub Organizations
22

3-
Template of terraform module
3+
Terraform module for creating and managing GitHub Organizations
44

55
## Features
66

77
## Usage
88

99
## (Resource) Best Practices
1010

11+
* https://registry.terraform.io/providers/integrations/github
12+
* https://github.com/integrations/terraform-provider-github
13+
1114
## Examples
1215

1316
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
@@ -16,13 +19,13 @@ Template of terraform module
1619
| Name | Version |
1720
|------|---------|
1821
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
19-
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.0 |
22+
| <a name="requirement_github"></a> [github](#requirement\_github) | 5.3.0 |
2023

2124
## Providers
2225

2326
| Name | Version |
2427
|------|---------|
25-
| <a name="provider_null"></a> [null](#provider\_null) | >= 3.0 |
28+
| <a name="provider_github"></a> [github](#provider\_github) | 5.3.0 |
2629

2730
## Modules
2831

@@ -32,24 +35,59 @@ No modules.
3235

3336
| Name | Type |
3437
|------|------|
35-
| [null_resource.template_null_resource](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
38+
| [github_organization_project.this](https://registry.terraform.io/providers/integrations/github/5.3.0/docs/resources/organization_project) | resource |
39+
| [github_organization_settings.this](https://registry.terraform.io/providers/integrations/github/5.3.0/docs/resources/organization_settings) | resource |
40+
| [github_organization_webhook.this](https://registry.terraform.io/providers/integrations/github/5.3.0/docs/resources/organization_webhook) | resource |
3641

3742
## Inputs
3843

3944
| Name | Description | Type | Default | Required |
4045
|------|-------------|------|---------|:--------:|
41-
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |
42-
| <a name="input_template_variable_boolean"></a> [template\_variable\_boolean](#input\_template\_variable\_boolean) | Template variable of type boolean | `bool` | `true` | no |
43-
| <a name="input_template_variable_map"></a> [template\_variable\_map](#input\_template\_variable\_map) | Template variable of type map | `map(string)` | `{}` | no |
44-
| <a name="input_template_variable_number"></a> [template\_variable\_number](#input\_template\_variable\_number) | Template variable of type number | `number` | `123` | no |
45-
| <a name="input_template_variable_string"></a> [template\_variable\_string](#input\_template\_variable\_string) | Template variable of type boolean | `string` | `""` | no |
46-
| <a name="input_triggers"></a> [triggers](#input\_triggers) | A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners | `map(string)` | `{}` | no |
46+
| <a name="input_advanced_security_enabled_for_new_repositories"></a> [advanced\_security\_enabled\_for\_new\_repositories](#input\_advanced\_security\_enabled\_for\_new\_repositories) | Whether or not advanced security is enabled for new repositories. (Optional) | `bool` | `false` | no |
47+
| <a name="input_billing_email"></a> [billing\_email](#input\_billing\_email) | The billing email address for the GitHub Organization. (Required) | `string` | n/a | yes |
48+
| <a name="input_blog_url"></a> [blog\_url](#input\_blog\_url) | The blog URL (https://example.com) for the GitHub Organization. (Optional) | `string` | `""` | no |
49+
| <a name="input_company"></a> [company](#input\_company) | The company name for the GitHub Organization. (Optional) | `string` | `""` | no |
50+
| <a name="input_create_github_organization"></a> [create\_github\_organization](#input\_create\_github\_organization) | Whether to create the GitHub Organization. | `bool` | `true` | no |
51+
| <a name="input_create_github_organization_project"></a> [create\_github\_organization\_project](#input\_create\_github\_organization\_project) | Whether to create projects in the GitHub Organization. | `bool` | `false` | no |
52+
| <a name="input_create_github_organization_webhook"></a> [create\_github\_organization\_webhook](#input\_create\_github\_organization\_webhook) | Whether to create webhooks in the GitHub Organization. | `bool` | `false` | no |
53+
| <a name="input_default_repository_permission"></a> [default\_repository\_permission](#input\_default\_repository\_permission) | The default permission [read\|write\|admin\|none] for GitHub Organization members to create new repositories . (Optional) | `string` | `"read"` | no |
54+
| <a name="input_dependabot_alerts_enabled_for_new_repositories"></a> [dependabot\_alerts\_enabled\_for\_new\_repositories](#input\_dependabot\_alerts\_enabled\_for\_new\_repositories) | Whether or not dependabot alerts are enabled for new repositories. (Optional) | `bool` | `false` | no |
55+
| <a name="input_dependabot_security_updates_enabled_for_new_repositories"></a> [dependabot\_security\_updates\_enabled\_for\_new\_repositories](#input\_dependabot\_security\_updates\_enabled\_for\_new\_repositories) | Whether or not dependabot security updates are enabled for new repositories. (Optional) | `bool` | `false` | no |
56+
| <a name="input_dependency_graph_enabled_for_new_repositories"></a> [dependency\_graph\_enabled\_for\_new\_repositories](#input\_dependency\_graph\_enabled\_for\_new\_repositories) | Whether or not dependency graph is enabled for new repositories. (Optional) | `bool` | `false` | no |
57+
| <a name="input_description"></a> [description](#input\_description) | The description for the GitHub Organization. (Optional) | `string` | `""` | no |
58+
| <a name="input_email"></a> [email](#input\_email) | The email address (example@example.com) for the GitHub Organization. (Optional) | `string` | `""` | no |
59+
| <a name="input_github_organization_project_body"></a> [github\_organization\_project\_body](#input\_github\_organization\_project\_body) | The body of the project. (Optional) | `string` | `""` | no |
60+
| <a name="input_github_organization_project_name"></a> [github\_organization\_project\_name](#input\_github\_organization\_project\_name) | The name of the project. (Required) | `string` | `""` | no |
61+
| <a name="input_github_organization_webhook_active"></a> [github\_organization\_webhook\_active](#input\_github\_organization\_webhook\_active) | Indicate of the webhook should receive events. (Optional) | `bool` | `true` | no |
62+
| <a name="input_github_organization_webhook_config_content_type"></a> [github\_organization\_webhook\_config\_content\_type](#input\_github\_organization\_webhook\_config\_content\_type) | The content type of the webhook. [form\|json] | `string` | `"form"` | no |
63+
| <a name="input_github_organization_webhook_config_insecure_ssl"></a> [github\_organization\_webhook\_config\_insecure\_ssl](#input\_github\_organization\_webhook\_config\_insecure\_ssl) | Whether to allow insecure\_ssl. | `bool` | `false` | no |
64+
| <a name="input_github_organization_webhook_config_secret"></a> [github\_organization\_webhook\_config\_secret](#input\_github\_organization\_webhook\_config\_secret) | Secret for the Webhook | `string` | `""` | no |
65+
| <a name="input_github_organization_webhook_config_url"></a> [github\_organization\_webhook\_config\_url](#input\_github\_organization\_webhook\_config\_url) | The URL of the webhook | `string` | `""` | no |
66+
| <a name="input_github_organization_webhook_events"></a> [github\_organization\_webhook\_events](#input\_github\_organization\_webhook\_events) | A list of events which should trigger the webhook. (Optional)<br>For list of valid events, visit https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issues | `list(any)` | `[]` | no |
67+
| <a name="input_has_organization_projects"></a> [has\_organization\_projects](#input\_has\_organization\_projects) | Whether or not organization projects are enabled for the GitHub Organization. (Optional) | `bool` | `true` | no |
68+
| <a name="input_has_repository_projects"></a> [has\_repository\_projects](#input\_has\_repository\_projects) | Whether or not repository projects are enabled for the GitHub Organization. (Optional) | `bool` | `true` | no |
69+
| <a name="input_location"></a> [location](#input\_location) | The location for the GitHub Organization. (Optional) | `string` | `""` | no |
70+
| <a name="input_members_can_create_internal_repositories"></a> [members\_can\_create\_internal\_repositories](#input\_members\_can\_create\_internal\_repositories) | Whether or not organization members can create new internal repositories. For Enterprise Organizations only. (Optional) | `bool` | `false` | no |
71+
| <a name="input_members_can_create_pages"></a> [members\_can\_create\_pages](#input\_members\_can\_create\_pages) | Whether or not organization members can create new pages. (Optional) | `bool` | `true` | no |
72+
| <a name="input_members_can_create_private_pages"></a> [members\_can\_create\_private\_pages](#input\_members\_can\_create\_private\_pages) | Whether or not organization members can create new private pages. (Optional) | `bool` | `true` | no |
73+
| <a name="input_members_can_create_private_repositories"></a> [members\_can\_create\_private\_repositories](#input\_members\_can\_create\_private\_repositories) | Whether or not organization members can create new private repositories. (Optional) | `bool` | `true` | no |
74+
| <a name="input_members_can_create_public_pages"></a> [members\_can\_create\_public\_pages](#input\_members\_can\_create\_public\_pages) | Whether or not organization members can create new public pages. (Optional) | `bool` | `true` | no |
75+
| <a name="input_members_can_create_public_repositories"></a> [members\_can\_create\_public\_repositories](#input\_members\_can\_create\_public\_repositories) | Whether or not organization members can create new public repositories. (Optional) | `bool` | `true` | no |
76+
| <a name="input_members_can_create_repositories"></a> [members\_can\_create\_repositories](#input\_members\_can\_create\_repositories) | Whether or not organization members can create new repositories. (Optional) | `bool` | `true` | no |
77+
| <a name="input_members_can_fork_private_repositories"></a> [members\_can\_fork\_private\_repositories](#input\_members\_can\_fork\_private\_repositories) | Whether or not organization members can fork private repositories. (Optional) | `bool` | `false` | no |
78+
| <a name="input_name"></a> [name](#input\_name) | The name for the GitHub Organization. (Optional) | `string` | `""` | no |
79+
| <a name="input_secret_scanning_enabled_for_new_repositories"></a> [secret\_scanning\_enabled\_for\_new\_repositories](#input\_secret\_scanning\_enabled\_for\_new\_repositories) | Whether or not secret scanning is enabled for new repositories. (Optional) | `bool` | `false` | no |
80+
| <a name="input_secret_scanning_push_protection_enabled_for_new_repositories"></a> [secret\_scanning\_push\_protection\_enabled\_for\_new\_repositories](#input\_secret\_scanning\_push\_protection\_enabled\_for\_new\_repositories) | Whether or not secret scanning push protection is enabled for new repositories. (Optional) | `bool` | `false` | no |
81+
| <a name="input_twitter_username"></a> [twitter\_username](#input\_twitter\_username) | The Twitter username for the GitHub Organization. (Optional) | `string` | `""` | no |
82+
| <a name="input_web_commit_signoff_required"></a> [web\_commit\_signoff\_required](#input\_web\_commit\_signoff\_required) | Whether or not commit signatures are required for commits to the organization. (Optional) | `bool` | `false` | no |
4783

4884
## Outputs
4985

5086
| Name | Description |
5187
|------|-------------|
52-
| <a name="output_template_null_resource_id"></a> [template\_null\_resource\_id](#output\_template\_null\_resource\_id) | The ID of the null resource |
88+
| <a name="output_github_organization_project_url"></a> [github\_organization\_project\_url](#output\_github\_organization\_project\_url) | The URL of the project |
89+
| <a name="output_github_organization_settings_id"></a> [github\_organization\_settings\_id](#output\_github\_organization\_settings\_id) | The ID of the organization settings |
90+
| <a name="output_github_organization_webhook_url"></a> [github\_organization\_webhook\_url](#output\_github\_organization\_webhook\_url) | The URL of the webhook |
5391
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
5492

5593
## Authors

examples/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ After testing with this example is completed, run ```$ terraform destroy```
2424
| Name | Version |
2525
|------|---------|
2626
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
27-
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.0 |
27+
| <a name="requirement_github"></a> [github](#requirement\_github) | 5.3.0 |
2828

2929
## Providers
3030

@@ -34,19 +34,21 @@ No providers.
3434

3535
| Name | Source | Version |
3636
|------|--------|---------|
37-
| <a name="module_template_null_resource"></a> [template\_null\_resource](#module\_template\_null\_resource) | ../ | n/a |
37+
| <a name="module_github_organization_settings"></a> [github\_organization\_settings](#module\_github\_organization\_settings) | ../ | n/a |
3838

3939
## Resources
4040

4141
No resources.
4242

4343
## Inputs
4444

45-
No inputs.
45+
| Name | Description | Type | Default | Required |
46+
|------|-------------|------|---------|:--------:|
47+
| <a name="input_billing_email"></a> [billing\_email](#input\_billing\_email) | The billing email address for the GitHub Organization. (Required) | `string` | n/a | yes |
48+
| <a name="input_owner"></a> [owner](#input\_owner) | Target GitHub organization or individual user account to manage. (Required) | `string` | n/a | yes |
49+
| <a name="input_token"></a> [token](#input\_token) | GitHub API Auth using OAuth or Personal Access Token. (Required) | `string` | n/a | yes |
4650

4751
## Outputs
4852

49-
| Name | Description |
50-
|------|-------------|
51-
| <a name="output_template_null_resource_id"></a> [template\_null\_resource\_id](#output\_template\_null\_resource\_id) | The ID of the null resource |
53+
No outputs.
5254
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/deploy.tf

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
1-
provider "null" {
2-
}
1+
provider "github" {
2+
3+
owner = var.owner
4+
token = var.token
35

4-
#provider "aws" {
5-
# region = "ca-central-1"
6-
#}
6+
#token = var.github_token # GITHUB_TOKEN - GitHub API Auth using OAuth or Personal Access Token
7+
#base_url = var.github_base_url # GITHUB_BASE_URL - Target GitHub base API endpoint. Required for GitHub Enterprise
8+
#owner = var.github_owner # GITHUB_OWNER - Target GitHub organization or individual user account to manage
9+
10+
#write_delay_ms = try(var.github_write_delay_ms, 1000) # Milliseconds to sleep between write ops for GitHub API Rate Limit
11+
#read_delay_ms = try(var.github_read_delay_ms, 0) # Milliseconds to sleep between read ops for GitHub API Rate Limit
12+
}
713

814
##################################################
9-
# Null Resource Module
15+
# GitHub Organization
1016
##################################################
1117

12-
module "template_null_resource" {
18+
module "github_organization_settings" {
1319
source = "../"
1420

15-
triggers = {
16-
name = "dsodk-template-code-terraform-module"
17-
trigger = "Change this text to trigger the module to replace null resources with new ones"
18-
}
21+
billing_email = var.billing_email
22+
company = "dsodk"
23+
email = "terraform.module.test@dsodk.io"
24+
location = "Global"
25+
name = "dsodk-test-github-org-module"
26+
description = "Test organization used by example in dsodk-code-module-terraform-github-organization"
27+
28+
default_repository_permission = "read"
29+
30+
members_can_create_repositories = false
31+
members_can_create_public_repositories = false
32+
members_can_create_private_repositories = false
33+
34+
members_can_create_pages = false
35+
members_can_create_public_pages = false
36+
members_can_create_private_pages = false
37+
members_can_fork_private_repositories = false
38+
39+
secret_scanning_enabled_for_new_repositories = true
40+
secret_scanning_push_protection_enabled_for_new_repositories = true
1941
}

examples/outputs.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
output "template_null_resource_id" {
2-
description = "The ID of the null resource"
3-
value = module.template_null_resource.template_null_resource_id
4-
}

examples/variables.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
##################################################
2+
# GitHub Provider Config
3+
##################################################
4+
5+
variable "owner" {
6+
description = "Target GitHub organization or individual user account to manage. (Required)"
7+
type = string
8+
}
9+
10+
variable "token" {
11+
description = "GitHub API Auth using OAuth or Personal Access Token. (Required)"
12+
type = string
13+
sensitive = true
14+
}
15+
16+
##################################################
17+
# GitHub Organization
18+
##################################################
19+
20+
variable "billing_email" {
21+
description = "The billing email address for the GitHub Organization. (Required)"
22+
type = string
23+
sensitive = true
24+
}

examples/versions.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ terraform {
22
required_version = ">= 1.0"
33

44
required_providers {
5-
# aws = {
6-
# source = "hashicorp/aws"
7-
# version = ">= 4.0"
8-
# },
9-
null = {
10-
source = "hashicorp/null"
11-
version = ">= 3.0"
5+
github = {
6+
source = "integrations/github"
7+
version = "5.3.0"
128
}
139
}
1410
}

0 commit comments

Comments
 (0)