Skip to content

Commit

Permalink
validate region for dashboard url
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoandredinis committed Dec 10, 2024
1 parent b0bffdc commit 0bfa0b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/auth/integration/integrationv1/awsoidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func (s *AWSOIDCService) DeployDatabaseService(ctx context.Context, req *integra
}, nil
}

// ListDeployedDatabaseServices deploys Database Services into Amazon ECS.
// ListDeployedDatabaseServices lists Database Services deployed into Amazon ECS.
func (s *AWSOIDCService) ListDeployedDatabaseServices(ctx context.Context, req *integrationpb.ListDeployedDatabaseServicesRequest) (*integrationpb.ListDeployedDatabaseServicesResponse, error) {
authCtx, err := s.authorizer.Authorize(ctx)
if err != nil {
Expand Down
9 changes: 8 additions & 1 deletion lib/integrations/awsoidc/deployservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (

"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
apiaws "github.com/gravitational/teleport/api/utils/aws"
"github.com/gravitational/teleport/api/utils/retryutils"
"github.com/gravitational/teleport/lib/integrations/awsoidc/tags"
"github.com/gravitational/teleport/lib/utils/teleportassets"
Expand Down Expand Up @@ -449,11 +450,17 @@ func DeployService(ctx context.Context, clt DeployServiceClient, req DeployServi
ClusterARN: aws.ToString(cluster.ClusterArn),
ServiceARN: aws.ToString(service.ServiceArn),
TaskDefinitionARN: taskDefinitionARN,
ServiceDashboardURL: serviceDashboardURL(req.Region, aws.ToString(req.ClusterName), aws.ToString(req.ServiceName)),
ServiceDashboardURL: serviceDashboardURL(req.Region, aws.ToString(req.ClusterName), aws.ToString(service.ServiceName)),
}, nil
}

// serviceDashboardURL builds the ECS Service dashboard URL using the AWS Region, the ECS Cluster and Service Names.
// It returns an empty string if region is not valid.
func serviceDashboardURL(region, clusterName, serviceName string) string {
if err := apiaws.IsValidRegion(region); err != nil {
return ""
}

return fmt.Sprintf("https://%s.console.aws.amazon.com/ecs/v2/clusters/%s/services/%s", region, clusterName, serviceName)
}

Expand Down

0 comments on commit 0bfa0b8

Please sign in to comment.