Skip to content

Commit 01e7765

Browse files
Merge pull request #300 from SamphireReeve/Update_Readme
Update to README
2 parents f55620a + f60c3b9 commit 01e7765

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ Run `sls deploy`, the defined Stepfunctions are deployed.
10671067

10681068
## IAM Role
10691069

1070-
The IAM roles required to run Statemachine are automatically generated. It is also possible to specify ARN directly.
1070+
The IAM roles required to run Statemachine are automatically generated for each state machine in the `serverless.yml`, with the IAM role name of `StatesExecutionPolicy-<environment>`. These roles are tailored to the services that the state machine integrates with, for example with Lambda the `InvokeFunction` is applied. You can also specify a custom ARN directly to the step functions lambda.
10711071

10721072
Here's an example:
10731073

@@ -1079,7 +1079,9 @@ stepFunctions:
10791079
definition:
10801080
```
10811081

1082-
It is also possible to use the [CloudFormation intrinsic functions](https://docs.aws.amazon.com/en_en/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html) to reference resources from elsewhere:
1082+
It is also possible to use the [CloudFormation intrinsic functions](https://docs.aws.amazon.com/en_en/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html) to reference resources from elsewhere. This allows for an IAM role to be created, and applied to the state machines all within the serverless file.
1083+
1084+
The below example shows the policy needed if your step function needs the ability to send a message to an sqs queue. To apply the role either the RoleName can be used as a reference in the state machine, or the role ARN can be used like in the example above. It is important to note that if you want to store your state machine role at a certain path, this must be specified on the `Path` property on the new role.
10831085

10841086
```yml
10851087
stepFunctions:
@@ -1095,7 +1097,31 @@ resources:
10951097
StateMachineRole:
10961098
Type: AWS::IAM::Role
10971099
Properties:
1098-
...
1100+
RoleName: RoleName
1101+
Path: /path_of_state_machine_roles/
1102+
AssumeRolePolicyDocument:
1103+
Statement:
1104+
- Effect: Allow
1105+
Principal:
1106+
Service:
1107+
- states.amazonaws.com
1108+
Action:
1109+
- sts:AssumeRole
1110+
Policies:
1111+
- PolicyName: statePolicy
1112+
PolicyDocument:
1113+
Version: version
1114+
Statement:
1115+
- Effect: Allow
1116+
Action:
1117+
- lambda:InvokeFunction
1118+
Resource:
1119+
- arn:aws:lambda:lambdaName
1120+
- Effect: Allow
1121+
Action:
1122+
- sqs:SendMessage
1123+
Resource:
1124+
- arn:aws:sqs::xxxxxxxx:queueName
10991125
```
11001126

11011127
The short form of the intrinsic functions (i.e. `!Sub`, `!Ref`) is not supported at the moment.

0 commit comments

Comments
 (0)