From 370eec99068aacb9fd0a73ff6399f7c6020efb26 Mon Sep 17 00:00:00 2001 From: Martin Dojcak Date: Mon, 27 Jun 2022 21:59:32 +0200 Subject: [PATCH] Init --- .github/workflows/main.yml | 121 ++++++ .gitignore | 36 ++ .pre-commit-config.yaml | 33 ++ .secrets.baseline | 67 ++++ .tflint.hcl | 5 + LICENSE | 201 ++++++++++ README.md | 193 +++++++++ argo.tf | 85 ++++ examples/basic/README.md | 52 +++ examples/basic/main.tf | 104 +++++ examples/basic/providers.tf | 19 + helm.tf | 64 +++ helm/argocd-application/.helmignore | 23 ++ helm/argocd-application/Chart.yaml | 18 + .../argocd-application/templates/_helpers.tpl | 51 +++ .../templates/application.yaml | 19 + helm/argocd-application/values.yaml | 2 + iam.tf | 75 ++++ ll-logo.png | Bin 0 -> 12095 bytes outputs.tf | 14 + values.tf | 19 + variables.tf | 365 ++++++++++++++++++ versions.tf | 22 ++ 23 files changed, 1588 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 .secrets.baseline create mode 100644 .tflint.hcl create mode 100644 LICENSE create mode 100644 README.md create mode 100644 argo.tf create mode 100644 examples/basic/README.md create mode 100644 examples/basic/main.tf create mode 100644 examples/basic/providers.tf create mode 100644 helm.tf create mode 100644 helm/argocd-application/.helmignore create mode 100644 helm/argocd-application/Chart.yaml create mode 100644 helm/argocd-application/templates/_helpers.tpl create mode 100644 helm/argocd-application/templates/application.yaml create mode 100644 helm/argocd-application/values.yaml create mode 100644 iam.tf create mode 100644 ll-logo.png create mode 100644 outputs.tf create mode 100644 values.tf create mode 100644 variables.tf create mode 100644 versions.tf diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..244f575 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,121 @@ +name: Terraform validation + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + TERRAFORM_DOCS_VERSION: "v0.16.0" + TFLINT_VERSION: "v0.35.0" + TFSEC_VERSION: "v1.6.2" + +jobs: + terraform-validation: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/setup-python@v2 + name: "SETUP: Python" + + - uses: actions/cache@v2.0.0 + id: cache-terraform-docs + name: "CACHE: terraform-docs" + with: + path: | + ~/terraform-docs/bin/ + key: ${{ runner.os }}-terraform_docs-${{ env.TERRAFORM_DOCS_VERSION }} + restore-keys: | + ${{ runner.os}}-terraform_docs- + + - shell: bash + name: "INSTALL: terraform-docs" + if: steps.cache-terraform-docs.output.cache-hit != 'true' + run: | + wget https://github.com/terraform-docs/terraform-docs/releases/download/${{ env.TERRAFORM_DOCS_VERSION }}/terraform-docs-${{ env.TERRAFORM_DOCS_VERSION }}-linux-amd64.tar.gz + tar xvzf terraform-docs-${{ env.TERRAFORM_DOCS_VERSION }}-linux-amd64.tar.gz + mkdir -p ~/terraform-docs/bin/ + install terraform-docs ~/terraform-docs/bin/ + + - shell: bash + name: "SETUP: terraform-docs path" + run: echo '~/terraform-docs/bin/' >> $GITHUB_PATH + + - uses: actions/checkout@v2 + name: Checkout source code + + - uses: actions/cache@v2 + id: cache-pre-commit-dependencies + name: "CACHE: pip and pre-commit dependencies" + with: + path: | + ~/.cache/pre-commit + ~/.cache/pip + key: ${{ runner.os }}-pip-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + restore-keys: | + ${{ runner.os }}-pip-pre-commit- + + - uses: actions/cache@v2 + id: cache-tflint + name: "CACHE: tflint" + with: + path: | + ~/tflint/bin/ + key: ${{ runner.os }}-tflint-${{ env.TFLINT_VERSION }} + restore-keys: | + ${{ runner.os }}-tflint- + + - shell: bash + name: "INSTALL: detect-secrets" + run: | + pip install detect-secrets + + - shell: bash + name: "INSTALL: checkov" + run: | + pip install checkov + + - shell: bash + name: "INSTALL: tflint" + if: steps.cache-tflint.outputs.cache-hit != 'true' + run: | + wget https://github.com/terraform-linters/tflint/releases/download/${{ env.TFLINT_VERSION }}/tflint_linux_amd64.zip + unzip tflint_linux_amd64.zip + mkdir -p ~/tflint/bin/ + install tflint ~/tflint/bin/ + + - shell: bash + name: "SETUP: tflint path" + run: echo '~/tflint/bin/' >> $GITHUB_PATH + + - shell: bash + name: "INIT: TFLint" + run: tflint --init + + - uses: actions/cache@v2 + id: cache-tfsec + name: "CACHE: tfsec" + with: + path: | + ~/tfsec/bin/ + key: ${{ runner.os }}-tfsec-${{ env.TFSEC_VERSION }} + restore-keys: | + ${{ runner.os }}-tfsec- + + - shell: bash + name: "INSTALL: tfsec" + if: steps.cache-tfsec.outputs.cache-hit != 'true' + run: | + wget https://github.com/tfsec/tfsec/releases/download/${{ env.TFSEC_VERSION }}/tfsec-linux-amd64 + mkdir -p ~/tfsec/bin/ + install tfsec-linux-amd64 ~/tfsec/bin/ + + - shell: bash + name: "SETUP: tfsec path" + run: echo '~/tfsec/bin/' >> $GITHUB_PATH + + - uses: pre-commit/action@v2.0.0 + name: "RUN: pre-commit" + env: + AWS_DEFAULT_REGION: "eu-central-1" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd32dc8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log + +# Exclude all .tfvars files, which are likely to contain sentitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +# +*.tfvars + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Ignore CLI configuration files +.terraformrc +terraform.rc + +.terraform.lock.hcl diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..c498614 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: trailing-whitespace + - id: check-merge-conflict + - id: detect-aws-credentials + args: ['--allow-missing-credentials'] + - id: detect-private-key + - id: end-of-file-fixer + + - repo: https://github.com/antonbabenko/pre-commit-terraform + rev: v1.64.1 + hooks: + - id: terraform_fmt + - id: terraform_tflint + - id: terraform_validate + - id: checkov + - id: terraform_docs + args: + - '--args=--hide providers --sort-by required' + + - repo: https://github.com/pecigonzalo/pre-commit-terraform-vars + rev: v1.0.0 + hooks: + - id: terraform-vars + + - repo: https://github.com/Yelp/detect-secrets + rev: v1.2.0 + hooks: + - id: detect-secrets + args: ['--baseline', '.secrets.baseline'] + exclude: terraform.tfstate diff --git a/.secrets.baseline b/.secrets.baseline new file mode 100644 index 0000000..62fe8c6 --- /dev/null +++ b/.secrets.baseline @@ -0,0 +1,67 @@ +{ + "custom_plugin_paths": [], + "exclude": { + "files": null, + "lines": null + }, + "generated_at": "2020-09-21T15:31:24Z", + "plugins_used": [ + { + "name": "AWSKeyDetector" + }, + { + "name": "ArtifactoryDetector" + }, + { + "base64_limit": 4.5, + "name": "Base64HighEntropyString" + }, + { + "name": "BasicAuthDetector" + }, + { + "name": "CloudantDetector" + }, + { + "hex_limit": 3, + "name": "HexHighEntropyString" + }, + { + "name": "IbmCloudIamDetector" + }, + { + "name": "IbmCosHmacDetector" + }, + { + "name": "JwtTokenDetector" + }, + { + "keyword_exclude": null, + "name": "KeywordDetector" + }, + { + "name": "MailchimpDetector" + }, + { + "name": "PrivateKeyDetector" + }, + { + "name": "SlackDetector" + }, + { + "name": "SoftlayerDetector" + }, + { + "name": "StripeDetector" + }, + { + "name": "TwilioKeyDetector" + } + ], + "results": {}, + "version": "0.14.3", + "word_list": { + "file": null, + "hash": null + } +} diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..65c113e --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,5 @@ +plugin "aws" { + enabled = true + version = "0.13.2" + source = "github.com/terraform-linters/tflint-ruleset-aws" +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f6f1438 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2020] [Labyrinth Labs] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..13ec35f --- /dev/null +++ b/README.md @@ -0,0 +1,193 @@ +# AWS EKS keda Terraform module + +[![labyrinth labs logo](ll-logo.png)](https://lablabs.io/) + +We help companies build, run, deploy and scale software and infrastructure by embracing the right technologies and principles. Check out our website at https://lablabs.io/ + +--- + +<<<<<<< Updated upstream +![Terraform validation](https://github.com/lablabs/terraform-aws-eks-load-balancer-controller/workflows/Terraform%20validation/badge.svg?branch=main) +[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-success?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) +======= +[![Terraform validate](https://github.com/lablabs/terraform-aws-eks-keda/actions/workflows/validate.yaml/badge.svg)](https://github.com/lablabs/terraform-aws-eks-keda/actions/workflows/validate.yaml) +[![pre-commit](https://github.com/lablabs/terraform-aws-eks-keda/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/lablabs/terraform-aws-eks-keda/actions/workflows/pre-commit.yml) +>>>>>>> Stashed changes + +## Description + +A terraform module to deploy the AWS keda on Amazon EKS cluster. + +## Related Projects + +Check out these [related projects](https://github.com/orgs/lablabs/repositories?q=terraform-aws-eks&type=public&language=&sort=). + +## Deployment methods + +### Helm +Deploy helm chart by helm (default method, set `enabled = true`) + +### Argo kubernetes +Deploy helm chart as argo application by kubernetes manifest (set `enabled = true` and `argo_enabled = true`) + +### Argo helm +When deploying with ArgoCD application, Kubernetes terraform provider requires access to Kubernetes cluster API during plan time. This introduces potential issue when you want to deploy the cluster with this addon at the same time, during the same Terraform run. + +To overcome this issue, the module deploys the ArgoCD application object using the Helm provider, which does not require API access during plan. If you want to deploy the application using this workaround, you can set the `argo_helm_enabled` variable to `true`. + +Create helm release resource and deploy it as argo application (set `enabled = true`, `argo_enabled = true` and `argo_helm_enabled = true`) + +## AWS IAM resources + +To disable of creation IRSA role and IRSA policy, set `irsa_role_create = false` and `irsa_policy_enabled = false`, respectively + +## Examples + +See [Basic example](examples/basic/README.md) for further information. + + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 0.14 | +| [aws](#requirement\_aws) | >= 2.0 | +| [helm](#requirement\_helm) | >= 2.4.0 | +| [kubernetes](#requirement\_kubernetes) | >= 2.6 | +| [utils](#requirement\_utils) | >= 0.14.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_iam_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | +| [aws_iam_role.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | +| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | +| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | +| [helm_release.argo_application](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | +| [helm_release.this](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | +| [kubernetes_manifest.this](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/manifest) | resource | +| [aws_caller_identity.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | +| [aws_iam_policy_document.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | +| [aws_iam_policy_document.this_assume](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | +| [utils_deep_merge_yaml.argo_helm_values](https://registry.terraform.io/providers/cloudposse/utils/latest/docs/data-sources/deep_merge_yaml) | data source | +| [utils_deep_merge_yaml.values](https://registry.terraform.io/providers/cloudposse/utils/latest/docs/data-sources/deep_merge_yaml) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [cluster\_identity\_oidc\_issuer](#input\_cluster\_identity\_oidc\_issuer) | The OIDC Identity issuer for the cluster | `string` | n/a | yes | +| [cluster\_identity\_oidc\_issuer\_arn](#input\_cluster\_identity\_oidc\_issuer\_arn) | The OIDC Identity issuer ARN for the cluster that can be used to associate IAM roles with a service account | `string` | n/a | yes | +| [argo\_apiversion](#input\_argo\_apiversion) | ArgoCD Appliction apiVersion | `string` | `"argoproj.io/v1alpha1"` | no | +| [argo\_destionation\_server](#input\_argo\_destionation\_server) | Destination server for ArgoCD Application | `string` | `"https://kubernetes.default.svc"` | no | +| [argo\_enabled](#input\_argo\_enabled) | If set to true, the module will be deployed as ArgoCD application, otherwise it will be deployed as a Helm release | `bool` | `false` | no | +| [argo\_helm\_enabled](#input\_argo\_helm\_enabled) | If set to true, the ArgoCD Application manifest will be deployed using Kubernetes provider as a Helm release. Otherwise it'll be deployed as a Kubernetes manifest. See Readme for more info | `bool` | `false` | no | +| [argo\_helm\_values](#input\_argo\_helm\_values) | Value overrides to use when deploying argo application object with helm | `string` | `""` | no | +| [argo\_info](#input\_argo\_info) | ArgoCD info manifest parameter | `list` |
[
{
"name": "terraform",
"value": "true"
}
]
| no | +| [argo\_kubernetes\_manifest\_computed\_fields](#input\_argo\_kubernetes\_manifest\_computed\_fields) | List of paths of fields to be handled as "computed". The user-configured value for the field will be overridden by any different value returned by the API after apply. | `list(string)` |
[
"metadata.labels",
"metadata.annotations"
]
| no | +| [argo\_kubernetes\_manifest\_field\_manager\_force\_conflicts](#input\_argo\_kubernetes\_manifest\_field\_manager\_force\_conflicts) | Forcibly override any field manager conflicts when applying the kubernetes manifest resource | `bool` | `false` | no | +| [argo\_kubernetes\_manifest\_field\_manager\_name](#input\_argo\_kubernetes\_manifest\_field\_manager\_name) | The name of the field manager to use when applying the kubernetes manifest resource. Defaults to Terraform | `string` | `"Terraform"` | no | +| [argo\_kubernetes\_manifest\_wait\_for\_fields](#input\_argo\_kubernetes\_manifest\_wait\_for\_fields) | A map of fields and a corresponding regular expression with a pattern to wait for. The provider will wait until the field matches the regular expression. Use * for any value. | `map(string)` | `{}` | no | +| [argo\_metadata](#input\_argo\_metadata) | ArgoCD Application metadata configuration. Override or create additional metadata parameters | `map` | `{}` | no | +| [argo\_namespace](#input\_argo\_namespace) | Namespace to deploy ArgoCD application CRD to | `string` | `"argo"` | no | +| [argo\_project](#input\_argo\_project) | ArgoCD Application project | `string` | `"default"` | no | +| [argo\_spec](#input\_argo\_spec) | ArgoCD Application spec configuration. Override or create additional spec parameters | `map` | `{}` | no | +| [argo\_sync\_policy](#input\_argo\_sync\_policy) | ArgoCD syncPolicy manifest parameter | `map` | `{}` | no | +| [enabled](#input\_enabled) | Variable indicating whether deployment is enabled | `bool` | `true` | no | +| [helm\_atomic](#input\_helm\_atomic) | If set, installation process purges chart on fail. The wait flag will be set automatically if atomic is used | `bool` | `false` | no | +| [helm\_chart\_name](#input\_helm\_chart\_name) | Helm chart name to be installed | `string` | `"keda"` | no | +| [helm\_chart\_version](#input\_helm\_chart\_version) | Version of the Helm chart | `string` | `"2.7.2"` | no | +| [helm\_cleanup\_on\_fail](#input\_helm\_cleanup\_on\_fail) | Allow deletion of new resources created in this helm upgrade when upgrade fails | `bool` | `false` | no | +| [helm\_create\_namespace](#input\_helm\_create\_namespace) | Create the namespace if it does not yet exist | `bool` | `true` | no | +| [helm\_dependency\_update](#input\_helm\_dependency\_update) | Runs helm dependency update before installing the chart | `bool` | `false` | no | +| [helm\_description](#input\_helm\_description) | Set helm release description attribute (visible in the history) | `string` | `""` | no | +| [helm\_devel](#input\_helm\_devel) | Use helm chart development versions, too. Equivalent to version '>0.0.0-0'. If version is set, this is ignored | `bool` | `false` | no | +| [helm\_disable\_openapi\_validation](#input\_helm\_disable\_openapi\_validation) | If set, the installation process will not validate rendered helm templates against the Kubernetes OpenAPI Schema | `bool` | `false` | no | +| [helm\_disable\_webhooks](#input\_helm\_disable\_webhooks) | Prevent helm chart hooks from running | `bool` | `false` | no | +| [helm\_force\_update](#input\_helm\_force\_update) | Force helm resource update through delete/recreate if needed | `bool` | `false` | no | +| [helm\_keyring](#input\_helm\_keyring) | Location of public keys used for verification. Used only if helm\_package\_verify is true | `string` | `"~/.gnupg/pubring.gpg"` | no | +| [helm\_lint](#input\_helm\_lint) | Run the helm chart linter during the plan | `bool` | `false` | no | +| [helm\_package\_verify](#input\_helm\_package\_verify) | Verify the package before installing it. Helm uses a provenance file to verify the integrity of the chart; this must be hosted alongside the chart | `bool` | `false` | no | +| [helm\_postrender](#input\_helm\_postrender) | Value block with a path to a binary file to run after helm renders the manifest which can alter the manifest contents | `map(any)` | `{}` | no | +| [helm\_recreate\_pods](#input\_helm\_recreate\_pods) | Perform pods restart during helm upgrade/rollback | `bool` | `false` | no | +| [helm\_release\_max\_history](#input\_helm\_release\_max\_history) | Maximum number of release versions stored per release | `number` | `0` | no | +| [helm\_release\_name](#input\_helm\_release\_name) | Helm release name | `string` | `"keda-controller"` | no | +| [helm\_render\_subchart\_notes](#input\_helm\_render\_subchart\_notes) | If set, render helm subchart notes along with the parent | `bool` | `true` | no | +| [helm\_replace](#input\_helm\_replace) | Re-use the given name of helm release, only if that name is a deleted release which remains in the history. This is unsafe in production | `bool` | `false` | no | +| [helm\_repo\_ca\_file](#input\_helm\_repo\_ca\_file) | Helm repositories cert file | `string` | `""` | no | +| [helm\_repo\_cert\_file](#input\_helm\_repo\_cert\_file) | Helm repositories cert file | `string` | `""` | no | +| [helm\_repo\_key\_file](#input\_helm\_repo\_key\_file) | Helm repositories cert key file | `string` | `""` | no | +| [helm\_repo\_password](#input\_helm\_repo\_password) | Password for HTTP basic authentication against the helm repository | `string` | `""` | no | +| [helm\_repo\_url](#input\_helm\_repo\_url) | Helm repository | `string` | `"https://kedacore.github.io/charts"` | no | +| [helm\_repo\_username](#input\_helm\_repo\_username) | Username for HTTP basic authentication against the helm repository | `string` | `""` | no | +| [helm\_reset\_values](#input\_helm\_reset\_values) | When upgrading, reset the values to the ones built into the helm chart | `bool` | `false` | no | +| [helm\_reuse\_values](#input\_helm\_reuse\_values) | When upgrading, reuse the last helm release's values and merge in any overrides. If 'helm\_reset\_values' is specified, this is ignored | `bool` | `false` | no | +| [helm\_set\_sensitive](#input\_helm\_set\_sensitive) | Value block with custom sensitive values to be merged with the values yaml that won't be exposed in the plan's diff | `map(any)` | `{}` | no | +| [helm\_skip\_crds](#input\_helm\_skip\_crds) | If set, no CRDs will be installed before helm release | `bool` | `false` | no | +| [helm\_timeout](#input\_helm\_timeout) | Time in seconds to wait for any individual kubernetes operation (like Jobs for hooks) | `number` | `300` | no | +| [helm\_wait](#input\_helm\_wait) | Will wait until all helm release resources are in a ready state before marking the release as successful. It will wait for as long as timeout | `bool` | `false` | no | +| [helm\_wait\_for\_jobs](#input\_helm\_wait\_for\_jobs) | If wait is enabled, will wait until all helm Jobs have been completed before marking the release as successful. It will wait for as long as timeout | `bool` | `false` | no | +| [irsa\_additional\_policies](#input\_irsa\_additional\_policies) | Map of the additional policies to be attached to default role. Where key is arbiraty id and value is policy arn. | `map(string)` | `{}` | no | +| [irsa\_policy\_allow\_assume\_roles](#input\_irsa\_policy\_allow\_assume\_roles) | Allow assume specified roles. IRSA policy must be enabled to take effect. Default to all roles under source AWS account ("arn:aws:iam::{account\_id}:role/*"). | `list(string)` | `[]` | no | +| [irsa\_policy\_enabled](#input\_irsa\_policy\_enabled) | Whether to create opinionated policy for keda controller, see https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/v2.4.0/docs/install/iam_policy.json | `bool` | `true` | no | +| [irsa\_role\_create](#input\_irsa\_role\_create) | Whether to create IRSA role and annotate service account | `bool` | `true` | no | +| [irsa\_role\_name\_prefix](#input\_irsa\_role\_name\_prefix) | The IRSA role name prefix for keda controller | `string` | `"keda-controller"` | no | +| [irsa\_tags](#input\_irsa\_tags) | IRSA resources tags | `map(string)` | `{}` | no | +| [namespace](#input\_namespace) | The K8s namespace in which the keda controller controller will be created | `string` | `"keda-controller"` | no | +| [service\_account\_create](#input\_service\_account\_create) | Whether to create Service Account | `bool` | `true` | no | +| [service\_account\_name](#input\_service\_account\_name) | The k8s keda controller service account name | `string` | `"keda-operator"` | no | +| [settings](#input\_settings) | Additional settings which will be passed to the Helm chart values, see https://github.com/kedacore/charts/tree/main/keda | `map(any)` | `{}` | no | +| [values](#input\_values) | Additional yaml encoded values which will be passed to the Helm chart, see https://github.com/kedacore/charts/tree/main/keda | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [helm\_release\_application\_metadata](#output\_helm\_release\_application\_metadata) | Argo application helm release attributes | +| [helm\_release\_metadata](#output\_helm\_release\_metadata) | Helm release attributes | +| [kubernetes\_application\_attributes](#output\_kubernetes\_application\_attributes) | Argo kubernetes manifest attributes | + + +## Contributing and reporting issues + +Feel free to create an issue in this repository if you have questions, suggestions or feature requests. + +### Validation, linters and pull-requests + +We want to provide high quality code and modules. For this reason we are using +several [pre-commit hooks](.pre-commit-config.yaml) and +[GitHub Actions workflow](.github/workflows/main.yml). A pull-request to the +master branch will trigger these validations and lints automatically. Please +check your code before you will create pull-requests. See +[pre-commit documentation](https://pre-commit.com/) and +[GitHub Actions documentation](https://docs.github.com/en/actions) for further +details. + + +## License + +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) + +See [LICENSE](LICENSE) for full details. + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. diff --git a/argo.tf b/argo.tf new file mode 100644 index 0000000..144e66e --- /dev/null +++ b/argo.tf @@ -0,0 +1,85 @@ +locals { + argo_application_metadata = { + "labels" : try(var.argo_metadata.labels, {}), + "annotations" : try(var.argo_metadata.annotations, {}), + "finalizers" : try(var.argo_metadata.finalizers, []) + } + argo_application_values = { + "project" : var.argo_project + "source" : { + "repoURL" : var.helm_repo_url + "chart" : var.helm_chart_name + "targetRevision" : var.helm_chart_version + "helm" : { + "releaseName" : var.helm_release_name + "parameters" : [for k, v in var.settings : tomap({ "forceString" : true, "name" : k, "value" : v })] + "values" : var.enabled ? data.utils_deep_merge_yaml.values[0].output : "" + } + } + "destination" : { + "server" : var.argo_destionation_server + "namespace" : var.namespace + } + "syncPolicy" : var.argo_sync_policy + "info" : var.argo_info + } +} + +data "utils_deep_merge_yaml" "argo_helm_values" { + count = var.enabled && var.argo_enabled && var.argo_helm_enabled ? 1 : 0 + input = compact([ + yamlencode({ + "apiVersion" : var.argo_apiversion + }), + yamlencode({ + "spec" : local.argo_application_values + }), + yamlencode({ + "spec" : var.argo_spec + }), + yamlencode( + local.argo_application_metadata + ) + ]) +} + +resource "helm_release" "argo_application" { + count = var.enabled && var.argo_enabled && var.argo_helm_enabled ? 1 : 0 + + chart = "${path.module}/helm/argocd-application" + name = var.helm_release_name + namespace = var.argo_namespace + + values = [ + data.utils_deep_merge_yaml.argo_helm_values[0].output, + var.argo_helm_values + ] +} + +resource "kubernetes_manifest" "this" { + count = var.enabled && var.argo_enabled && !var.argo_helm_enabled ? 1 : 0 + manifest = { + "apiVersion" = var.argo_apiversion + "kind" = "Application" + "metadata" = merge( + local.argo_application_metadata, + { "name" = var.helm_release_name }, + { "namespace" = var.argo_namespace }, + ) + "spec" = merge( + local.argo_application_values, + var.argo_spec + ) + } + + computed_fields = var.argo_kubernetes_manifest_computed_fields + + field_manager { + name = var.argo_kubernetes_manifest_field_manager_name + force_conflicts = var.argo_kubernetes_manifest_field_manager_force_conflicts + } + + wait_for = { + fields = var.argo_kubernetes_manifest_wait_for_fields + } +} diff --git a/examples/basic/README.md b/examples/basic/README.md new file mode 100644 index 0000000..877e0f2 --- /dev/null +++ b/examples/basic/README.md @@ -0,0 +1,52 @@ +# Basic example + +The code in this example shows how to use the module with basic configuration and minimal set of other resources. + +## Deployment methods + +### Helm +Deploy helm chart by helm (default method, set `enabled = true`) + +### Argo kubernetes +Deploy helm chart as argo application by kubernetes manifest (set `enabled = true` and `argo_enabled = true`) + +### Argo helm +Create helm release resource and deploy it as argo application (set `enabled = true`, `argo_enabled = true` and `argo_helm_enabled = true`) + +## AWS IAM resources + +To disable of creation IRSA role and IRSA policy, set `irsa_role_create = false` and `irsa_policy_enabled = false`, respectively + + + +## Requirements + +No requirements. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [eks\_cluster](#module\_eks\_cluster) | cloudposse/eks-cluster/aws | 0.45.0 | +| [eks\_node\_group](#module\_eks\_node\_group) | cloudposse/eks-node-group/aws | 0.28.0 | +| [keda\_argo\_helm](#module\_keda\_argo\_helm) | ../../ | n/a | +| [keda\_argo\_kubernetes](#module\_keda\_argo\_kubernetes) | ../../ | n/a | +| [keda\_disabled](#module\_keda\_disabled) | ../../ | n/a | +| [keda\_helm](#module\_keda\_helm) | ../../ | n/a | +| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | 3.13.0 | + +## Resources + +| Name | Type | +|------|------| +| [aws_eks_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source | +| [aws_eks_cluster_auth.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source | + +## Inputs + +No inputs. + +## Outputs + +No outputs. + diff --git a/examples/basic/main.tf b/examples/basic/main.tf new file mode 100644 index 0000000..82b49a4 --- /dev/null +++ b/examples/basic/main.tf @@ -0,0 +1,104 @@ +module "vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "3.13.0" + + name = "keda-vpc" + cidr = "10.0.0.0/16" + azs = ["eu-central-1a", "eu-central-1b"] + public_subnets = ["10.0.101.0/24", "10.0.102.0/24"] + enable_nat_gateway = true +} + +module "eks_cluster" { + source = "cloudposse/eks-cluster/aws" + version = "0.45.0" + + region = "eu-central-1" + subnet_ids = module.vpc.public_subnets + vpc_id = module.vpc.vpc_id + name = "keda" +} + +module "eks_node_group" { + source = "cloudposse/eks-node-group/aws" + version = "0.28.0" + + cluster_name = "keda" + instance_types = ["t3.medium"] + subnet_ids = module.vpc.public_subnets + min_size = 1 + desired_size = 1 + max_size = 2 + depends_on = [module.eks_cluster.kubernetes_config_map_id] +} + +module "keda_disabled" { + source = "../../" + + enabled = false + + cluster_identity_oidc_issuer = module.eks_cluster.eks_cluster_identity_oidc_issuer + cluster_identity_oidc_issuer_arn = module.eks_cluster.eks_cluster_identity_oidc_issuer_arn +} + +module "keda_helm" { + source = "../../" + + enabled = true + argo_enabled = false + argo_helm_enabled = false + + cluster_identity_oidc_issuer = module.eks_cluster.eks_cluster_identity_oidc_issuer + cluster_identity_oidc_issuer_arn = module.eks_cluster.eks_cluster_identity_oidc_issuer_arn + + helm_release_name = "aws-keda-helm" + namespace = "aws-keda-helm" + + values = yamlencode({ + "podLabels" : { + "app" : "aws-keda-helm" + } + }) + + helm_timeout = 240 + helm_wait = true +} + +module "keda_argo_kubernetes" { + source = "../../" + + enabled = true + argo_enabled = true + argo_helm_enabled = false + + cluster_identity_oidc_issuer = module.eks_cluster.eks_cluster_identity_oidc_issuer + cluster_identity_oidc_issuer_arn = module.eks_cluster.eks_cluster_identity_oidc_issuer_arn + + helm_release_name = "aws-keda-argo-kubernetes" + namespace = "aws-keda-argo-kubernetes" + + argo_sync_policy = { + "automated" : {} + "syncOptions" = ["CreateNamespace=true"] + } +} + +module "keda_argo_helm" { + source = "../../" + + enabled = true + argo_enabled = true + argo_helm_enabled = true + + cluster_identity_oidc_issuer = module.eks_cluster.eks_cluster_identity_oidc_issuer + cluster_identity_oidc_issuer_arn = module.eks_cluster.eks_cluster_identity_oidc_issuer_arn + + helm_release_name = "aws-keda-argo-helm" + namespace = "aws-keda-argo-helm" + + argo_namespace = "argo" + argo_sync_policy = { + "automated" : {} + "syncOptions" = ["CreateNamespace=true"] + } +} diff --git a/examples/basic/providers.tf b/examples/basic/providers.tf new file mode 100644 index 0000000..e8369d1 --- /dev/null +++ b/examples/basic/providers.tf @@ -0,0 +1,19 @@ +provider "aws" { + region = "eu-central-1" +} + +data "aws_eks_cluster" "this" { + name = module.eks_cluster.eks_cluster_id +} + +data "aws_eks_cluster_auth" "this" { + name = module.eks_cluster.eks_cluster_id +} + +provider "helm" { + kubernetes { + host = data.aws_eks_cluster.this.endpoint + token = data.aws_eks_cluster_auth.this.token + cluster_ca_certificate = base64decode(data.aws_eks_cluster.this.certificate_authority.0.data) + } +} diff --git a/helm.tf b/helm.tf new file mode 100644 index 0000000..22c250b --- /dev/null +++ b/helm.tf @@ -0,0 +1,64 @@ +resource "helm_release" "this" { + count = var.enabled && !var.argo_enabled ? 1 : 0 + chart = var.helm_chart_name + create_namespace = var.helm_create_namespace + namespace = var.namespace + name = var.helm_release_name + version = var.helm_chart_version + repository = var.helm_repo_url + + repository_key_file = var.helm_repo_key_file + repository_cert_file = var.helm_repo_cert_file + repository_ca_file = var.helm_repo_ca_file + repository_username = var.helm_repo_username + repository_password = var.helm_repo_password + devel = var.helm_devel + verify = var.helm_package_verify + keyring = var.helm_keyring + timeout = var.helm_timeout + disable_webhooks = var.helm_disable_webhooks + reset_values = var.helm_reset_values + reuse_values = var.helm_reuse_values + force_update = var.helm_force_update + recreate_pods = var.helm_recreate_pods + cleanup_on_fail = var.helm_cleanup_on_fail + max_history = var.helm_release_max_history + atomic = var.helm_atomic + wait = var.helm_wait + wait_for_jobs = var.helm_wait_for_jobs + skip_crds = var.helm_skip_crds + render_subchart_notes = var.helm_render_subchart_notes + disable_openapi_validation = var.helm_disable_openapi_validation + dependency_update = var.helm_dependency_update + replace = var.helm_replace + description = var.helm_description + lint = var.helm_lint + + values = [ + data.utils_deep_merge_yaml.values[0].output + ] + + dynamic "set" { + for_each = var.settings + content { + name = set.key + value = set.value + } + } + + dynamic "set_sensitive" { + for_each = var.helm_set_sensitive + content { + name = set_sensitive.key + value = set_sensitive.value + } + } + + dynamic "postrender" { + for_each = var.helm_postrender + content { + binary_path = postrender.value + } + } + +} diff --git a/helm/argocd-application/.helmignore b/helm/argocd-application/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/argocd-application/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/argocd-application/Chart.yaml b/helm/argocd-application/Chart.yaml new file mode 100644 index 0000000..b450f61 --- /dev/null +++ b/helm/argocd-application/Chart.yaml @@ -0,0 +1,18 @@ +apiVersion: v2 +name: argocd-application +description: Helm wrapper for deploying ArgoCD application object + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 diff --git a/helm/argocd-application/templates/_helpers.tpl b/helm/argocd-application/templates/_helpers.tpl new file mode 100644 index 0000000..6dac3de --- /dev/null +++ b/helm/argocd-application/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "argocd_application.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "argocd_application.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "argocd_application.chart" -}} +{{- printf "%s" .Chart.Name | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "argocd_application.labels" -}} +helm.sh/chart: {{ include "argocd_application.chart" . }} +{{ include "argocd_application.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "argocd_application.selectorLabels" -}} +app.kubernetes.io/name: {{ include "argocd_application.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/helm/argocd-application/templates/application.yaml b/helm/argocd-application/templates/application.yaml new file mode 100644 index 0000000..3117c37 --- /dev/null +++ b/helm/argocd-application/templates/application.yaml @@ -0,0 +1,19 @@ +apiVersion: {{ .Values.apiVersion }} +kind: Application +metadata: + name: {{ include "argocd_application.fullname" . }} + labels: + {{- include "argocd_application.labels" . | nindent 4 }} + {{- if .Values.labels }} + {{ toYaml .Values.labels | nindent 4 }} + {{- end }} + annotations: + {{- if .Values.annotations }} + {{ toYaml .Values.annotations | indent 4 }} + {{- end }} + finalizers: + {{- if .Values.finalizers }} + {{ toYaml .Values.finalizers | indent 4 }} + {{- end }} +spec: + {{ toYaml .Values.spec | nindent 2 }} diff --git a/helm/argocd-application/values.yaml b/helm/argocd-application/values.yaml new file mode 100644 index 0000000..552d6da --- /dev/null +++ b/helm/argocd-application/values.yaml @@ -0,0 +1,2 @@ +nameOverride: "" +fullnameOverride: "" diff --git a/iam.tf b/iam.tf new file mode 100644 index 0000000..9c233b8 --- /dev/null +++ b/iam.tf @@ -0,0 +1,75 @@ +locals { + irsa_role_create = var.enabled && var.service_account_create && var.irsa_role_create + irsa_policy_allow_assume_roles = length(var.irsa_policy_allow_assume_roles) > 0 ? var.irsa_policy_allow_assume_roles : ["arn:aws:iam::${data.aws_caller_identity.this.id}:role/*"] +} + +data "aws_caller_identity" "this" {} + +data "aws_iam_policy_document" "this" { + count = local.irsa_role_create && var.irsa_policy_enabled ? 1 : 0 + + statement { + effect = "Allow" + actions = [ + "sts:AssumeRole" + ] + resources = local.irsa_policy_allow_assume_roles + } +} + +resource "aws_iam_policy" "this" { + count = local.irsa_role_create && var.irsa_policy_enabled ? 1 : 0 + name = "${var.irsa_role_name_prefix}-${var.helm_release_name}" + path = "/" + description = "Policy for keda service" + + policy = data.aws_iam_policy_document.this[0].json + tags = var.irsa_tags +} + +data "aws_iam_policy_document" "this_assume" { + count = local.irsa_role_create ? 1 : 0 + + statement { + actions = ["sts:AssumeRoleWithWebIdentity"] + + principals { + type = "Federated" + identifiers = [var.cluster_identity_oidc_issuer_arn] + } + + condition { + test = "StringEquals" + variable = "${replace(var.cluster_identity_oidc_issuer, "https://", "")}:sub" + + values = [ + "system:serviceaccount:${var.namespace}:${var.service_account_name}", + ] + } + + effect = "Allow" + } +} + +resource "aws_iam_role" "this" { + count = local.irsa_role_create ? 1 : 0 + + name = "${var.irsa_role_name_prefix}-${var.helm_release_name}" + assume_role_policy = data.aws_iam_policy_document.this_assume[0].json + + tags = var.irsa_tags +} + +resource "aws_iam_role_policy_attachment" "this" { + count = local.irsa_role_create ? 1 : 0 + + role = aws_iam_role.this[0].name + policy_arn = aws_iam_policy.this[0].arn +} + +resource "aws_iam_role_policy_attachment" "additional" { + for_each = local.irsa_role_create ? var.irsa_additional_policies : {} + + role = aws_iam_role.this[0].name + policy_arn = each.value +} diff --git a/ll-logo.png b/ll-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..8aa2c6a4997fbdcf7009e089b2d07ad4a89218a6 GIT binary patch literal 12095 zcmbVxWl$YF(C)##xVsmJ;!xbRc#FHcyL)l>!ol6$DeiFK;O_3Ox9^Yp^WOR9o6KgC zooqIf+0E?pBvMIH3I&k>5dZ+7$ViK;000nr|He`9kpKGPNi$Ob04>c+?U##+p*xv_ zlf9XxjVYOnr-Lb(sfVQ*0N}9#&d_eAEOQFm#19PzK%=n|kr^;e_x3;HN~@QgxU~3s zE&Dl?H5cZ{QYSb*vz$46>~7jWaet)D%YIe&CajY9NKuyj(|LS-Yu|Z@HSX>AdGg#X z*F%cx>)VseOVv4c_%kPWk%L$7^E#B&y72z>dZs6L@1twxF_;t=OP}|4$PXoP_u2V- z%4O)#bEjp&X$`RY&2xPdQ~&E`ZpUqh-up((CyAecQZl2aDf#HLbmG&WS6ayDH+etA zX&KnV>tlY3K-`3fn2?Y+H*X<5<2O!`9_r`ej;rZq`}^sn+`~uY=MtS}`&f_L64Jt# z!%=^_4^zWueC3aKsB-5|2Y#VMpQ=r7L3eIB%7XJ%Wwy7Gsqqg^klvne)wPlz{pGy? zY#fRCTJqXXY}BwKrD?g782uX|9doAC#*QofhctHuGFy47 z=^fHjdeOC@2gZ9pRcI&Sl2LEUHPjI;ZA^OGopZvX1oBRFWt@V$bh93KG z84X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d00001 diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..17d94f0 --- /dev/null +++ b/outputs.tf @@ -0,0 +1,14 @@ +output "helm_release_metadata" { + description = "Helm release attributes" + value = try(helm_release.this[0].metadata, {}) +} + +output "helm_release_application_metadata" { + description = "Argo application helm release attributes" + value = try(helm_release.argo_application[0].metadata, {}) +} + +output "kubernetes_application_attributes" { + description = "Argo kubernetes manifest attributes" + value = try(kubernetes_manifest.this[0], {}) +} diff --git a/values.tf b/values.tf new file mode 100644 index 0000000..8368696 --- /dev/null +++ b/values.tf @@ -0,0 +1,19 @@ +locals { + values = yamlencode({ + "serviceAccount" : { + "create" : var.service_account_create + "name" : var.service_account_name + "annotations" : { + "eks.amazonaws.com/role-arn" : local.irsa_role_create ? aws_iam_role.this[0].arn : "" + } + } + }) +} + +data "utils_deep_merge_yaml" "values" { + count = var.enabled ? 1 : 0 + input = compact([ + local.values, + var.values + ]) +} diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..3e1aa47 --- /dev/null +++ b/variables.tf @@ -0,0 +1,365 @@ +variable "enabled" { + type = bool + default = true + description = "Variable indicating whether deployment is enabled" +} + +variable "cluster_identity_oidc_issuer" { + type = string + description = "The OIDC Identity issuer for the cluster" +} + +variable "cluster_identity_oidc_issuer_arn" { + type = string + description = "The OIDC Identity issuer ARN for the cluster that can be used to associate IAM roles with a service account" +} + +variable "helm_chart_name" { + type = string + default = "keda" + description = "Helm chart name to be installed" +} + +variable "helm_chart_version" { + type = string + default = "2.7.2" + description = "Version of the Helm chart" +} + +variable "helm_release_name" { + type = string + default = "keda-controller" + description = "Helm release name" +} +variable "helm_repo_url" { + type = string + default = "https://kedacore.github.io/charts" + description = "Helm repository" +} + +variable "namespace" { + type = string + default = "keda-controller" + description = "The K8s namespace in which the keda controller controller will be created" +} + +variable "service_account_create" { + type = bool + default = true + description = "Whether to create Service Account" +} + +variable "service_account_name" { + default = "keda-operator" + description = "The k8s keda controller service account name" +} + +variable "irsa_role_create" { + type = bool + default = true + description = "Whether to create IRSA role and annotate service account" +} + +variable "irsa_role_name_prefix" { + type = string + default = "keda-controller" + description = "The IRSA role name prefix for keda controller" +} + +variable "irsa_policy_enabled" { + type = bool + default = true + description = "Whether to create opinionated policy for keda controller, see https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/v2.4.0/docs/install/iam_policy.json" +} + +variable "irsa_policy_allow_assume_roles" { + type = list(string) + default = [] + description = "Allow assume specified roles. IRSA policy must be enabled to take effect. Default to all roles under source AWS account (\"arn:aws:iam::{account_id}:role/*\")." +} + +variable "irsa_additional_policies" { + type = map(string) + default = {} + description = "Map of the additional policies to be attached to default role. Where key is arbiraty id and value is policy arn." +} + +variable "irsa_tags" { + type = map(string) + default = {} + description = "IRSA resources tags" +} + +variable "settings" { + type = map(any) + default = {} + description = "Additional settings which will be passed to the Helm chart values, see https://github.com/kedacore/charts/tree/main/keda" +} + +variable "values" { + type = string + default = "" + description = "Additional yaml encoded values which will be passed to the Helm chart, see https://github.com/kedacore/charts/tree/main/keda" +} + +variable "argo_enabled" { + type = bool + default = false + description = "If set to true, the module will be deployed as ArgoCD application, otherwise it will be deployed as a Helm release" +} + +variable "argo_namespace" { + type = string + default = "argo" + description = "Namespace to deploy ArgoCD application CRD to" +} + +variable "argo_destionation_server" { + type = string + default = "https://kubernetes.default.svc" + description = "Destination server for ArgoCD Application" +} + +variable "argo_project" { + type = string + default = "default" + description = "ArgoCD Application project" +} + +variable "argo_info" { + default = [{ + "name" = "terraform" + "value" = "true" + }] + description = "ArgoCD info manifest parameter" +} + +variable "argo_sync_policy" { + default = {} + description = "ArgoCD syncPolicy manifest parameter" +} + +variable "argo_metadata" { + default = {} + description = "ArgoCD Application metadata configuration. Override or create additional metadata parameters" +} + +variable "argo_spec" { + default = {} + description = "ArgoCD Application spec configuration. Override or create additional spec parameters" +} + +variable "argo_apiversion" { + default = "argoproj.io/v1alpha1" + description = "ArgoCD Appliction apiVersion" +} + +variable "argo_kubernetes_manifest_computed_fields" { + type = list(string) + default = ["metadata.labels", "metadata.annotations"] + description = "List of paths of fields to be handled as \"computed\". The user-configured value for the field will be overridden by any different value returned by the API after apply." +} + +variable "argo_kubernetes_manifest_field_manager_name" { + default = "Terraform" + description = "The name of the field manager to use when applying the kubernetes manifest resource. Defaults to Terraform" +} + +variable "argo_kubernetes_manifest_field_manager_force_conflicts" { + type = bool + default = false + description = "Forcibly override any field manager conflicts when applying the kubernetes manifest resource" +} + +variable "argo_kubernetes_manifest_wait_for_fields" { + type = map(string) + default = {} + description = "A map of fields and a corresponding regular expression with a pattern to wait for. The provider will wait until the field matches the regular expression. Use * for any value." +} + +variable "argo_helm_enabled" { + type = bool + default = false + description = "If set to true, the ArgoCD Application manifest will be deployed using Kubernetes provider as a Helm release. Otherwise it'll be deployed as a Kubernetes manifest. See Readme for more info" +} + +variable "argo_helm_values" { + type = string + default = "" + description = "Value overrides to use when deploying argo application object with helm" +} + +variable "helm_create_namespace" { + type = bool + default = true + description = "Create the namespace if it does not yet exist" +} + +variable "helm_repo_key_file" { + type = string + default = "" + description = "Helm repositories cert key file" +} + +variable "helm_repo_cert_file" { + type = string + default = "" + description = "Helm repositories cert file" +} + +variable "helm_repo_ca_file" { + type = string + default = "" + description = "Helm repositories cert file" +} + +variable "helm_repo_username" { + type = string + default = "" + description = "Username for HTTP basic authentication against the helm repository" +} + +variable "helm_repo_password" { + type = string + default = "" + description = "Password for HTTP basic authentication against the helm repository" +} + +variable "helm_devel" { + type = bool + default = false + description = "Use helm chart development versions, too. Equivalent to version '>0.0.0-0'. If version is set, this is ignored" +} + +variable "helm_package_verify" { + type = bool + default = false + description = "Verify the package before installing it. Helm uses a provenance file to verify the integrity of the chart; this must be hosted alongside the chart" +} + +variable "helm_keyring" { + type = string + default = "~/.gnupg/pubring.gpg" + description = "Location of public keys used for verification. Used only if helm_package_verify is true" +} + +variable "helm_timeout" { + type = number + default = 300 + description = "Time in seconds to wait for any individual kubernetes operation (like Jobs for hooks)" +} + +variable "helm_disable_webhooks" { + type = bool + default = false + description = "Prevent helm chart hooks from running" +} + +variable "helm_reset_values" { + type = bool + default = false + description = "When upgrading, reset the values to the ones built into the helm chart" +} + +variable "helm_reuse_values" { + type = bool + default = false + description = "When upgrading, reuse the last helm release's values and merge in any overrides. If 'helm_reset_values' is specified, this is ignored" +} + +variable "helm_force_update" { + type = bool + default = false + description = "Force helm resource update through delete/recreate if needed" +} + +variable "helm_recreate_pods" { + type = bool + default = false + description = "Perform pods restart during helm upgrade/rollback" +} + +variable "helm_cleanup_on_fail" { + type = bool + default = false + description = "Allow deletion of new resources created in this helm upgrade when upgrade fails" +} + +variable "helm_release_max_history" { + type = number + default = 0 + description = "Maximum number of release versions stored per release" +} + +variable "helm_atomic" { + type = bool + default = false + description = "If set, installation process purges chart on fail. The wait flag will be set automatically if atomic is used" +} + +variable "helm_wait" { + type = bool + default = false + description = "Will wait until all helm release resources are in a ready state before marking the release as successful. It will wait for as long as timeout" +} + +variable "helm_wait_for_jobs" { + type = bool + default = false + description = "If wait is enabled, will wait until all helm Jobs have been completed before marking the release as successful. It will wait for as long as timeout" +} + + +variable "helm_skip_crds" { + type = bool + default = false + description = "If set, no CRDs will be installed before helm release" +} + +variable "helm_render_subchart_notes" { + type = bool + default = true + description = "If set, render helm subchart notes along with the parent" +} + +variable "helm_disable_openapi_validation" { + type = bool + default = false + description = "If set, the installation process will not validate rendered helm templates against the Kubernetes OpenAPI Schema" +} + +variable "helm_set_sensitive" { + type = map(any) + default = {} + description = "Value block with custom sensitive values to be merged with the values yaml that won't be exposed in the plan's diff" +} + +variable "helm_dependency_update" { + type = bool + default = false + description = "Runs helm dependency update before installing the chart" +} + +variable "helm_replace" { + type = bool + default = false + description = "Re-use the given name of helm release, only if that name is a deleted release which remains in the history. This is unsafe in production" +} + +variable "helm_description" { + type = string + default = "" + description = "Set helm release description attribute (visible in the history)" +} + +variable "helm_postrender" { + type = map(any) + default = {} + description = "Value block with a path to a binary file to run after helm renders the manifest which can alter the manifest contents" +} + +variable "helm_lint" { + type = bool + default = false + description = "Run the helm chart linter during the plan" +} diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..87f20d8 --- /dev/null +++ b/versions.tf @@ -0,0 +1,22 @@ +terraform { + required_version = ">= 0.14" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 2.0" + } + kubernetes = { + source = "hashicorp/kubernetes" + version = ">= 2.6" + } + helm = { + source = "hashicorp/helm" + version = ">= 2.4.0" + } + utils = { + source = "cloudposse/utils" + version = ">= 0.14.0" + } + } +}