From 4cf258edf9bd43585b8a0ad7e89d7b985c1fe48b Mon Sep 17 00:00:00 2001 From: ljacobsson Date: Mon, 14 Nov 2022 22:53:40 +0100 Subject: [PATCH] adding readme section on sam accelerate example --- README.md | 14 ++++++++++++++ package-lock.json | 4 ++-- package.json | 4 ++-- src/commands/extract.js | 4 ++-- src/commands/merge.js | 2 +- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b32f620..0806d83 100644 --- a/README.md +++ b/README.md @@ -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----`. 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. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 90f119f..b259c42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mhlabs/cfn-subset", - "version": "0.0.8", + "version": "0.0.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@mhlabs/cfn-subset", - "version": "0.0.8", + "version": "0.0.9", "license": "ISC", "dependencies": { "commander": "^7.1.0", diff --git a/package.json b/package.json index 919b0ba..b88dc85 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -13,7 +13,7 @@ }, "publishConfig": { "access": "public" - }, + }, "repository": { "type": "git", "url": "git+https://github.com/mhlabs/cfn-subset.git" diff --git a/src/commands/extract.js b/src/commands/extract.js index 8cf36f5..1017965 100644 --- a/src/commands/extract.js +++ b/src/commands/extract.js @@ -9,7 +9,7 @@ program .command("extract") .alias("e") .option("-t, --template ", "Template file name", "template.yaml") - .option("-st, --subTemplate ", "Template file name", "template.sub.yaml") + .option("-st, --sub-template ", "Template file name", "template.sub.yaml") .action(async (cmd) => { template = templateHelper.getTemplate(cmd.template); const resource = await inquirer.prompt({ @@ -86,7 +86,7 @@ program 'stack_name = "sub--$1-' + sentencer.make("{{ adjective }}-{{ noun }}") + '"' - ); + ).replace(/\s=\s/g, "=");; fs.writeFileSync("samconfig.sub.toml", tomlFile); } diff --git a/src/commands/merge.js b/src/commands/merge.js index 3f0c6fc..356632c 100644 --- a/src/commands/merge.js +++ b/src/commands/merge.js @@ -11,7 +11,7 @@ program .command("merge") .alias("m") .option("-t, --template ", "Template file name", "template.yaml") - .option("-st, --subTemplate ", "Template file name", "template.sub.yaml") + .option("-st, --sub-template ", "Template file name", "template.sub.yaml") .action(async (cmd) => { if (cmd.template.includes(".sub.")) { cmd.template = cmd.template.replace(".sub.", ".");