cdk-ec2-key-pair icon indicating copy to clipboard operation
cdk-ec2-key-pair copied to clipboard

feat: remove the function name

Open ahammond opened this issue 2 years ago • 11 comments

Named functions are more trouble than they're worth. The description provides the same value, without the annoyance.

Fixes: #53

ahammond avatar Apr 22 '22 05:04 ahammond

The alternative is to use something like https://www.npmjs.com/package/multi-convention-namer with the maxLength option.

ahammond avatar Apr 22 '22 05:04 ahammond

@udondan This is a good first step, but I think this ressource should follow the CDK standard of autogenerating all names and leaving it up to L2 ressource where possible

LukvonStrom avatar May 04 '22 13:05 LukvonStrom

So please merge :)

LukvonStrom avatar May 04 '22 13:05 LukvonStrom

I'm running into a function length problem as well and came here to make this exact PR. Glad someone else beat me to it. Removing the function name would be fantastic and unblock my work.

cameroncf avatar May 06 '22 18:05 cameroncf

Looks like the role name and managed policy name have similar "explicitly named resources" problems. The error checking on length that reports "Cloudformation limits names to 63 characters." could also be removed.

My use case is using a domain name as part of the key name, which can get quite long.

cameroncf avatar May 06 '22 19:05 cameroncf

@cameroncf you can override it using the resourcePrefix property, but it's still problematic.

ahammond avatar May 06 '22 19:05 ahammond

@cameroncf I also removed the name from the role, which as you point out has the same problem. And standardized the imports.

ahammond avatar May 06 '22 19:05 ahammond

bump

cameroncf avatar May 13 '22 19:05 cameroncf

cc/ @udondan

LukvonStrom avatar Aug 15 '22 10:08 LukvonStrom

Please see the related ticket #53. CFN now has native support for creating Key pairs. Most probably the only thing I'm going to do with this project is to archive it 😸

udondan avatar Aug 15 '22 10:08 udondan

Personally I do not have a problem with this. Though AWS does. You cannot change the Lambda function name for existing custom resources. CFN will fail with:

Modifying service token is not allowed.

By removing the function name we would force all users to delete and re-create their KeyPairs.

I see only one option how we can change this: A new contruct property, e.g. lambdaName.

  • If undefined: We use the name as currently implemented. So this is backwards compatible and not messing with existing KeyPairs
  • If false: No names for the function, role and policy will be set
  • If typeof String: User can set a custom name

udondan avatar Sep 18 '23 06:09 udondan