Skip to content

Commit 0f611dd

Browse files
committed
chore: update README.md
Adds an example of how to reference a DynamoDB table name exported from an external CloudFormation stack.
1 parent 8a1b732 commit 0f611dd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Specify your state machine definition using Amazon States Language in a `definit
8383

8484
Alternatively, you can also provide the raw ARN, or SQS queue URL, or DynamoDB table name as a string. If you need to construct the ARN by hand, then we recommend to use the [serverless-pseudo-parameters](https://www.npmjs.com/package/serverless-pseudo-parameters) plugin together to make your life easier.
8585

86+
In addition, if you want to reference a DynamoDB table managed by an external CloudFormation Stack, as long as that table name is exported as an output from that stack, it can be referenced by importing it using `Fn::ImportValue`. See the `ddbtablestepfunc` Step Function definition below for an example.
87+
8688
```yml
8789
functions:
8890
hello:
@@ -138,6 +140,27 @@ stepFunctions:
138140
Resource:
139141
Fn::GetAtt: [hello, Arn]
140142
End: true
143+
ddbtablestepfunc:
144+
definition:
145+
Comment: Demonstrates how to reference a DynamoDB Table Name exported from an external CloudFormation Stack
146+
StartAt: ImportDDBTableName
147+
States:
148+
ImportDDBTableName:
149+
Type: Task
150+
Resource: "arn:aws:states:::dynamodb:updateItem"
151+
Parameters:
152+
TableName:
153+
Fn::ImportValue: MyExternalStack:ToDoTable:Name # imports a table name from an external stack
154+
Key:
155+
id:
156+
S.$: "$.todoId"
157+
UpdateExpression: "SET #status = :updatedStatus"
158+
ExpressionAttributeNames:
159+
"#status": status
160+
ExpressionAttributeValues:
161+
":updatedStatus":
162+
S: DONE
163+
End: true
141164
dependsOn:
142165
- DynamoDBTable
143166
- KinesisStream

0 commit comments

Comments
 (0)