From 19c2ed204dae312339d68024ecd40e853d8c86c0 Mon Sep 17 00:00:00 2001 From: Sergey Novikov Date: Wed, 16 Oct 2024 15:16:34 +0200 Subject: [PATCH] Add module code --- README.md | 39 ++++++++++++++++++++++++++------------- main.tf | 4 ++++ variables.tf | 14 ++++++++++++++ versions.tf | 6 ++++++ 4 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 main.tf create mode 100644 variables.tf diff --git a/README.md b/README.md index da64134..d452159 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,12 @@ -# terraform-module-template -Template for Terraform modules - - -[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) +# terraform-github-app-installation + +This module manages GitHub App permissions for multiple repositories + +[![lint](https://github.com/flaconi/terraform-github-app-installation/workflows/lint/badge.svg)](https://github.com/flaconi/terraform-github-app-installation/actions?query=workflow%3Alint) +[![test](https://github.com/flaconi/terraform-github-app-installation/workflows/test/badge.svg)](https://github.com/flaconi/terraform-github-app-installation/actions?query=workflow%3Atest) +[![Tag](https://img.shields.io/github/tag/flaconi/terraform-github-app-installation.svg)](https://github.com/flaconi/terraform-github-app-installation/releases) -For requirements regarding module structure: [style-guide-terraform.md](https://github.com/Flaconi/devops-docs/blob/master/doc/conventions/style-guide-terraform.md) +[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) @@ -18,7 +16,9 @@ For requirements regarding module structure: [style-guide-terraform.md](https:// ## Providers -No providers. +| Name | Version | +|------|---------| +| [github](#provider\_github) | ~> 6.2 | @@ -28,13 +28,26 @@ No providers. | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | ~> 1.3 | +| [github](#requirement\_github) | ~> 6.2 | ## Required Inputs -No required inputs. +The following input variables are required: + +### [installation\_id](#input\_installation\_id) + +Description: GitHub App installation id + +Type: `string` + +### [repositories](#input\_repositories) + +Description: List of names of repositories which will be granted access to. + +Type: `list(string)` ## Optional Inputs @@ -53,4 +66,4 @@ No outputs. **[MIT License](LICENSE)** -Copyright (c) 2023 **[Flaconi GmbH](https://github.com/flaconi)** +Copyright (c) 2024 **[Flaconi GmbH](https://github.com/flaconi)** diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..1de0fe2 --- /dev/null +++ b/main.tf @@ -0,0 +1,4 @@ +resource "github_app_installation_repositories" "this" { + installation_id = var.installation_id + selected_repositories = var.repositories +} diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..a55211e --- /dev/null +++ b/variables.tf @@ -0,0 +1,14 @@ +variable "installation_id" { + description = "GitHub App installation id" + type = string + sensitive = true +} + +variable "repositories" { + description = "List of names of repositories which will be granted access to." + type = list(string) + validation { + condition = length(var.repositories) > 0 + error_message = "Application should have permission for at least one repository" + } +} diff --git a/versions.tf b/versions.tf index e6b4cbd..167b647 100644 --- a/versions.tf +++ b/versions.tf @@ -1,3 +1,9 @@ terraform { + required_providers { + github = { + source = "integrations/github" + version = "~> 6.2" + } + } required_version = "~> 1.3" }