Skip to content

Commit

Permalink
adding readme section on sam accelerate example
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Nov 14, 2022
1 parent 0f30536 commit 4cf258e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,17 @@ When working on large CloudFormation templates it's likely that you will only be

### SAM integration
If your project has a samconfig.toml file, a copy of that will be created with the stack_name parameter chnaged to `sub--<stackname>-<random adjective>-<random noun>`. This is so you can deploy your substack alongside the original stack without interfering with what's already deployed. A prerequisite is that you don't implicitly name any resources as there will be naming clash

### Working with SAM Accelerate example (bash example)
In your `~/.bashrc` file, add the following:
```
partial-sync() {
cfn-subset extract --template $1 --sub-template samsync.partial.template
source <(grep = samconfig.sub.toml)
sam sync --watch --template-file samsync.partial.template --stack-name $stack_name --parameter-overrides $parameter_overrides
sam delete --stack-name $stack_name
}
```

The `cfn-subset` command will prompt you to select the resources you want in the sub-stack. Once selected, an ephemeral stack will be spun up using `sam sync`. Now, iterate over your code changes, and when happy, hit ctrl+c/command+. The ephemeral stack will be deleted and you're ready to use `cfn-subset merge` to merge your subset back into the main template.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mhlabs/cfn-subset",
"version": "0.0.9",
"version": "0.0.10",
"description": "Extract a subset of a CloudFormation template for quick deploys when integration testing parallel stacks",
"main": "index.js",
"scripts": {
Expand All @@ -13,7 +13,7 @@
},
"publishConfig": {
"access": "public"
},
},
"repository": {
"type": "git",
"url": "git+https://github.com/mhlabs/cfn-subset.git"
Expand Down
4 changes: 2 additions & 2 deletions src/commands/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ program
.command("extract")
.alias("e")
.option("-t, --template <filename>", "Template file name", "template.yaml")
.option("-st, --subTemplate <filename>", "Template file name", "template.sub.yaml")
.option("-st, --sub-template <filename>", "Template file name", "template.sub.yaml")
.action(async (cmd) => {
template = templateHelper.getTemplate(cmd.template);
const resource = await inquirer.prompt({
Expand Down Expand Up @@ -86,7 +86,7 @@ program
'stack_name = "sub--$1-' +
sentencer.make("{{ adjective }}-{{ noun }}") +
'"'
);
).replace(/\s=\s/g, "=");;
fs.writeFileSync("samconfig.sub.toml", tomlFile);
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ program
.command("merge")
.alias("m")
.option("-t, --template <filename>", "Template file name", "template.yaml")
.option("-st, --subTemplate <filename>", "Template file name", "template.sub.yaml")
.option("-st, --sub-template <filename>", "Template file name", "template.sub.yaml")
.action(async (cmd) => {
if (cmd.template.includes(".sub.")) {
cmd.template = cmd.template.replace(".sub.", ".");
Expand Down

0 comments on commit 4cf258e

Please sign in to comment.