Skip to content

Commit

Permalink
fixed aws template
Browse files Browse the repository at this point in the history
  • Loading branch information
Facundo De Lorenzo committed May 20, 2024
1 parent dcaf0b7 commit d4540af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
1 change: 0 additions & 1 deletion packages/api/src/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ exports.get = async (
ExclusiveStartKey: lastKey,
});
const response = await docClient.send(command);
console.log('response: ', response);

const products: ProductDTO[] = response.Items.map((x) => ({
id: x.productId,
Expand Down
28 changes: 16 additions & 12 deletions packages/api/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@ Description: Api
Globals:
Function:
Timeout: 10
Role: !GetAtt ExecutionRole.Arn

Resources:
ExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument: Json
RoleName: APIExecutionRole
Policies:
- DynamoDBCrudPolicy:
TableName: wakeup-challenge-orders
- DynamoDBCrudPolicy:
TableName: wakeup-challenge-products

MyApi:
Type: AWS::Serverless::Api
Properties:
Expand All @@ -25,6 +35,7 @@ Resources:
Handler: products.get
Runtime: nodejs20.x
MemorySize: 128
Role: !GetAtt ExecutionRole.Arn
Events:
Event:
Type: Api
Expand All @@ -40,6 +51,7 @@ Resources:
Handler: orders.create
Runtime: nodejs20.x
MemorySize: 128
Role: !GetAtt ExecutionRole.Arn
Events:
Event:
Type: Api
Expand All @@ -55,6 +67,7 @@ Resources:
Handler: orders.finish
Runtime: nodejs20.x
MemorySize: 128
Role: !GetAtt ExecutionRole.Arn
Events:
Event:
Type: Api
Expand All @@ -70,6 +83,7 @@ Resources:
Handler: orders.get
Runtime: nodejs20.x
MemorySize: 128
Role: !GetAtt ExecutionRole.Arn
Events:
Event:
Type: Api
Expand All @@ -85,21 +99,11 @@ Resources:
Handler: restaurants.get
Runtime: nodejs20.x
MemorySize: 128
Role: !GetAtt ExecutionRole.Arn
Events:
Event:
Type: Api
Properties:
Method: GET
Path: /restaurants
RestApiId: !Ref MyApi

ExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument: Json
RoleName: APIExecutionRole
Policies:
- DynamoDBCrudPolicy:
TableName: wakeup-challenge-orders
- DynamoDBCrudPolicy:
TableName: wakeup-challenge-products

0 comments on commit d4540af

Please sign in to comment.