Skip to content

Commit 5854f2a

Browse files
committed
design: sam deploy also packages built artifacts (#1521)
1 parent c7fffc4 commit 5854f2a

File tree

1 file changed

+178
-0
lines changed

1 file changed

+178
-0
lines changed

designs/package_during_deploy.md

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
Package during `sam deploy`
2+
====================================
3+
4+
5+
What is the problem?
6+
--------------------
7+
8+
Today while using `sam deploy` the specified `--template-file` or `--template` is expected to have packaged artifacts references in the given template file.
9+
10+
This is driven by the following workflow.
11+
12+
`sam build` -> `sam package --s3-bucket ... --s3-prefix ... --output-template-file packaged.yaml`.
13+
14+
This workflow builds the requisite code and packages those built artifacts into an s3 bucket, optionally under a given s3 prefix.
15+
16+
If a developer can optionally cut through this process without requiring an explicit `package` command, but rather have `sam deploy` package to a given s3 bucket, it cuts the number of steps before needing to deploy and test in the cloud.
17+
18+
This also reduces friction in the `author` and `test` loop.
19+
20+
Ideal end state.
21+
22+
`sam build` -> `sam deploy ..... --s3-bucket ....`
23+
24+
25+
What will be changed?
26+
---------------------
27+
28+
Addition of extra parameters that are currently supported by `sam package` over to `sam deploy` with all of them being optional.
29+
30+
Additional parameters that need to be on `sam deploy` that are not on `sam package`.
31+
32+
* `--metadata`
33+
* `--use-json`
34+
35+
Parameters that dont need to be added.
36+
37+
* `--output-template-file`
38+
* An explicit `output-template-file` is created on the fly during packaging in the deploy phase.
39+
40+
If the expectation is to package and deploy in one command, One can now do.
41+
42+
`sam deploy --stack-name sam-package-on-deploy --capabilities CAPABILITY_IAM --s3-bucket sam-package-bucket`
43+
44+
There is no explicit need to pass in a `--template-file` or `--template` parameter, if one is not passed in it to defaults to trying to find the template.yaml that was generated by `sam build` which is located at `.aws-sam/build/template.yaml`
45+
46+
The old method of deploying pre-packaged artifacts will continue to work as before.
47+
48+
* `sam deploy --template-file packaged.yaml --stack-name sam-package-on-deploy --capabilities CAPABILITY_IAM`
49+
50+
If a deployment is done without running `sam build` prior we still go ahead and deploy with the given `template.yaml` in the project root. This might still result in a successful deploy, but not a deploy with the correct build artifacts.
51+
52+
53+
Future of `sam package`?
54+
---------------------
55+
56+
* `sam package` will continue to exist in the state it is today and will continue to be improved upon separately.
57+
58+
Success criteria for the change
59+
-------------------------------
60+
61+
User do not require to run `sam package` as part of their author test loop, except for CI/CD purposes, where `sam package` can be run and the packaged template file can be passed to cloudformation deploy actions.
62+
63+
64+
Out-of-Scope
65+
------------
66+
67+
The s3 bucket where the packaged artifacts go is not abstracted in this design. In the future, the s3 bucket could be specified via a configuration file.
68+
69+
This is currently in design in : https://github.com/awslabs/aws-sam-cli/pull/1503
70+
71+
User Experience Walkthrough
72+
---------------------------
73+
74+
`sam build` -> `sam deploy`
75+
76+
`sam build` -> `sam package` -> `sam deploy`
77+
78+
Provide identical experiences in terms of a deploying the same stack, with exactly same artifacts.
79+
80+
81+
Implementation
82+
==============
83+
84+
CLI Changes
85+
-----------
86+
87+
* Add new arguments `--metadata`, `--use-json` and modify existing `--template-file` or `--template` to look for a default `template.yaml` that exists under `.aws-sam/build/`
88+
89+
### Breaking Change
90+
91+
* Not a breaking change , but there are optional behavorial changes that a user can subscribe into by supplying a non-packaged template file and an s3 bucket.
92+
93+
Design
94+
------
95+
96+
* Changes to Deploy command's click options
97+
* Attempt to package on every deploy if an appropriate s3 bucket is specified and deploy using the output template file during package.
98+
* If a pre-packaged template is specified, an attempt to package does not change the template and the same template is used for deploy.
99+
* The parameters that share the same name across package and deploy are collapsed together. eg: `--kms-key-id` , if a kms-key-id is specified that same key is used across both packaging and deploy purposes.
100+
101+
`.samrc` Changes
102+
----------------
103+
104+
None
105+
106+
Security
107+
--------
108+
109+
**What new dependencies (libraries/cli) does this change require?**
110+
N/A
111+
112+
**What other Docker container images are you using?**
113+
N/A
114+
115+
**Are you creating a new HTTP endpoint? If so explain how it will be
116+
created & used**
117+
N/A
118+
119+
**Are you connecting to a remote API? If so explain how is this
120+
connection secured**
121+
N/A
122+
123+
**Are you reading/writing to a temporary folder? If so, what is this
124+
used for and when do you clean up?**
125+
126+
Possibly reading from a configuration file in the future.
127+
128+
**How do you validate new .samrc configuration?**
129+
130+
N/A
131+
132+
What is your Testing Plan (QA)?
133+
===============================
134+
135+
Goal
136+
----
137+
* Regression tests on previous functionality of `sam deploy`
138+
* Integration tests on automatic packaging on `sam deploy`
139+
140+
Pre-requesites
141+
--------------
142+
N/A
143+
144+
Test Scenarios/Cases
145+
--------------------
146+
* Re-deploy a stack that was deployed with a packaged template before hand using the new sam deploy menthod.
147+
148+
`sam deploy --template-file packaged.yaml --stack-name sam-stack --capabilities CAPABILITY_IAM`
149+
150+
`sam deploy --stack-name sam-stack --capabilities CAPABILITY_IAM`
151+
152+
The new stack should not have any changes.
153+
154+
155+
Expected Results
156+
----------------
157+
158+
* Regresssion and Integration tests pass.
159+
160+
Documentation Changes
161+
=====================
162+
* Required nature of `--template-file`, `--template` parameter has a series of defaults that are looked at during `sam deploy` similair to `sam package`.
163+
* If `--template-file` or `--template` points to a non-packaged template-file, `--s3-bucket` becomes required to be able to effectively package and deploy in one command using `sam deploy`.
164+
165+
Open Issues
166+
============
167+
168+
Task Breakdown
169+
==============
170+
171+
- \[x\] Send a Pull Request with this design document
172+
- \[ \] Build the command line interface
173+
- \[ \] Build the underlying library
174+
- \[ \] Unit tests
175+
- \[ \] Functional Tests
176+
- \[ \] Integration tests
177+
- \[ \] Run all tests on Windows
178+
- \[ \] Update documentation

0 commit comments

Comments
 (0)