Skip to content

Commit

Permalink
Do not validate inputs when disabled (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru authored Aug 8, 2023
1 parent 7011101 commit 5d8145a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ We highly recommend that in your code you pin the version to the exact version y
using so that your infrastructure remains stable, and update versions in a
systematic way so that they do not catch you by surprise.

Also, because of a bug in the Terraform registry ([hashicorp/terraform#21417](https://github.com/hashicorp/terraform/issues/21417)),
the registry shows many of our inputs as required when in fact they are optional.
The table below correctly indicates which inputs are required.


Here's how to invoke this module in your projects

Expand Down Expand Up @@ -167,7 +163,7 @@ Available targets:

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0 |
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1.2 |

Expand Down
2 changes: 1 addition & 1 deletion docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0 |
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1.2 |

Expand Down
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.0.0"
required_version = ">= 1.2.0"

required_providers {
aws = {
Expand Down
9 changes: 8 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
enabled = module.this.enabled

eks_cluster_oidc_issuer = replace(var.eks_cluster_oidc_issuer_url, "https://", "")
eks_cluster_oidc_issuer = local.enabled ? replace(var.eks_cluster_oidc_issuer_url, "https://", "") : ""

aws_account_number = local.enabled ? coalesce(var.aws_account_number, data.aws_caller_identity.current[0].account_id) : ""

Expand Down Expand Up @@ -95,6 +95,13 @@ data "aws_iam_policy_document" "service_account_assume_role" {
variable = format("%s:aud", local.eks_cluster_oidc_issuer)
}
}

lifecycle {
precondition {
condition = length(local.eks_cluster_oidc_issuer) > 0
error_message = "The eks_cluster_oidc_issuer_url value must have a value."
}
}
}

resource "aws_iam_policy" "service_account" {
Expand Down
5 changes: 0 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ variable "aws_iam_policy_document" {
variable "eks_cluster_oidc_issuer_url" {
type = string
description = "OIDC issuer URL for the EKS cluster (initial \"https://\" may be omitted)"

validation {
condition = length(var.eks_cluster_oidc_issuer_url) > 0
error_message = "The eks_cluster_oidc_issuer_url value must have a value."
}
}

variable "permissions_boundary" {
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.0.0"
required_version = ">= 1.2.0"

required_providers {
aws = {
Expand Down

0 comments on commit 5d8145a

Please sign in to comment.