Skip to content
Open
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
20 changes: 20 additions & 0 deletions cmd/sst/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ var CmdDeploy = &cli.Command{
"sst deploy --target MyComponent",
"```",
"",
"Alternatively, exclude a specific component from the deploy.",
"",
"```bash frame=\"none\"",
"sst deploy --exclude MyComponent",
"```",
"",
"All the resources are deployed as concurrently as possible, based on their dependencies.",
"For resources like your container images, sites, and functions; it first builds them and then deploys the generated assets.",
"",
Expand Down Expand Up @@ -89,6 +95,14 @@ var CmdDeploy = &cli.Command{
Long: "Only run it for the given component.",
},
},
{
Name: "exclude",
Type: "string",
Description: cli.Description{
Short: "Exclude a component",
Long: "Exclude the specified component from the operation.",
},
},
{
Name: "continue",
Type: "bool",
Expand Down Expand Up @@ -126,6 +140,11 @@ var CmdDeploy = &cli.Command{
target = strings.Split(c.String("target"), ",")
}

exclude := []string{}
if c.String("exclude") != "" {
exclude = strings.Split(c.String("exclude"), ",")
}

var wg errgroup.Group
defer wg.Wait()
out := make(chan interface{})
Expand All @@ -152,6 +171,7 @@ var CmdDeploy = &cli.Command{
err = p.Run(c.Context, &project.StackInput{
Command: "deploy",
Target: target,
Exclude: exclude,
Dev: c.Bool("dev"),
ServerPort: s.Port,
Verbose: c.Bool("verbose"),
Expand Down
20 changes: 20 additions & 0 deletions cmd/sst/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ var CmdDiff = &cli.Command{
"sst diff --target MyComponent",
"```",
"",
"Alternatively, exclude a specific component from the diff.",
"",
"```bash frame=\"none\"",
"sst diff --exclude MyComponent",
"```",
"",
"By default, this compares to the last deploy of the given stage as it would be",
"deployed using `sst deploy`. But if you are working in dev mode using `sst dev`,",
"you can use the `--dev` flag.",
Expand All @@ -58,6 +64,14 @@ var CmdDiff = &cli.Command{
Long: "Only run it for the given component.",
},
},
{
Name: "exclude",
Type: "string",
Description: cli.Description{
Short: "Exclude a component",
Long: "Exclude the specified component from the operation.",
},
},
{
Name: "dev",
Type: "bool",
Expand Down Expand Up @@ -89,6 +103,11 @@ var CmdDiff = &cli.Command{
target = strings.Split(c.String("target"), ",")
}

exclude := []string{}
if c.String("exclude") != "" {
exclude = strings.Split(c.String("exclude"), ",")
}

var wg errgroup.Group
defer wg.Wait()
outputs := []*apitype.ResOutputsEvent{}
Expand Down Expand Up @@ -121,6 +140,7 @@ var CmdDiff = &cli.Command{
ServerPort: s.Port,
Dev: c.Bool("dev"),
Target: target,
Exclude: exclude,
Verbose: c.Bool("verbose"),
})
if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions cmd/sst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,12 @@ var root = &cli.Command{
"sst refresh --target MyComponent",
"```",
"",
"Alternatively, exclude a specific component from the refresh.",
"",
"```bash frame=\"none\"",
"sst refresh --exclude MyComponent",
"```",
"",
"This is useful for cases where you want to ensure that your local state is in sync with your cloud provider. [Learn more about how state works](/docs/providers/#how-state-works).",
}, "\n"),
},
Expand All @@ -980,6 +986,14 @@ var root = &cli.Command{
Long: "Only run it for the given component.",
},
},
{
Name: "exclude",
Type: "string",
Description: cli.Description{
Short: "Exclude a component",
Long: "Exclude the specified component from the operation.",
},
},
},
Run: CmdRefresh,
},
Expand Down
6 changes: 6 additions & 0 deletions cmd/sst/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func CmdRefresh(c *cli.Cli) error {
target = strings.Split(c.String("target"), ",")
}

exclude := []string{}
if c.String("exclude") != "" {
exclude = strings.Split(c.String("exclude"), ",")
}

var wg errgroup.Group
defer wg.Wait()
ui := ui.New(c.Context)
Expand All @@ -47,6 +52,7 @@ func CmdRefresh(c *cli.Cli) error {
err = p.Run(c.Context, &project.StackInput{
Command: "refresh",
Target: target,
Exclude: exclude,
ServerPort: s.Port,
Verbose: c.Bool("verbose"),
})
Expand Down
15 changes: 15 additions & 0 deletions pkg/project/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,21 @@ func (p *Project) RunNext(ctx context.Context, input *StackInput) error {
}
}

if input.Exclude != nil {
for _, item := range input.Exclude {
index := slices.IndexFunc(completed.Resources, func(res apitype.ResourceV3) bool {
return res.URN.Name() == item
})
if index == -1 {
return util.NewReadableError(nil, fmt.Sprintf("Exclude target not found: %v", item))
}
args = append(args, "--exclude", string(completed.Resources[index].URN))
}
if len(input.Exclude) > 0 {
args = append(args, "--exclude-dependents")
}
}

cmd := process.Command(pulumiPath, args...)
process.Detach(cmd)
cmd.Env = env
Expand Down
1 change: 1 addition & 0 deletions pkg/project/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type BuildFailedEvent struct {
type StackInput struct {
Command string
Target []string
Exclude []string
ServerPort int
Dev bool
Verbose bool
Expand Down