Created
August 10, 2016 17:05
-
-
Save mccraveiro/c8364c32dfeeaf9096486e407c4867e7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
resources: | |
Resources: | |
IamRoleLambda: | |
Type: 'AWS::IAM::Role' | |
Properties: | |
AssumeRolePolicyDocument: | |
Version: '2012-10-17' | |
Statement: | |
- | |
Effect: Allow | |
Principal: | |
Service: [lambda.amazonaws.com] | |
Action: | |
- 'sts:AssumeRole' | |
Path: / | |
IamPolicyLambda: | |
Type: 'AWS::IAM::Policy' | |
Properties: | |
PolicyName: '${stage}-${service}-lambda' | |
PolicyDocument: | |
Version: '2012-10-17' | |
Statement: | |
- | |
Effect: Allow | |
Action: | |
- 'logs:CreateLogGroup' | |
- 'logs:CreateLogStream' | |
- 'logs:PutLogEvents' | |
Resource: 'arn:aws:logs:${region}:*:*' | |
- | |
Effect: Allow | |
Action: | |
- '*' | |
Resource: 'arn:aws:dynamodb:*' | |
Roles: | |
- | |
Ref: IamRoleLambda | |
IamPolicyLambdaInvocationDynamoDB: | |
Type: 'AWS::IAM::Policy' | |
Properties: | |
PolicyName: '${stage}-${service}-dynamo-stream-lambda' | |
PolicyDocument: | |
Version: '2012-10-17' | |
Statement: | |
- | |
Effect: Allow | |
Action: | |
- 'lambda:InvokeFunction' | |
Resource: '*' | |
- | |
Effect: Allow | |
Action: | |
- 'dynamodb:DescribeStream' | |
- 'dynamodb:GetRecords' | |
- 'dynamodb:GetShardIterator' | |
- 'dynamodb:ListStreams' | |
- 'dynamodb:PutItem' | |
- 'dynamodb:GetItem' | |
Resource: 'arn:aws:dynamodb:*' | |
Roles: | |
- | |
Ref: IamRoleLambda | |
dynamoDBTable: | |
Type: AWS::DynamoDB::Table | |
Properties: | |
TableName: '${service}-tableName-${stage}' | |
AttributeDefinitions: | |
- | |
AttributeName: Id | |
AttributeType: S | |
KeySchema: | |
- | |
AttributeName: Id | |
KeyType: HASH | |
ProvisionedThroughput: | |
ReadCapacityUnits: 5 | |
WriteCapacityUnits: 5 | |
StreamSpecification: | |
StreamViewType: NEW_IMAGE | |
mapping: | |
Type: AWS::Lambda::EventSourceMapping | |
Properties: | |
BatchSize: 10 | |
EventSourceArn: | |
Fn::GetAtt: | |
- dynamoDBTable | |
- StreamArn | |
FunctionName: '<lambda function ARN>' | |
StartingPosition: TRIM_HORIZON |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment