Skip to content

Commit

Permalink
feat(azure): Resource Group Imports (#648)
Browse files Browse the repository at this point in the history
Co-authored-by: Jye Cusch <[email protected]>
  • Loading branch information
tjholm and jyecusch authored Jul 23, 2024
1 parent 213c850 commit 8dbddb7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions cloud/azure/deploy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type AzureContainerAppsConfig struct {

type AzureConfig struct {
Refresh bool
ResourceGroup string `mapstructure:"resource-group"`
Org string `mapstructure:"org"`
AdminEmail string `mapstructure:"adminemail"`
config.AbstractConfig[*AzureConfigItem] `mapstructure:"config,squash"`
Expand Down
2 changes: 1 addition & 1 deletion cloud/azure/deploy/containerenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (p *NitricAzurePulumiProvider) newContainerEnv(ctx *pulumi.Context, name st
res.ManagedUser, err = managedidentity.NewUserAssignedIdentity(ctx, "managed-identity", &managedidentity.UserAssignedIdentityArgs{
Location: p.ResourceGroup.Location,
ResourceGroupName: p.ResourceGroup.Name,
ResourceName: pulumi.String("managed-identity"),
ResourceName: pulumi.Sprintf("managed-identity-%s", p.StackId),
}, pulumi.Parent(res))
if err != nil {
return nil, err
Expand Down
14 changes: 10 additions & 4 deletions cloud/azure/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,16 @@ func (a *NitricAzurePulumiProvider) Pre(ctx *pulumi.Context, nitricResources []*
return err
}

a.ResourceGroup, err = resources.NewResourceGroup(ctx, ResourceName(ctx, "", ResourceGroupRT), &resources.ResourceGroupArgs{
Location: pulumi.String(a.Region),
Tags: pulumi.ToStringMap(tags.Tags(a.StackId, ctx.Stack(), commonresources.Stack)),
})
if a.AzureConfig.ResourceGroup != "" {
rgId := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s", a.ClientConfig.SubscriptionId, a.AzureConfig.ResourceGroup)
a.ResourceGroup, err = resources.GetResourceGroup(ctx, ResourceName(ctx, "", ResourceGroupRT), pulumi.ID(rgId), nil, pulumi.RetainOnDelete(true))
} else {
a.ResourceGroup, err = resources.NewResourceGroup(ctx, ResourceName(ctx, "", ResourceGroupRT), &resources.ResourceGroupArgs{
Location: pulumi.String(a.Region),
Tags: pulumi.ToStringMap(tags.Tags(a.StackId, ctx.Stack(), commonresources.Stack)),
})
}

if err != nil {
return errors.WithMessage(err, "resource group create")
}
Expand Down

0 comments on commit 8dbddb7

Please sign in to comment.