Skip to content

Instantly share code, notes, and snippets.

@selvesandev
Created May 24, 2022 13:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selvesandev/80bf8aa01cba993b472a4e4cc1fb5bac to your computer and use it in GitHub Desktop.
Save selvesandev/80bf8aa01cba993b472a4e4cc1fb5bac to your computer and use it in GitHub Desktop.
Deploy your serverless framework aws lambda function from aws code build
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12
commands:
- npm install -g serverless
- npm install
- printenv
pre_build:
commands:
# checkout the version that are installed for the build process.
- npm --version
- sls --version
- aws --version
# - npm run migrate
- sls deploy --stage stage # "--stage stage" is optional
build:
commands:
- echo Build started on `date`
- ls
post_build:
commands:
- echo Build completed on `date`
cache:
paths:
- node_modules
@selvesandev
Copy link
Author

You might also have to give few policies (permissions) to the code build role so that the serverless can run the cloud formation and s3 uploads.

       "s3:CreateBucket",
        "s3:DeleteBucket",
        "s3:DeleteBucketPolicy",
        "s3:DeleteObject",
        "s3:DeleteObjectVersion",
        "s3:Get*",
        "s3:List*",
        "s3:PutBucketNotification",
        "s3:PutBucketPolicy",
        "s3:PutBucketTagging",
        "s3:PutBucketWebsite",
        "s3:PutEncryptionConfiguration",
        "s3:PutObject"
        "cloudformation:CancelUpdateStack",
        "cloudformation:ContinueUpdateRollback",
        "cloudformation:CreateChangeSet",
        "cloudformation:CreateStack",
        "cloudformation:CreateUploadBucket",
        "cloudformation:DeleteStack",
        "cloudformation:Describe*",
        "cloudformation:EstimateTemplateCost",
        "cloudformation:ExecuteChangeSet",
        "cloudformation:Get*",
        "cloudformation:List*",
        "cloudformation:UpdateStack",
        "cloudformation:UpdateTerminationProtection"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment