You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BREAKING - Create build command and drop --noDeploy option #2660
Some use cases, especially with CI/CD demand the packages to be used for a deployment to be created beforehand. After #2659 is merged we can create a separate build command with its own lifecycle that can then be included by the deployment command.
serverless build without any options will package all artifacts for deployment to Lambda and put them in the .serverless folder
serverless build -f hello will only package the specified function and put it in the .serverless folder.
Both package commands will overwrite the artifact configuration of each function to point to the newly created artifacts so other commands like deploy or deploy function can pick them up and release the artifact. This only works if build runs as a dependency of those other commands.
Future extensions:
``serverless build --output (or -o)` will package all artifacts and put the artifacts into the specified
@mthenw FYI I'm only renaming the milestones once it comes up, basically because before the milestone is planned I don't necessarily know if a breaking change will be happening in it. So in this case it will be renamed and will then be at least 2.0
I think we need to be really clear on the goals and implementation of this issue.
It will affect how #2659 is implemented.
The main goal is to support pipeline style deployments. As part of pipelines we need to be able to run a series of steps lint / unit test -> package/build -> integration test -> deploy. The build artefact needs to be consistent between testing and deployment.
This will also allow us to create temporary environments comprised of multiple services for testing purposes. i.e. I need to run integration testing on service-a which relies on service-b. To do this, I deploy service-a and a pre-packaged version of service-b to a test environment before running my tests.
It seems to me that there are two distinct options for the implementation of build.
Option 1 - code + serverless.yml
This technique will require the user to modify serverless.yml. The user will need to use the package.artifact setting plus options to conditionally set it. For example
package:
artifact: ${opt:userArtifactOption}
The first step in the pipeline would execute build. The command will zip the code and serverless.yml into a package. This could then be stored as an artefact in a build system.
The second step in pipeline would extract the code + serverless.yml and use sls deploy --userArtifactOption /path/to/code.zip. This would create the CF templates on deploy and deploy them to AWS.
Advantages
Uses existing features so it might be easier to implement
More configuration options - (this is also a disadvantage)
Disadvantages
Requires user config in serverless.yml
CF templates are built on every deploy
CF templates could change between deployments - a bug or version change could cause this
The package is not independently deployable i.e. you couldn't just upload the CF + code to AWS yourself. (This isn't much of a disadvantage though)
Option 2 - code + CF templates
The first step in the pipeline will execute build. The command will zip the contents of .serverless. This will include code + create & update CF stacks.
The second step in the pipeline would retrieve the artefact and use sls deploy --artifact /path/to/artifact.zip. This would skip the package step, extract the artifacts to .serverless and deploy the existing code + CF templates.
Advantages
Better user experience - no config in serverless.yml
CF templates are built only once
CF templates won't change between deployments
The package not independently deployable
Disadvantages
serverless.yml isn't available to sls which will will require some core changes
Support for deploying existing artifacts will have to be added to deploy
Plugins that deploy outside of CF wouldn't work i.e. external sns. I personally think they should use custom CF resources and not act outside of CF.
Summary
Clearly I'm in favour of option 2. I think it's a better user experience and more consistent. But it's probably a harder change to make. Happy to hear different thoughts on this.
@johncmckim, for me, the option 2 would be much better. I'm currently working on a project where I deploy zip + CloudFormation files (using --noDeploy) with Jenkins. Those files are then used later when the whole stack is deployed to AWS with Ansible.
Not sure if can go with either of your options @johncmckim; Option 2 sounds closer to what I imagined, but I'm confused about your proposal details:
Why does deploy require an --artifact argument? Wouldn't it just deploy the (pre-generated) artifacts in .serverless/?
Why would serverless.yml not be available to sls? I don't think sls should be doing anything without a serverless.yml, in general...
I definitely don't think this change should require changes/additions to serverless.yml - it should be as transparent as possible to users who don't care about the build step i.e. they can continue to build and deploy in a single command if they want (which is something I often want to do). Only users who care about the build step need to know/worry about it. There may be advanced options, but there should be enough sensible defaults that no changes are required.
In my mind I had imagined additional commands to facilitate this:
sls build ... # builds template and function packages in .serverless/
sls deploy ... # builds AND deploys the service, just like now
sls push ... # ONLY deploys the service, based on existing artifacts in .serverless/ (and fails if none present)
To be clear, I'm not in love with the name push but I'm just putting it out there to differentiate it from the other commands. This would be backwards compatible - you could continue to support deploy --noDeploy to avoid a version bump.
I was including an --artifact argument so deploy could just take a package. It would be responsible for extracting it and putting it into .serverless if that's what was required.
I think you're right about .serverless.yml having to be there. My thinking behind that was because the built package needs to remain unmodified by deploy. This means the package, function or resources config in serverless.yml are not used when deploying a built package. Though upon reflection, it might still need to check the provider settings.
I like the UX of build & push (or another name) and having deploy coordinate those two commands. If #2659 is implemented deploy would just have build as a before command and push as an after command.
changed the title [-]Create build command and drop --noDeploy option[/-][+]BREAKING - Create build command and drop --noDeploy option[/+]on Feb 8, 2017
It is worthwhile noting that alias support as outlined above has been implemented by @HyperBrain as standalone plugin. This addresses most of my initial concerns and I'd like to encourage everybody on this thread to help beta testing: #2411 (comment)
I believe there is still a need for a --build vs --deploy command line option though.
Activity
mthenw commentedon Nov 8, 2016
Dropping
--noDeployis a breaking change so I'm not sure if we can release that in 1.*.flomotlik commentedon Nov 8, 2016
@mthenw FYI I'm only renaming the milestones once it comes up, basically because before the milestone is planned I don't necessarily know if a breaking change will be happening in it. So in this case it will be renamed and will then be at least 2.0
johncmckim commentedon Nov 9, 2016
I think we need to be really clear on the goals and implementation of this issue.
It will affect how #2659 is implemented.
The main goal is to support pipeline style deployments. As part of pipelines we need to be able to run a series of steps
lint / unit test->package/build->integration test->deploy. The build artefact needs to be consistent between testing and deployment.This will also allow us to create temporary environments comprised of multiple services for testing purposes. i.e. I need to run integration testing on
service-awhich relies onservice-b. To do this, I deployservice-aand a pre-packaged version ofservice-bto a test environment before running my tests.It seems to me that there are two distinct options for the implementation of
build.Option 1 - code + serverless.yml
This technique will require the user to modify
serverless.yml. The user will need to use thepackage.artifactsetting plus options to conditionally set it. For exampleThe first step in the pipeline would execute
build. The command will zip the code andserverless.ymlinto a package. This could then be stored as an artefact in a build system.The second step in pipeline would extract the code +
serverless.ymland usesls deploy --userArtifactOption /path/to/code.zip. This would create the CF templates on deploy and deploy them to AWS.Advantages
Disadvantages
serverless.ymlOption 2 - code + CF templates
The first step in the pipeline will execute
build. The command will zip the contents of.serverless. This will include code + create & update CF stacks.The second step in the pipeline would retrieve the artefact and use
sls deploy --artifact /path/to/artifact.zip. This would skip the package step, extract the artifacts to.serverlessand deploy the existing code + CF templates.Advantages
serverless.ymlDisadvantages
serverless.ymlisn't available toslswhich will will require some core changesdeploySummary
Clearly I'm in favour of option 2. I think it's a better user experience and more consistent. But it's probably a harder change to make. Happy to hear different thoughts on this.
laardee commentedon Nov 9, 2016
@johncmckim, for me, the option 2 would be much better. I'm currently working on a project where I deploy zip + CloudFormation files (using
--noDeploy) with Jenkins. Those files are then used later when the whole stack is deployed to AWS with Ansible.rowanu commentedon Nov 10, 2016
Not sure if can go with either of your options @johncmckim; Option 2 sounds closer to what I imagined, but I'm confused about your proposal details:
--artifactargument? Wouldn't it just deploy the (pre-generated) artifacts in.serverless/?serverless.ymlnot be available tosls? I don't thinkslsshould be doing anything without aserverless.yml, in general...I definitely don't think this change should require changes/additions to
serverless.yml- it should be as transparent as possible to users who don't care about the build step i.e. they can continue to build and deploy in a single command if they want (which is something I often want to do). Only users who care about thebuildstep need to know/worry about it. There may be advanced options, but there should be enough sensible defaults that no changes are required.In my mind I had imagined additional commands to facilitate this:
To be clear, I'm not in love with the name
pushbut I'm just putting it out there to differentiate it from the other commands. This would be backwards compatible - you could continue to supportdeploy --noDeployto avoid a version bump.johncmckim commentedon Nov 11, 2016
@rowanu that's a pretty interesting solution.
I was including an
--artifactargument so deploy could just take a package. It would be responsible for extracting it and putting it into.serverlessif that's what was required.I think you're right about
.serverless.ymlhaving to be there. My thinking behind that was because the built package needs to remain unmodified by deploy. This means thepackage,functionorresourcesconfig inserverless.ymlare not used when deploying a built package. Though upon reflection, it might still need to check theprovidersettings.I like the UX of
build&push(or another name) and havingdeploycoordinate those two commands. If #2659 is implementeddeploywould just havebuildas a before command andpushas an after command.27 remaining items
[-]Create build command and drop --noDeploy option[/-][+]BREAKING - Create build command and drop --noDeploy option[/+]arabold commentedon Mar 2, 2017
It is worthwhile noting that alias support as outlined above has been implemented by @HyperBrain as standalone plugin. This addresses most of my initial concerns and I'd like to encourage everybody on this thread to help beta testing: #2411 (comment)
I believe there is still a need for a
--buildvs--deploycommand line option though.