Skip to content

Commit 1853dca

Browse files
authored
Environment specific template support (#14)
* Environment specific template support * cleanup * yaml * docs
1 parent 61ffaac commit 1853dca

File tree

10 files changed

+421
-372
lines changed

10 files changed

+421
-372
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ typings/
5656

5757
# dotenv environment variables file
5858
.env
59+
60+
# project
61+
test

README.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
### Features
66

77
* Generate a minimal yet flexible SAM template for you to get started.
8-
* Simplify SAM's complex packaging & deploy steps/flags into a simple `deploy` command.
8+
* Simplify SAM's complex packaging & deploy steps & flags into a simple `deploy` command.
99
* Provide a best practice for deploying multiple environments.
1010

1111
![sammie](https://user-images.githubusercontent.com/411908/35882654-ea43468a-0b52-11e8-9a0c-d5d721e56a51.gif)
1212

1313
### Prerequisites
1414

15-
[AWS CLI](https://aws.amazon.com/cli/)
15+
[AWS CLI](https://aws.amazon.com/cli/) - sammie uses this for all AWS operations under the hood.
1616

1717
### Quickstart
1818

@@ -22,11 +22,11 @@ sammie init my-app
2222
sammie deploy
2323
```
2424

25-
This will initialize a basic SAM template, deploy it to a development environment, and direct you to your app served over https!
25+
This will generate a basic serverless application, deploy it to a development environment, and direct you to your app served over https!
2626

2727
### Commands
2828

29-
#### init - Generates a SAM template & lambda function
29+
#### init - Generates a serverless application including a SAM template & lambda function
3030

3131
`sammie init <name>`
3232
_Options:_
@@ -40,20 +40,34 @@ _Options:_
4040
`-e, --environment`: An environment name to deploy. Defaults to "development".
4141
`-p, --parameters`: A list of parameters to override in your template.
4242

43-
### Bootstrapping existing SAM projects
43+
### Environments
4444

45-
If you already have a SAM template, you can use `sammie deploy` for a simplified deployment.
46-
Make sure to add the following parameters to your template so sammie knows where to deploy:
45+
It's a best practice to create completely separate stacks for each of your application's environments, rather than a single stack with multiple lambda qualifiers, API Gateway stages, and permissions. This makes your application more portable and reduces the blast radius of taking down your live application during the development cycle.
46+
47+
To support this, sammie will deploy separate stacks for you based on your environment option.
48+
E.g. your stack name is "my-app":
49+
`sammie deploy` will deploy stack "my-app-development"
50+
`sammie deploy --environment production` will deploy stack "my-app-production"
51+
52+
#### Environment variables & properties
53+
54+
To add environemnt specific variables & properties, you can create separate sam templates named with the environemnt suffix.
55+
E.g. `sam-production.json` containing the following, will get merged with your base template `sam.json` upon `sammie deploy --environment production`
4756

4857
```json
49-
"Parameters": {
50-
"stackName": {
51-
"Type": "String",
52-
"Default": "<your-projects-stack-name>"
53-
},
54-
"bucketName": {
55-
"Type": "String",
56-
"Default": "<your-s3-bucket-for-code-uploads>"
58+
{
59+
"Resources": {
60+
"TestFunction": {
61+
"Properties": {
62+
"MemorySize": 1280,
63+
"Environment": {
64+
"Variables": {
65+
"ENV_VAR1": "var1-prod",
66+
"ENV_VAR2": "var2-prod"
67+
}
68+
}
69+
}
70+
}
5771
}
5872
}
5973
```

0 commit comments

Comments
 (0)