Skip to content

Commit

Permalink
Merge pull request #35874 from acwwat/d-aws_eks-fix_cluster_name_regex
Browse files Browse the repository at this point in the history
fix: Fix EKS cluster name regex
  • Loading branch information
ewbankkit authored Feb 20, 2024
2 parents ddb77e8 + 4030c06 commit 824ced2
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 10 deletions.
35 changes: 35 additions & 0 deletions .changelog/35874.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
```release-note:bug
resource/aws_eks_access_entry: Fix `cluster_name` plan-time validation, allowing single-character names
```

```release-note:bug
data-source/aws_eks_access_entry: Fix `cluster_name` plan-time validation, allowing single-character names
```

```release-note:bug
resource/aws_eks_access_policy_association: Fix `cluster_name` plan-time validation, allowing single-character names
```

```release-note:bug
resource/aws_eks_addon: Fix `cluster_name` plan-time validation, allowing single-character names
```

```release-note:bug
data-source/aws_eks_addon: Fix `cluster_name` plan-time validation, allowing single-character names
```

```release-note:bug
resource/aws_eks_cluster: Fix `name` plan-time validation, allowing single-character names
```

```release-note:bug
data-source/aws_eks_cluster: Fix `name` plan-time validation, allowing single-character names
```

```release-note:bug
resource/aws_eks_fargate_profile: Fix `cluster_name` plan-time validation, allowing single-character names
```

```release-note:bug
resource/aws_eks_node_group: Fix `cluster_name` plan-time validation, allowing single-character names
```
2 changes: 1 addition & 1 deletion internal/service/eks/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func validClusterName(v interface{}, k string) (ws []string, errors []error) {
}

