Skip to content

Add stack option for CLI start command #12675

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 5 commits into from
May 30, 2025
Merged

Conversation

gtsiolis
Copy link
Member

@gtsiolis gtsiolis commented May 28, 2025

Motivation

Following up from a relevant discussion, this is an attempt to add a CLI option for selecting a stack (image, emulator).

  1. The command to start LocalStack for Snowflake is quite verbose by using the IMAGE_NAME environment variable.
  2. Selecting a different image version also required the IMAGE_NAME variable, see relevant docs.
IMAGE_NAME=localstack/snowflake:latest localstack start
IMAGE_NAME=localstack/localstack-pro:4.1 localstack start

See also relevant discussion for more context.

Changes

This will add --stack and -s as a shorthand for selecting the image and optional a version.

localstack start                      # default, starts localstack for aws (localstack image)
localstack start --stack snowflake    # starts localstack for snowflake (snowflake image)
localstack start -s snowflake         # starts localstack for snowflake (snowflake image)
localstack start -s snowflake:0.3     # starts localstack for snowflake (snowflake image, 0.3 version)
localstack start -s localstack:4.4    # starts localstack for aws (localstack image, 4.4 version)

Heads-up: We are experimenting with the Stacks terminology also in the Console, see https://github.com/localstack/localstack-web/pull/1787.

@gtsiolis gtsiolis added the area: cli LocalStack CLI label May 28, 2025
Copy link

github-actions bot commented May 28, 2025

Test Results - Preflight, Unit

21 579 tests  ±0   19 927 ✅ ±0   6m 12s ⏱️ +4s
     1 suites ±0    1 652 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit dd2c462. ± Comparison against base commit 1833df1.

♻️ This comment has been updated with latest results.

@click.option(
"--stack",
"-s",
type=str,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use click.Choice here to enforce only snowflake can be used here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice one! Today I learned. Added in 714e323.

Copy link
Member Author

@gtsiolis gtsiolis May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted the choice in 931f2af to make it more flexible to add versions next to the image.

localstack start -s snowflake
localstack start -s snowflake:0.3

Happy to go back to restricting this only to image name as a first iteration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could subtype click.Choice as well and that logic in there instead of the start command. But no need to optimize without knowing what we'll do with the CLI in the future yet :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For passing specific versions next to the image, we can also introduce another cli option that would look like:

localstack start -s snowflake -v 0.3.0

This was also mentioned in #12529 briefly to get ideas around it. Wdyt?

Copy link
Member Author

@gtsiolis gtsiolis May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @eruditmorina! I would still keep the {image}:{version} approach for simplicity, having a Docker-familiar syntax, not creating any confusion on what version (-v) is referring to (CLI, stack, or start command). Let me know if I'm missing something!

{image}:{version} {image} -v {version}
Frame 48097105 Frame 48097106

Copy link

github-actions bot commented May 28, 2025

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 12s ⏱️ +3s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit dd2c462. ± Comparison against base commit 1833df1.

♻️ This comment has been updated with latest results.

@gtsiolis gtsiolis added the semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases label May 28, 2025
Copy link

github-actions bot commented May 28, 2025

Test Results - Alternative Providers

597 tests   420 ✅  15m 5s ⏱️
  4 suites  177 💤
  4 files      0 ❌

Results for commit dd2c462.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented May 28, 2025

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 43m 33s ⏱️ +5s
4 469 tests ±0  4 080 ✅ ±0  389 💤 ±0  0 ❌ ±0 
4 471 runs  ±0  4 080 ✅ ±0  391 💤 ±0  0 ❌ ±0 

Results for commit dd2c462. ± Comparison against base commit 1833df1.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented May 28, 2025

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 21m 55s ⏱️
4 824 tests 4 282 ✅ 542 💤 0 ❌
4 830 runs  4 282 ✅ 548 💤 0 ❌

Results for commit dd2c462.

♻️ This comment has been updated with latest results.

@gtsiolis gtsiolis self-assigned this May 28, 2025
@gtsiolis gtsiolis changed the title Add stack CLI option Add stack option for CLI start command May 28, 2025
@gtsiolis gtsiolis modified the milestones: 4.5, Playground May 29, 2025
@gtsiolis
Copy link
Member Author

Added opportunistically 4.5 as the milestone, but open to moving to 4.6 or Playground if this can't make it in time.

Thanks @anisaoshafi for the nudge to add a milestone! 😃

@gtsiolis gtsiolis marked this pull request as ready for review May 29, 2025 08:17
@gtsiolis gtsiolis requested review from thrau and alexrashed as code owners May 29, 2025 08:17
@gtsiolis gtsiolis requested a review from silv-io May 29, 2025 08:18
@gtsiolis
Copy link
Member Author

Most of this was inspired by #12529, #12674, and the linked discussion in the PR description!

Hat tip to @silv-io, @eruditmorina, @hovaesco, and @SimonWallner for sparking the discussion. ❤️


Looking for a code review since both code owners are OOO! Happy to make any changes or close the PR.

Copy link
Member

@silv-io silv-io left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just have some minor suggestions

@click.option(
"--stack",
"-s",
type=str,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could subtype click.Choice as well and that logic in there instead of the start command. But no need to optimize without knowing what we'll do with the CLI in the future yet :)

@gtsiolis gtsiolis force-pushed the gt/add-stack-cli-option branch from 3e2221b to dd2c462 Compare May 30, 2025 12:56
@gtsiolis gtsiolis merged commit 1a9469e into master May 30, 2025
61 checks passed
@gtsiolis gtsiolis deleted the gt/add-stack-cli-option branch May 30, 2025 14:03
@gtsiolis
Copy link
Member Author

Rebased to run the pipeline with the latest changes from master. All checks passed. ✔️

Merged! :shipit:

Thanks @silv-io and @eruditmorina for taking a look, inspiring this, and closing the draft PRs[1][2]!

Added you both as co-authors. 🏂 🏂 🏂

Thanks also everyone involved in the early discussions of adding a CLI command or option for running snowflake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cli LocalStack CLI semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants