Skip to content

Commit 67a5cff

Browse files
committed
feat(aws): add single module for EKS addon
Signed-off-by: Frederic Leger <frederic@webofmars.com>
1 parent 7c51076 commit 67a5cff

7 files changed

Lines changed: 140 additions & 0 deletions

File tree

aws/eks-addon/.tflint.hcl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
plugin "terraform" {
2+
enabled = true
3+
preset = "recommended"
4+
}
5+
6+
plugin "aws" {
7+
enabled = true
8+
version = "0.17.1"
9+
source = "github.com/terraform-linters/tflint-ruleset-aws"
10+
}

aws/eks-addon/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# eks addons
2+
3+
Deploy a single EKS addon to an EKS cluster.
4+
The main difference from the eks-addons module is that this module gives you more control over the addon,
5+
such as configuring an IRSA role.
6+
7+
<!-- BEGIN_TF_DOCS -->
8+
## Requirements
9+
10+
| Name | Version |
11+
|------|---------|
12+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.3 |
13+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.67.0, < 5.0.0 |
14+
| <a name="requirement_time"></a> [time](#requirement\_time) | ~> 0.9.1 |
15+
16+
## Providers
17+
18+
| Name | Version |
19+
|------|---------|
20+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.67.0, < 5.0.0 |
21+
| <a name="provider_time"></a> [time](#provider\_time) | ~> 0.9.1 |
22+
23+
## Modules
24+
25+
No modules.
26+
27+
## Resources
28+
29+
| Name | Type |
30+
|------|------|
31+
| [aws_eks_addon.addon](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_addon) | resource |
32+
| [time_static.last_update](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | resource |
33+
34+
## Inputs
35+
36+
| Name | Description | Type | Default | Required |
37+
|------|-------------|------|---------|:--------:|
38+
| <a name="input_addon_version"></a> [addon\_version](#input\_addon\_version) | The version of the addon to be deployed. | `string` | n/a | yes |
39+
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The name of the cluster | `string` | n/a | yes |
40+
| <a name="input_configuration_values"></a> [configuration\_values](#input\_configuration\_values) | The configuration values for the addon. | `string` | `null` | no |
41+
| <a name="input_customer"></a> [customer](#input\_customer) | Customer tag for the addon to be deployed | `string` | `""` | no |
42+
| <a name="input_name"></a> [name](#input\_name) | The name of the addon to be deployed | `string` | n/a | yes |
43+
| <a name="input_service_account_role_arn"></a> [service\_account\_role\_arn](#input\_service\_account\_role\_arn) | The ARN of the service account role to use for the addon. | `string` | `null` | no |
44+
| <a name="input_tags"></a> [tags](#input\_tags) | Default tags to add to resources | `map(any)` | `{}` | no |
45+
46+
## Outputs
47+
48+
| Name | Description |
49+
|------|-------------|
50+
| <a name="output_addon_arn"></a> [addon\_arn](#output\_addon\_arn) | The ARN of the EKS addon |
51+
<!-- END_TF_DOCS -->

aws/eks-addon/eks-addon.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resource "aws_eks_addon" "addon" {
2+
addon_name = var.name
3+
addon_version = var.addon_version
4+
cluster_name = var.cluster_name
5+
configuration_values = var.configuration_values
6+
resolve_conflicts = "OVERWRITE"
7+
service_account_role_arn = var.service_account_role_arn != null && var.service_account_role_arn != "" ? var.service_account_role_arn : null
8+
tags = local.interpolated_tags
9+
}

aws/eks-addon/main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
locals {
2+
# tflint-ignore: terraform_unused_declarations
3+
interpolated_tags = merge({
4+
"Name" = var.name,
5+
"Customer" = var.customer,
6+
"ManagedBy" = "Terraform",
7+
"LastModifiedAt" = time_static.last_update.rfc3339,
8+
},
9+
var.tags
10+
)
11+
}
12+
13+
resource "time_static" "last_update" {
14+
}

aws/eks-addon/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "addon_arn" {
2+
description = "The ARN of the EKS addon"
3+
value = aws_eks_addon.addon.arn
4+
}

aws/eks-addon/providers.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws",
5+
version = ">= 4.67.0, < 5.0.0"
6+
}
7+
time = {
8+
source = "hashicorp/time",
9+
version = "~> 0.9.1"
10+
}
11+
}
12+
required_version = "~> 1.3"
13+
}

aws/eks-addon/variables.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
variable "name" {
2+
description = "The name of the addon to be deployed"
3+
type = string
4+
}
5+
6+
variable "customer" {
7+
description = "Customer tag for the addon to be deployed"
8+
type = string
9+
default = ""
10+
}
11+
12+
variable "tags" {
13+
description = "Default tags to add to resources"
14+
type = map(any)
15+
default = {}
16+
}
17+
18+
# module specific variables
19+
variable "cluster_name" {
20+
description = "The name of the cluster"
21+
type = string
22+
}
23+
24+
variable "addon_version" {
25+
description = "The version of the addon to be deployed."
26+
type = string
27+
}
28+
29+
variable "service_account_role_arn" {
30+
description = "The ARN of the service account role to use for the addon."
31+
type = string
32+
default = null
33+
}
34+
35+
variable "configuration_values" {
36+
description = "The configuration values for the addon."
37+
type = string
38+
default = null
39+
}

0 commit comments

Comments
 (0)