diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ec25d53..df69b44 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @Flaconi/devops +* @Flaconi/devops @Flaconi/platform @Flaconi/ci diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b087fbe..8123d6c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -59,4 +59,4 @@ jobs: git diff --quiet || { echo "Build Changes"; git diff; git status; false; } env: TARGET: ${{ matrix.target }} - RETRIES: 20 + RETRIES: 1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b888ae3..9cb714a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,4 +47,4 @@ jobs: } retry make test env: - RETRIES: 20 + RETRIES: 1 diff --git a/README.md b/README.md index da64134..85bc55e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ -# terraform-module-template -Template for Terraform modules - - +# terraform-algolia-api-keys + +That module allows to create algolia api keys + +[![lint](https://github.com/flaconi/terraform-algolia-api-keys/workflows/lint/badge.svg)](https://github.com/flaconi/terraform-algolia-api-keys/actions?query=workflow%3Alint) +[![test](https://github.com/flaconi/terraform-algolia-api-keys/workflows/test/badge.svg)](https://github.com/flaconi/terraform-algolia-api-keys/actions?query=workflow%3Atest) +[![Tag](https://img.shields.io/github/tag/flaconi/terraform-algolia-api-keys.svg)](https://github.com/flaconi/terraform-algolia-api-keys/releases) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) For requirements regarding module structure: [style-guide-terraform.md](https://github.com/Flaconi/devops-docs/blob/master/doc/conventions/style-guide-terraform.md) @@ -53,4 +52,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..72d6b4d --- /dev/null +++ b/main.tf @@ -0,0 +1,5 @@ +resource "algolia_api_key" "this" { + for_each = var.api_keys + acl = each.value.acl + description = each.value.description +} diff --git a/output.tf b/output.tf new file mode 100644 index 0000000..b28e982 --- /dev/null +++ b/output.tf @@ -0,0 +1,5 @@ +output "api_keys" { + description = "Created API Keys through terraform" + value = algolia_api_key.this + sensitive = true +} diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..499ac68 --- /dev/null +++ b/variables.tf @@ -0,0 +1,12 @@ +variable "api_keys" { + type = map(object({ + description = string, + acl = set(string) + })) + default = {} + description = "Map of API Keys" + validation { + condition = alltrue(flatten([for key in var.api_keys : [for p in key.acl : contains(["search", "browse", "addObject", "deleteObject", "listIndexes", "deleteIndex", "settings", "analytics", "recommendation", "usage", "nluReadAnswers", "logs", "seeUnretrievableAttributes"], p)]])) + error_message = "Only the following permissions are allowed: search, browse, addObject, deleteObject, listIndexes, deleteIndex, settings, analytics, recommendation, usage, nluReadAnswers, logs, seeUnretrievableAttributes" + } +} diff --git a/versions.tf b/versions.tf index e6b4cbd..d6e3e20 100644 --- a/versions.tf +++ b/versions.tf @@ -1,3 +1,9 @@ terraform { - required_version = "~> 1.3" + required_providers { + algolia = { + source = "k-yomo/algolia" + version = "0.6.0" + } + } + required_version = ">= 1.5" }