Skip to content

Commit

Permalink
Merge pull request #157 from foomo/fix/pulumi-azure
Browse files Browse the repository at this point in the history
fix(pulumi/azure): add azure subscription to pulumi commands
  • Loading branch information
franklinkim authored Nov 12, 2024
2 parents 1d37860 + 9b9a9c6 commit 5834ea1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pulumi/pulumi/azure/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,36 @@ func NewCommand(l log.Logger, az *az.AZ, op *onepassword.OnePassword, cache cach
fs.Default().String("debug", "", "Show full logs")
fs.Default().String("tags", "", "Quoted string with space-separated tags")
fs.Default().String("vebose", "", "Increase logging verbosity")
fs.Internal().String("group-args", "", "Additional group create args")
fs.Internal().String("storage-args", "", "Additional storaage create args")
return nil
},
Execute: func(ctx context.Context, r *readline.Readline) error {
be, err := inst.cfg.Backend(r.Args().At(0))
if err != nil {
return err
}
fsi := r.FlagSets().Internal()

groupArgs, err := fsi.GetString("group-args")
if err != nil {
return err
}
groupArgs = strings.Trim(strings.Trim(groupArgs, "\""), "'")

storageArgs, err := fsi.GetString("storage-args")
if err != nil {
return err
}
storageArgs = strings.Trim(strings.Trim(storageArgs, "\""), "'")

// Create a new resource group
inst.l.Info("creating resource group:", be.ResourceGroup)
if err := shell.New(ctx, inst.l, "az", "group", "create").
Args("--resource-group", be.ResourceGroup).
Args("--subscription", be.Subscription).
Args("--location", be.Location).
Args(strings.Split(groupArgs, " ")...).
Args(r.Flags()...).
Run(); err != nil {
return err
Expand All @@ -125,7 +141,7 @@ func NewCommand(l log.Logger, az *az.AZ, op *onepassword.OnePassword, cache cach
Args("--resource-group", be.ResourceGroup).
Args("--subscription", be.Subscription).
Args("--location", be.Location).
Args("--sku", "Standard_LRS").
Args(strings.Split(storageArgs, " ")...).
Args(r.Flags()...).
Run(); err != nil {
return err
Expand Down Expand Up @@ -164,6 +180,7 @@ func NewCommand(l log.Logger, az *az.AZ, op *onepassword.OnePassword, cache cach
return shell.New(ctx, inst.l, "pulumi", "login", fmt.Sprintf("azblob://%s", be.Container)).
Env("AZURE_STORAGE_ACCOUNT=" + be.StorageAccount).
Env("AZURE_STORAGE_KEY=" + sks).
Env("ARM_SUBSCRIPTION_ID=" + be.Subscription).
Run()
},
},
Expand Down Expand Up @@ -476,6 +493,7 @@ func (c *Command) configureStack(ctx context.Context, env, proj, stack string, b
Env("PULUMI_CONFIG_PASSPHRASE=" + passphrase).
Env("AZURE_STORAGE_ACCOUNT=" + be.StorageAccount).
Env("AZURE_STORAGE_KEY=" + storageAccountKey).
Env("ARM_SUBSCRIPTION_ID=" + be.Subscription).
Args().
Run()
}
Expand Down Expand Up @@ -509,6 +527,7 @@ func (c *Command) executeStack(ctx context.Context, r *readline.Readline) error
Env("PULUMI_CONFIG_PASSPHRASE=" + passphrase).
Env("AZURE_STORAGE_ACCOUNT=" + be.StorageAccount).
Env("AZURE_STORAGE_KEY=" + storageAccountKey).
Env("ARM_SUBSCRIPTION_ID=" + be.Subscription).
Dir(path.Join(c.cfg.Path, e, proj)).
Run()
}
Expand Down

0 comments on commit 5834ea1

Please sign in to comment.