alexcasalboni / aws-lambda-power-tuning

AWS Lambda Power Tuning is an open-source tool that can help you visualize and fine-tune the memory/power configuration of Lambda functions. It runs in your own AWS account - powered by AWS Step Functions - and it supports three optimization strategies: cost, speed, and balanced.
Apache License 2.0
5.49k stars 379 forks source link

Feature Request: Allow naming of statemachine #220

Closed TonySherman closed 10 months ago

TonySherman commented 11 months ago

It would be nice if we could name the Statemachine when deploying from SAR. It looks like AWS::StepFunctions::StateMachine allows StateMachineName. So it seems like it could be a parameter with a default value.

Happy to make the contribution if you'd like.

alexcasalboni commented 11 months ago

Hi @TonySherman 👋 thanks for reaching out!

The main reason why there is no hard-coded (default) StateMachineName is that it's not uncommon to deploy the same stack multiple times in the same Account/Region, and name conflicts would cause the CloudFormation deployment to fail. That's why I'd normally recommend avoiding hard-coded resource names, unless strictly necessary.

I do like that CloudFormation will automatically use the logical resource name ("powerTuningStateMachine") and append a random ID to avoid collisions.

We could implement some kind of customizable name (or prefix), and then append the AWS::StackId or AWS::StackName to make it unique. StackIds are 36 characters andStateMachineName can be up to 80 characters, so we can afford 44 characters for a custom prefix :)

Besides the technical details, did you have a specific use case in mind for a static/fixed StateMachineName?

TonySherman commented 11 months ago

Thanks for the explanation! My specific use case is just to conform with some internal policies. We actually use a prefix for all resources so a prefix would fit my needs perfectly!

If you would prefer not to make the change with a custom prefix, I understand.

I deployed using python cdk aws_sam.CfnApplication and I tried using the add_override method to customize the template but that didn't seem to work. Could have been an error on how I was using it but I suspect it might not be possible with SAR apps since they get converted to "TemplateURL" in CloudFormation.

alexcasalboni commented 11 months ago

@TonySherman thanks for sharing more about the use case :)

I think a custom prefix is worth including, as it doesn't add much complexity. The only potential issue would be changing the current expected behaviour in case some developers depend on it for some kind of automation. So I'd suggest we keep using "powerTuningStateMachine" as the default prefix, and we'll make sure the mention this in the changelog.

Would you be comfortable with giving this a try with a PR, at least for the CloudFormation part? (Terraform will need some love too)

TonySherman commented 11 months ago

Happy to work on the cloudformation to start! I don't have Terraform experience but I can try to take a look as well.

alexcasalboni commented 10 months ago

Thank you again for your help, @TonySherman 🙏