On this page
serverless - Manages a Serverless Framework project
New in version 2.3.
Synopsis
- Provides support for managing Serverless Framework (https://serverless.com/) project deployments and stacks.
Requirements (on host that executes module)
- serverless
- yaml
Options
parameter | required | default | choices | comments |
---|---|---|---|---|
deploy |
no | True |
Whether or not to deploy artifacts after building them. When this option is `false` all the functions will be built, but no stack update will be run to send them out. This is mostly useful for generating artifacts to be stored/deployed elsewhere.
|
|
functions |
no |
A list of specific functions to deploy. If this is not provided, all functions in the service will be deployed.
|
||
region |
no | us-east-1 |
AWS region to deploy the service to
|
|
serverless_bin_path
(added in 2.4)
|
no |
The path of a serverless framework binary relative to the 'service_path' eg. node_module/.bin/serverless
|
||
service_path |
yes |
The path to the root of the Serverless Service to be operated on.
|
||
stage |
no |
The name of the serverless framework project stage to deploy to. This uses the serverless framework default "dev".
|
||
state |
no | present |
|
Goal state of given stage/project
|
Examples
# Basic deploy of a service
- serverless:
service_path: '{{ project_dir }}'
state: present
# Deploy specific functions
- serverless:
service_path: '{{ project_dir }}'
functions:
- my_func_one
- my_func_two
# deploy a project, then pull its resource list back into Ansible
- serverless:
stage: dev
region: us-east-1
service_path: '{{ project_dir }}'
register: sls
# The cloudformation stack is always named the same as the full service, so the
# cloudformation_facts module can get a full list of the stack resources, as
# well as stack events and outputs
- cloudformation_facts:
region: us-east-1
stack_name: '{{ sls.service_name }}'
stack_resources: true
# Deploy a project but use a locally installed serverless binary instead of the global serverless binary
- serverless:
stage: dev
region: us-east-1
service_path: '{{ project_dir }}'
serverless_bin_path: node_modules/.bin/serverless
Return Values
Common return values are documented here Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
command |
Full `serverless` command run by this module, in case you want to re-run the command outside the module.
|
always | string | serverless deploy --stage production |
service_name |
Most
|
always | string | my-fancy-service-dev |
state |
Whether the stack for the serverless project is present/absent.
|
always | string |
Notes
Note
- Currently, the
serverless
command must be in the path of the node executing the task. In the future this may be a flag.
Status
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/serverless_module.html