Closed TonySherman closed 10 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
?
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.
@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)
Happy to work on the cloudformation to start! I don't have Terraform experience but I can try to take a look as well.
Thank you again for your help, @TonySherman 🙏
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.