// https://docs.aws.amazon.com/eks/latest/APIReference/API_CreateCluster.html#API_CreateCluster_RequestSyntax
pattern := `^[0-9A-Za-z][0-9A-Za-z_-]+$`
pattern := `^[0-9A-Za-z][0-9A-Za-z_-]*$`
if !regexache.MustCompile(pattern).MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q doesn't comply with restrictions (%q): %q",
Expand Down
4 changes: 4 additions & 0 deletions internal/service/eks/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func TestValidClusterName(t *testing.T) {
Value: "my-valid-eks-cluster_1_dev",
ErrCount: 0,
},
{
Value: "a",
ErrCount: 0,
},
{
Value: `_invalid`,
ErrCount: 1,
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/eks_access_entry.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ output "eks_access_entry_outputs" {

## Argument Reference

* `cluster_name` – (Required) Name of the EKS Cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (`^[0-9A-Za-z][A-Za-z0-9\-_]+$`).
* `cluster_name` – (Required) Name of the EKS Cluster.
* `principal_arn` – (Required) The IAM Principal ARN which requires Authentication access to the EKS cluster.

## Attribute Reference
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/eks_addon.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ output "eks_addon_outputs" {

* `addon_name` – (Required) Name of the EKS add-on. The name must match one of
the names returned by [list-addon](https://docs.aws.amazon.com/cli/latest/reference/eks/list-addons.html).
* `cluster_name` – (Required) Name of the EKS Cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (`^[0-9A-Za-z][A-Za-z0-9\-_]+$`).
* `cluster_name` – (Required) Name of the EKS Cluster.

## Attribute Reference

Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/eks_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ output "identity-oidc-issuer" {

## Argument Reference

* `name` - (Required) Name of the cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (`^[0-9A-Za-z][A-Za-z0-9\-_]+$`).
* `name` - (Required) Name of the cluster.

## Attribute Reference

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/eks_access_entry.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ resource "aws_eks_access_entry" "example" {

The following arguments are required:

* `cluster_name` – (Required) Name of the EKS Cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (`^[0-9A-Za-z][A-Za-z0-9\-_]+$`).
* `cluster_name` – (Required) Name of the EKS Cluster.
* `principal_arn` – (Required) The IAM Principal ARN which requires Authentication access to the EKS cluster.

The following arguments are optional:
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/eks_access_policy_association.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "aws_eks_access_policy_association" "example" {

The following arguments are required:

* `cluster_name` – (Required) Name of the EKS Cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (`^[0-9A-Za-z][A-Za-z0-9\-_]+$`).
* `cluster_name` – (Required) Name of the EKS Cluster.
* `policy_arn` – (Required) The ARN of the access policy that you're associating.
* `principal_arn` – (Required) The IAM Principal ARN which requires Authentication access to the EKS cluster.
* `access_scope` – (Required) The configuration block to determine the scope of the access. See [`access_scope` Block](#access_scope-block) below.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/eks_addon.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ The following arguments are required:

* `addon_name` – (Required) Name of the EKS add-on. The name must match one of
the names returned by [describe-addon-versions](https://docs.aws.amazon.com/cli/latest/reference/eks/describe-addon-versions.html).
* `cluster_name` – (Required) Name of the EKS Cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (`^[0-9A-Za-z][A-Za-z0-9\-_]+$`).
* `cluster_name` – (Required) Name of the EKS Cluster.

The following arguments are optional:

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/eks_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ After adding inline IAM Policies (e.g., [`aws_iam_role_policy` resource](/docs/p

The following arguments are required:

* `name` – (Required) Name of the cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (`^[0-9A-Za-z][A-Za-z0-9\-_]+$`).
* `name` – (Required) Name of the cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (`^[0-9A-Za-z][A-Za-z0-9\-_]*$`).
* `role_arn` - (Required) ARN of the IAM role that provides permissions for the Kubernetes control plane to make calls to AWS API operations on your behalf. Ensure the resource configuration includes explicit dependencies on the IAM Role permissions by adding [`depends_on`](https://www.terraform.io/docs/configuration/meta-arguments/depends_on.html) if using the [`aws_iam_role_policy` resource](/docs/providers/aws/r/iam_role_policy.html) or [`aws_iam_role_policy_attachment` resource](/docs/providers/aws/r/iam_role_policy_attachment.html), otherwise EKS cannot delete EKS managed EC2 infrastructure such as Security Groups on EKS Cluster deletion.
* `vpc_config` - (Required) Configuration block for the VPC associated with your cluster. Amazon EKS VPC resources have specific requirements to work properly with Kubernetes. For more information, see [Cluster VPC Considerations](https://docs.aws.amazon.com/eks/latest/userguide/network_reqs.html) and [Cluster Security Group Considerations](https://docs.aws.amazon.com/eks/latest/userguide/sec-group-reqs.html) in the Amazon EKS User Guide. Detailed below. Also contains attributes detailed in the Attributes section.

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/eks_fargate_profile.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ resource "aws_iam_role_policy_attachment" "example-AmazonEKSFargatePodExecutionR

The following arguments are required:

* `cluster_name` – (Required) Name of the EKS Cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (`^[0-9A-Za-z][A-Za-z0-9\-_]+$`).
* `cluster_name` – (Required) Name of the EKS Cluster.
* `fargate_profile_name` – (Required) Name of the EKS Fargate Profile.
* `pod_execution_role_arn` – (Required) Amazon Resource Name (ARN) of the IAM Role that provides permissions for the EKS Fargate Profile.
* `selector` - (Required) Configuration block(s) for selecting Kubernetes Pods to execute with this EKS Fargate Profile. Detailed below.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/eks_node_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ resource "aws_subnet" "example" {

The following arguments are required:

* `cluster_name` – (Required) Name of the EKS Cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (`^[0-9A-Za-z][A-Za-z0-9\-_]+$`).
* `cluster_name` – (Required) Name of the EKS Cluster.
* `node_role_arn` – (Required) Amazon Resource Name (ARN) of the IAM Role that provides permissions for the EKS Node Group.
* `scaling_config` - (Required) Configuration block with scaling settings. See [`scaling_config`](#scaling_config-configuration-block) below for details.
* `subnet_ids` – (Required) Identifiers of EC2 Subnets to associate with the EKS Node Group.
Expand Down

0 comments on commit 824ced2

Please sign in to comment.