I need a component for creating a large number of CodeCommit users. CloudFormation doesn't support adding a public SSH key for an IAM user, so I have to create my own. CDK comes with AwsCustomResource, which does the heavy lifting of creating the Lambda that handles the required CloudFormation events. In other words, my code would be something like:
import { User } from 'aws-cdk-lib/aws-iam';
import { AwsCustomResource } from 'aws-cdk-lib/custom-resources';
import { Construct } from 'constructs';
export interface CodeCommitUserProps {
userName: string;
emailAddress: string;
sshPublicKey: string;
}
export class CodeCommitUser extends Construct {
constructor(scope: Construct, id: string, props: CodeCommitUserProps) {
super(scope, id);
const user = new User(this, 'codecommit-' + props.userName, {
userName: 'codecommit-' + props.userName,
path: '/git/users'
});
}
const custom = new AwsCustomResource(this, ... );
}
Now if I call new CodeCommitUser(...) a few hundred times, I would assume that there will be one CloudFormation event Lambda per user, even if all of them are identical. Is there a way to reuse the Lambdas created by AwsCustomResource if I need multiple copies of the custom resource?