I'm very unclear on how references or variables work with CloudFormation.
Currently my iAmRole in my serverless.yml looks like:
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
# Restrict our IAM role permissions to
# the specific table for the stage
Resource:
- "Fn::GetAtt": [ ReportsTable, Arn ]
ReportsTable is a table created in another file that looks like:
Resources:
ReportsTable:
Type: AWS::DynamoDB::Table
Properties:
...
LocalSecondaryIndexes:
- IndexName: typeId-accessToken-index
KeySchema:
- AttributeName: typeId
KeyType: HASH
...etc
I understand that the second value in the Fn::GetAtt array is referencing an attributename, but I don't understand where Arn is coming from. It seems like a variable but it's not defined anywhere.
Ultimately I need to add another Effect, Action, Resource block referencing the local secondary index I have created, but I'm lost as to where to start.
Edit: Looks like Arn comes from dynamoDB tables return values (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html)
Edit2: Okay so I now have the format arn:aws:dynamodb:region:account-id:table/table-name/index/*
from the permissions reference docs, testing now.