Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws-eks): Inconsistent fargateProfileName Handling Causes Deletion Failure When PhysicalResourceId Exceeds 100 Characters #32909

Open
1 task
AviorSchreiber opened this issue Jan 14, 2025 · 1 comment
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service bug This issue is a bug. effort/medium Medium work item – several days of effort p1

Comments

@AviorSchreiber
Copy link
Contributor

AviorSchreiber commented Jan 14, 2025

Describe the bug

When creating an EKS FargateProfile using the AWS CDK,
the onCreate event correctly handles long fargateProfileName values by generating a valid name using the generateProfileName() function if none is provided.

However, in the onDelete event, this logic is missing.
The deletion process directly uses the physicalResourceId as the fargateProfileName without validating its length.
If the physicalResourceId exceeds 100 characters, it results in an error during deletion
because

  1. AWS EKS enforces a maximum length of 100 characters for fargateProfileName.
  2. The fargate profile with that name does not exist.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

The onDelete event should handle long physicalResourceId values consistently with the creation process.
and use the same function to generate the fargateProfileName for the delete action

Current Behavior

Stack deleting failed due to that reason

Received response status [FAILED] from custom resource. Message returned: The Fargate profile name parameter should not be greater than 100 characters. Logs:

Reproduction Steps

  1. Deploy a CDK stack that creates a FargateProfile without specifying fargateProfileName, allowing it to auto-generate one.
  2. Ensure the generated PhysicalResourceId exceeds 100 characters.
  3. Attempt to delete the stack.
  4. Observe the deletion failure due to the long fargateProfileName.

Possible Solution

Adding the same logic to the onDelete event.

protected async onDelete() {
    if (!this.physicalResourceId) {
      throw new Error('Cannot delete a profile without a physical id');
    }

    const fargateProfileName = this.event.ResourceProperties.Config.fargateProfileName ?? this.generateProfileName();
    const deleteFargateProfile: EKS.DeleteFargateProfileCommandInput = {
      clusterName: this.event.ResourceProperties.Config.clusterName,
      fargateProfileName: fargateProfileName,
    };
    this.log({ deleteFargateProfile });
    const deleteFargateProfileResponse = await this.eks.deleteFargateProfile(deleteFargateProfile);
    this.log({ deleteFargateProfileResponse });

    return;
  }

Additional Information/Context

No response

CDK CLI Version

2.175.1

Framework Version

No response

Node.js Version

22

OS

MacOS

Language

TypeScript

Language Version

No response

Other information

No response

@AviorSchreiber AviorSchreiber added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 14, 2025
@github-actions github-actions bot added @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service potential-regression Marking this issue as a potential regression to be checked by team member and removed potential-regression Marking this issue as a potential regression to be checked by team member labels Jan 14, 2025
@AviorSchreiber AviorSchreiber changed the title [aws-eks]: Inconsistent fargateProfileName Handling Causes Deletion Failure When PhysicalResourceId Exceeds 100 Characters (aws-eks): Inconsistent fargateProfileName Handling Causes Deletion Failure When PhysicalResourceId Exceeds 100 Characters Jan 14, 2025
@pahud pahud self-assigned this Jan 14, 2025
@pahud
Copy link
Contributor

pahud commented Jan 14, 2025

const fargateProfileName = this.event.ResourceProperties.Config.fargateProfileName ?? this.generateProfileName();

Yes, thanks for pointing this out. We should get it fixed. Making it a p1 and we welcome PRs as well.

@pahud pahud added the p1 label Jan 14, 2025
@pahud pahud removed their assignment Jan 14, 2025
@pahud pahud added effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service bug This issue is a bug. effort/medium Medium work item – several days of effort p1
Projects
None yet
Development

No branches or pull requests

2 participants