Skip to content

Commit

Permalink
Support outputs of default_version and latest_versions in eks-addon
Browse files Browse the repository at this point in the history
  • Loading branch information
posquit0 committed Nov 13, 2023
1 parent ea73a60 commit 069b201
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
8 changes: 7 additions & 1 deletion modules/eks-addon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ This module creates following resources.
| Name | Type |
|------|------|
| [aws_eks_addon.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_addon) | resource |
| [aws_eks_addon_version.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_addon_version) | data source |
| [aws_eks_addon_version.latest](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_addon_version) | data source |
| [aws_eks_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source |

## Inputs

Expand All @@ -53,14 +56,17 @@ This module creates following resources.

| Name | Description |
|------|-------------|
| <a name="output_addon_version"></a> [addon\_version](#output\_addon\_version) | The version of the EKS add-on. |
| <a name="output_arn"></a> [arn](#output\_arn) | The ARN of the EKS add-on. |
| <a name="output_cluster_name"></a> [cluster\_name](#output\_cluster\_name) | The name of the EKS cluster. |
| <a name="output_conflict_resolution_strategy_on_create"></a> [conflict\_resolution\_strategy\_on\_create](#output\_conflict\_resolution\_strategy\_on\_create) | How to resolve field value conflicts when migrating a self-managed add-on to an EKS add-on. |
| <a name="output_conflict_resolution_strategy_on_update"></a> [conflict\_resolution\_strategy\_on\_update](#output\_conflict\_resolution\_strategy\_on\_update) | How to resolve field value conflicts for an EKS add-on if you've changed a value from the EKS default value. |
| <a name="output_created_at"></a> [created\_at](#output\_created\_at) | Date and time in RFC3339 format that the EKS add-on was created. |
| <a name="output_default_version"></a> [default\_version](#output\_default\_version) | The default version of the EKS add-on compatible with the EKS cluster version. |
| <a name="output_id"></a> [id](#output\_id) | The ID of the EKS add-on. |
| <a name="output_is_latest"></a> [is\_latest](#output\_is\_latest) | Whether the EKS add-on version is the latest available. |
| <a name="output_latest_version"></a> [latest\_version](#output\_latest\_version) | The latest version of the EKS add-on compatible with the EKS cluster version. |
| <a name="output_name"></a> [name](#output\_name) | The name of the EKS add-on. |
| <a name="output_service_account_role"></a> [service\_account\_role](#output\_service\_account\_role) | The ARN (Amazon Resource Name) of the IAM Role to bind to the add-on's service account |
| <a name="output_updated_at"></a> [updated\_at](#output\_updated\_at) | Date and time in RFC3339 format that the EKS add-on was updated. |
| <a name="output_version"></a> [version](#output\_version) | The version of the EKS add-on. |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
20 changes: 20 additions & 0 deletions modules/eks-addon/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,23 @@ resource "aws_eks_addon" "this" {
var.tags,
)
}


###################################################
# Versions of EKS Addon
###################################################

data "aws_eks_cluster" "this" {
name = var.cluster_name
}

data "aws_eks_addon_version" "default" {
addon_name = var.name
kubernetes_version = data.aws_eks_cluster.this.version
}

data "aws_eks_addon_version" "latest" {
addon_name = var.name
kubernetes_version = data.aws_eks_cluster.this.version
most_recent = true
}
45 changes: 30 additions & 15 deletions modules/eks-addon/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
output "id" {
description = "The ID of the EKS add-on."
value = aws_eks_addon.this.id
}

output "arn" {
description = "The ARN of the EKS add-on."
value = aws_eks_addon.this.arn
}

output "cluster_name" {
description = "The name of the EKS cluster."
value = aws_eks_addon.this.cluster_name
Expand All @@ -8,29 +18,24 @@ output "name" {
value = aws_eks_addon.this.addon_name
}

output "addon_version" {
output "version" {
description = "The version of the EKS add-on."
value = aws_eks_addon.this.addon_version
}

output "id" {
description = "The ID of the EKS add-on."
value = aws_eks_addon.this.id
}

output "arn" {
description = "The ARN of the EKS add-on."
value = aws_eks_addon.this.arn
output "default_version" {
description = "The default version of the EKS add-on compatible with the EKS cluster version."
value = data.aws_eks_addon_version.default.version
}

output "created_at" {
description = "Date and time in RFC3339 format that the EKS add-on was created."
value = aws_eks_addon.this.created_at
output "latest_version" {
description = "The latest version of the EKS add-on compatible with the EKS cluster version."
value = data.aws_eks_addon_version.latest.version
}

output "updated_at" {
description = "Date and time in RFC3339 format that the EKS add-on was updated."
value = aws_eks_addon.this.modified_at
output "is_latest" {
description = "Whether the EKS add-on version is the latest available."
value = aws_eks_addon.this.addon_version == data.aws_eks_addon_version.latest.version
}

output "service_account_role" {
Expand All @@ -47,3 +52,13 @@ output "conflict_resolution_strategy_on_update" {
description = "How to resolve field value conflicts for an EKS add-on if you've changed a value from the EKS default value."
value = aws_eks_addon.this.resolve_conflicts_on_update
}

output "created_at" {
description = "Date and time in RFC3339 format that the EKS add-on was created."
value = aws_eks_addon.this.created_at
}

output "updated_at" {
description = "Date and time in RFC3339 format that the EKS add-on was updated."
value = aws_eks_addon.this.modified_at
}

0 comments on commit 069b201

Please sign in to comment.