Open lifeisgift opened 5 years ago
The below file is the vanilla yaml template (template.yml) from the Module3 Seeder - with only the nodeJS versions changed. Everything else is as posted in the repository.
AWSTemplateFormatVersion: '2010-09-09'
Transform:
- 'AWS::Serverless-2016-10-31'
- 'AWS::CodeStar'
Description:
Creates a RESTful API using API Gateway, Lambda and DynamoDB for the Wild Rydes serverless devops workshop
Parameters:
ProjectId:
Type: String
Description: AWS CodeStar projectID used to associate new resources to team members
CodeDeployRole:
Type: String
Description: IAM role to allow AWS CodeDeploy to manage deployment of AWS Lambda functions
Stage:
Type: String
Description: The name for a project pipeline stage, such as Staging or Prod, for which resources are provisioned and deployed.
Default: ''
Resources:
LambdaExecutionRole:
Description: Creating service role in IAM for AWS Lambda
Type: AWS::IAM::Role
Properties:
RoleName: !Sub 'CodeStar-${ProjectId}-Execution${Stage}'
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: [lambda.amazonaws.com]
Action: sts:AssumeRole
Path: /
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
- arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess
- arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess
PermissionsBoundary: !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:policy/CodeStar_${ProjectId}_PermissionsBoundary'
Table:
Type: 'AWS::Serverless::SimpleTable'
Properties:
PrimaryKey:
Name: name
Type: String
ReadFunction:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: 'uni-api-read'
Runtime: nodejs8.10
CodeUri: app
Handler: read.lambda_handler
Description: View Unicorn by name
Timeout: 10
Tracing: Active
Events:
GET:
Type: Api
Properties:
Path: /unicorns/{name}
Method: get
Environment:
Variables:
TABLE_NAME: !Ref Table
Role: !GetAtt LambdaExecutionRole.Arn
ListFunction:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: 'uni-api-list'
Runtime: nodejs8.10
CodeUri: app
Handler: list.lambda_handler
Description: List Unicorns
Timeout: 10
Tracing: Active
Events:
GET:
Type: Api
Properties:
Path: /unicorns
Method: get
Environment:
Variables:
TABLE_NAME: !Ref Table
Role: !GetAtt LambdaExecutionRole.Arn
UpdateFunction:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: 'uni-api-update'
Runtime: nodejs8.10
CodeUri: app
Handler: update.lambda_handler
Description: Update Unicorn
Timeout: 10
Tracing: Active
Events:
PUT:
Type: Api
Properties:
Path: /unicorns/{name}
Method: put
Environment:
Variables:
TABLE_NAME: !Ref Table
Role: !GetAtt LambdaExecutionRole.Arn
DeleteFunction:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: 'uni-api-delete'
Runtime: nodejs8.10
CodeUri: app
Handler: delete.lambda_handler
Description: Delete Unicorn
Timeout: 10
Tracing: Active
Events:
DELETE:
Type: Api
Properties:
Path: /unicorns/{name}
Method: delete
Environment:
Variables:
TABLE_NAME: !Ref Table
Role: !GetAtt LambdaExecutionRole.Arn
In the following link, the NodeJS version in yaml is still 6.10, which will report not supported. https://github.com/aws-samples/aws-serverless-workshops/tree/master/Auth/2_ServerlessAPI