Skip to content

Commit 3af359f

Browse files
Merge pull request #223 from TonySherman/feat/statemachine-name-prefix
add ability to customize the prefix of the statemachine name
2 parents 4a28bfc + 5ecb337 commit 3af359f

5 files changed

Lines changed: 16 additions & 1 deletion

File tree

README-INPUT-OUTPUT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ The CloudFormation template accepts the following parameters:
3939
* **logGroupRetentionInDays** (number, default=7): the number of days to retain log events in the Lambda log groups. Before this parameter existed, log events were retained indefinitely
4040
* **securityGroupIds** (list of SecurityGroup IDs): List of Security Groups to use in every Lambda function's VPC Configuration (optional); please note that your VPC should be configured to allow public internet access (via NAT Gateway) or include VPC Endpoints to the Lambda service
4141
* **subnetIds** (list of Subnet IDs): List of Subnets to use in every Lambda function's VPC Configuration (optional); please note that your VPC should be configured to allow public internet access (via NAT Gateway) or include VPC Endpoints to the Lambda service
42+
* **stateMachineNamePrefix** (string, default=`powerTuningStateMachine`): Allows you to customize the name of the state machine. Maximum 43 characters, only alphanumeric (plus `-` and `_`). The last portion of the `AWS::StackId` will be appended to this value, so the full name will look like `powerTuningStateMachine-89549da0-a4f9-11ee-844d-12a2895ed91f`. Note: `StateMachineName` has a maximum of 80 characters and 36+1 from the `StackId` are appended, allowing 43 for a custom prefix.
4243

4344

4445
Please note that the total execution time should stay below 300 seconds (5 min), which is the default timeout. You can easily estimate the total execution timeout based on the average duration of your functions. For example, if your function's average execution time is 5 seconds and you haven't enabled `parallelInvocation`, you should set `totalExecutionTimeout` to at least `num * 5`: 50 seconds if `num=10`, 500 seconds if `num=100`, and so on. If you have enabled `parallelInvocation`, usually you don't need to tune the value of `totalExecutionTimeout` unless your average execution time is above 5 min. If you have a sleep between invocations set, you should include that in your timeout calculations.

README-SAR.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ The CloudFormation template accepts the following parameters:
7272
* **logGroupRetentionInDays** (number, default=7): the number of days to retain log events in the Lambda log groups. Before this parameter existed, log events were retained indefinitely
7373
* **securityGroupIds** (list of SecurityGroup IDs): List of Security Groups to use in every Lambda function's VPC Configuration (optional); please note that your VPC should be configured to allow public internet access (via NAT Gateway) or include VPC Endpoints to the Lambda service
7474
* **subnetIds** (list of Subnet IDs): List of Subnets to use in every Lambda function's VPC Configuration (optional); please note that your VPC should be configured to allow public internet access (via NAT Gateway) or include VPC Endpoints to the Lambda service
75+
* **stateMachineNamePrefix** (string, default=`powerTuningStateMachine`): Allows you to customize the name of the state machine. Maximum 43 characters, only alphanumeric (plus `-` and `_`). The last portion of the `AWS::StackId` will be appended to this value, so the full name will look like `powerTuningStateMachine-89549da0-a4f9-11ee-844d-12a2895ed91f`. Note: `StateMachineName` has a maximum of 80 characters and 36+1 from the `StackId` are appended, allowing 43 for a custom prefix.
7576

7677
Please note that the total execution time should stay below 300 seconds (5 min), which is the default timeout. You can easily estimate the total execution timeout based on the average duration of your functions. For example, if your function's average execution time is 5 seconds and you haven't enabled `parallelInvocation`, you should set `totalExecutionTimeout` to at least `num * 5`: 50 seconds if `num=10`, 500 seconds if `num=100`, and so on. If you have enabled `parallelInvocation`, usually you don't need to tune the value of `totalExecutionTimeout` unless your average execution time is above 5 min.
7778

scripts/deploy-sar-app.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Resources:
1818
# permissionsBoundary: ARN
1919
# payloadS3Bucket: my-bucket
2020
# payloadS3Key: my-key.json
21+
# stateMachineNamePrefix: my-custom-name-prefix
2122

2223
Outputs:
2324
PowerTuningStateMachine:

template.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ Parameters:
6262
Type: CommaDelimitedList
6363
Default: ''
6464
Description: List of Subnets to use in every Lambda function's VPC Configuration (optional).
65+
stateMachineNamePrefix:
66+
Type: String
67+
MaxLength: 43
68+
AllowedPattern: ^[a-zA-Z0-9\-_]*$
69+
ConstraintDescription: Prefix must conform to StateMachineName requirements.
70+
Default: 'powerTuningStateMachine'
71+
Description: Prefix to the name of the StateMachine. The StackId will be appended to this value (optional).
6572

6673
Conditions:
6774
UsePermissionsBoundary: !Not [!Equals [!Ref permissionsBoundary, '']]
@@ -262,6 +269,11 @@ Resources:
262269
powerTuningStateMachine:
263270
Type: AWS::StepFunctions::StateMachine
264271
Properties:
272+
StateMachineName:
273+
Fn::Join:
274+
- '-'
275+
- - !Ref stateMachineNamePrefix
276+
- !Select [2, !Split ['/', !Ref AWS::StackId]]
265277
RoleArn: !GetAtt statemachineRole.Arn
266278
DefinitionString:
267279
!Sub

terraform/module/state_machine.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
resource "aws_sfn_state_machine" "state-machine" {
3-
name = var.lambda_function_prefix
3+
name_prefix = var.lambda_function_prefix
44
role_arn = aws_iam_role.sfn_role.arn
55

66
definition = local.state_machine

0 commit comments

Comments
 (0)