Skip to content

feat: #122 Add SAM stack name parameter #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ The configuration is saved to `lldebugger.config.ts`.
--config-env <evironment> SAM environment
--sam-config-file <file> SAM configuration file
--sam-template-file <file> SAM template file
--sam-stack-name <name> SAM stack name;
--profile <profile> AWS profile to use
--region <region> AWS region to use
--role <role> AWS role to use
Expand Down
1 change: 1 addition & 0 deletions src/configuration/getConfigFromCliArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export async function getConfigFromCliArgs(
program.option('--config-env <evironment>', 'SAM environment');
program.option('--sam-config-file <file>', 'SAM configuration file');
program.option('--sam-template-file <file>', 'SAM template file');
program.option('--sam-stack-name <name>', 'SAM stack name');
program.option('--profile <profile>', 'AWS profile to use');
program.option('--region <region>', 'AWS region to use');
program.option('--role <role>', 'AWS role to use');
Expand Down
11 changes: 11 additions & 0 deletions src/configuration/getConfigFromWizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ export async function getConfigFromWizard({
default:
configFromCliArgs.samTemplateFile ?? currentConfig?.samTemplateFile,
},
{
type: 'input',
name: 'samStackName',
message:
'Would you like to enter SAM stack name and not use the one from config?',
default:
configFromCliArgs.samStackName ?? currentConfig?.samStackName,
},
]);

answers = { ...answers, ...samAnswers };
Expand Down Expand Up @@ -421,6 +429,8 @@ export default {
samConfigFile: "${config.samConfigFile}",
// SAM framework template file
samTemplateFile: "${config.samTemplateFile}",
// SAM framework stack name
samStackName: "${config.samStackName}",
// Observable mode
observable: ${config.observable},
// Observable mode interval
Expand Down Expand Up @@ -468,6 +478,7 @@ function getConfigFromAnswers(answers: any): LldConfigCliArgs {
configEnv: answers.configEnv,
samConfigFile: answers.samConfigFile,
samTemplateFile: answers.samTemplateFile,
samStackName: answers.samStackName,
observable: answers.observable,
interval:
answers.interval !== undefined
Expand Down
8 changes: 7 additions & 1 deletion src/frameworks/samFramework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ export class SamFramework implements IFramework {
samConfig = yaml.parse(samConfigContent);
}

const stackName = samConfig[environment]?.global?.parameters?.stack_name;
let stackName: string | undefined;

if (config.samStackName) {
stackName = config.samStackName;
} else {
stackName = samConfig[environment]?.global?.parameters?.stack_name;
}

if (!stackName) {
throw new Error(`Stack name not found in ${samConfigFile}`);
Expand Down
5 changes: 5 additions & 0 deletions src/types/lldConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export type LldConfigBase = {
*/
samTemplateFile?: string;

/**
* SAM framework cli parameter stack-name
*/
samStackName?: string;

/**
* Resources discovery function
*/
Expand Down
Loading