I am using serverless framework, AWS CodeCommit, CodeBuild, and CodePipeline. When I push my code and CodeBuild starts to deploy it, I don't get any feedback or logs from serverless framework inside the CloudWatch log groups.
I am using the default service roles for CodeBuild and CodePipeline which are created by AWS when I first created a new PipeLine and CodeBuild. Both of those roles include polices for CloudWatch and create log groups as follows:
CodeBuild
"Statement": [
{
"Effect": "Allow",
"Resource": [
"arn:aws:logs:us-west-2:*****:log-group:/aws/codebuild/sis-notes-backend-codebuild",
"arn:aws:logs:us-west-2:*****:log-group:/aws/codebuild/sis-notes-backend-codebuild:*"
],
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
]
},
CodePipeline
"Action": [
"elasticbeanstalk:*",
"ec2:*",
"elasticloadbalancing:*",
"autoscaling:*",
"cloudwatch:*",
"s3:*",
"sns:*",
"cloudformation:*",
"rds:*",
"sqs:*",
"ecs:*"
],
"Resource": "*",
"Effect": "Allow"
},
And this is the output of CloudWatch log groups. As you can see that I've wrote rubbish in the deploy code in order to get an error or failed response back from Serverless, but I got nothing just empty lines.
buildspec.yml
version: 0.2
phases:
install:
commands:
- echo Installing Serverless
- npm install -g serverless
pre_build:
commands:
- echo Install source NPM dependencies
- npm install
build:
commands:
- echo Deployment started on `date`
- echo Deploying with the Serverless Framework
- sls deploy -v -s $ENV_NAMEss kklksadk
post_build:
commands:
- echo Deployment completed on `date`
serverless.yml
service: sls-notes-backend
frameworkVersion: '3'
provider:
name: aws
runtime: nodejs14.x
region: us-west-2
stage: prod
memorySize: 128
timeout: 4
endpointType: regional
environment:
NOTES_TABLE: ${self:service}-${opt:stage, self:provider.stage}
resources:
Resources:
NotesTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
Properties:
TableName: ${self:provider.environment.NOTES_TABLE}
AttributeDefinitions:
- AttributeName: user_id
AttributeType: S
- AttributeName: timestamp
AttributeType: N
- AttributeName: note_id
AttributeType: S
KeySchema:
- AttributeName: user_id
KeyType: HASH
- AttributeName: timestamp
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
GlobalSecondaryIndexes:
- IndexName: note_id_index
KeySchema:
- AttributeName: note_id
KeyType: HASH
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 2
WriteCapacityUnits: 2
sls deploy -v
will only output the version information and exit. It's a greedy match.
Change the -v
flag to --verbose
and this will work.
Example:
➜ js-library-test sls deploy -v
Running "serverless" from node_modules
Framework Core: 3.1.1 (local) 3.12.0v (global)
Plugin: 6.0.0
SDK: 4.3.1
➜ js-library-test