Skip to content

Commit

Permalink
fix: add resource group links to output AWS + Azure
Browse files Browse the repository at this point in the history
adds the resource group link to the output for AWS and Azure providers
  • Loading branch information
tjholm authored Oct 29, 2024
1 parent da6b0fc commit f023e1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cloud/aws/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package deploy

import (
"fmt"
"net/url"
"strings"

_ "embed"
Expand Down Expand Up @@ -72,6 +73,7 @@ type NitricAwsPulumiProvider struct {
BatchSecurityGroup *awsec2.SecurityGroup
ComputeEnvironment *batch.ComputeEnvironment
JobQueue *batch.JobQueue
ResourceGroup *resourcegroups.Group
// A codebuild job for creating the requested databases for a single database cluster
DbMasterPassword *random.RandomPassword
CreateDatabaseProject *codebuild.Project
Expand Down Expand Up @@ -184,7 +186,7 @@ func (a *NitricAwsPulumiProvider) Pre(ctx *pulumi.Context, resources []*pulumix.
}

// Create AWS Resource groups with our tags
_, err = resourcegroups.NewGroup(ctx, "stack-resource-group", &resourcegroups.GroupArgs{
a.ResourceGroup, err = resourcegroups.NewGroup(ctx, "stack-resource-group", &resourcegroups.GroupArgs{
Name: pulumi.String(a.FullStackName),
Description: pulumi.Sprintf("All deployed resources for the %s nitric stack", a.FullStackName),
ResourceQuery: &resourcegroups.GroupResourceQueryArgs{
Expand Down Expand Up @@ -234,6 +236,15 @@ func (a *NitricAwsPulumiProvider) Post(ctx *pulumi.Context) error {
func (a *NitricAwsPulumiProvider) Result(ctx *pulumi.Context) (pulumi.StringOutput, error) {
outputs := []interface{}{}

urlEncodedRgArn := a.ResourceGroup.Arn.ApplyT(func(arn string) string {
// URL encode the ARN
return url.QueryEscape(arn)
})

// Get a link to this stacks resource group in the AWS console
outputs = append(outputs, pulumi.Sprintf("Deployed Resources:\n──────────────"))
outputs = append(outputs, pulumi.Sprintf("https://%s.console.aws.amazon.com/resource-groups/group/%s\n", a.Region, urlEncodedRgArn))

// Add APIs outputs
if len(a.Apis) > 0 {
outputs = append(outputs, pulumi.Sprintf("API Endpoints:\n──────────────"))
Expand Down
3 changes: 3 additions & 0 deletions cloud/azure/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ func (a *NitricAzurePulumiProvider) Post(ctx *pulumi.Context) error {
func (a *NitricAzurePulumiProvider) Result(ctx *pulumi.Context) (pulumi.StringOutput, error) {
outputs := []interface{}{}

// Add Resource Group output as a link to the Azure Portal
outputs = append(outputs, pulumi.Sprintf("Resource Group:\n──────────────\n%s\n", pulumi.Sprintf("https://portal.azure.com/#@%s/resource/subscriptions/%s/resourceGroups/%s/overview", a.ClientConfig.TenantId, a.ClientConfig.SubscriptionId, a.ResourceGroup.Name)))

// Add APIs outputs
if len(a.Apis) > 0 {
outputs = append(outputs, pulumi.Sprintf("API Endpoints:\n──────────────"))
Expand Down

0 comments on commit f023e1b

Please sign in to comment.