cdk-ec2-key-pair
cdk-ec2-key-pair copied to clipboard
feat: remove the function name
Named functions are more trouble than they're worth. The description provides the same value, without the annoyance.
Fixes: #53
The alternative is to use something like https://www.npmjs.com/package/multi-convention-namer with the maxLength
option.
@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
So please merge :)
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.
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 you can override it using the resourcePrefix
property, but it's still problematic.
@cameroncf I also removed the name from the role, which as you point out has the same problem. And standardized the imports.
bump
cc/ @udondan
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 😸
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