Last active
November 26, 2020 00:01
-
-
Save Nxtra/1aebaabc1de4d15d9f5ba83b4a404393 to your computer and use it in GitHub Desktop.
Amplify lambda access dynamodb api resources policy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"AccessDynamoDBApiResourcesPolicy": { | |
"DependsOn": ["LambdaExecutionRole"], | |
"Type": "AWS::IAM::Policy", | |
"Properties": { | |
"PolicyName": "amplify-lambda-execution-policy", | |
"Roles": [ | |
{ | |
"Ref": "LambdaExecutionRole" | |
} | |
], | |
"PolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"dynamodb:BatchWriteItem", | |
"dynamodb:List*", | |
"dynamodb:Query", | |
"dynamodb:Delete*" | |
], | |
"Resource": [ | |
{ | |
"Fn::Sub": [ | |
"arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${tablename}", | |
{ | |
"tablename": { | |
"Fn::ImportValue": { | |
"Fn::Sub": "${apiGraphQLAPIIdOutput}:GetAtt:PostTable:Name" | |
} | |
} | |
} | |
] | |
}, | |
{ | |
"Fn::Sub": [ | |
"arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${tablename}", | |
{ | |
"tablename": { | |
"Fn::ImportValue": { | |
"Fn::Sub": "${apiGraphQLAPIIdOutput}:GetAtt:CommentTable:Name" | |
} | |
} | |
} | |
] | |
}, | |
{ | |
"Fn::Sub": [ | |
"arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${tablename}/index/*", | |
{ | |
"tablename": { | |
"Fn::ImportValue": { | |
"Fn::Sub": "${apiGraphQLAPIIdOutput}:GetAtt:CommentTable:Name" | |
} | |
} | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment