Automating Dynatrace dashboard sharing with user groups
TypeScriptTo automate sharing Dynatrace dashboards with user groups using Pulumi and the Dynatrace provider, you need to define both the
dynatrace.Dashboard
anddynatrace.DashboardSharing
resources in your Pulumi program.The
dynatrace.Dashboard
resource allows you to create and configure a dashboard in Dynatrace, and thedynatrace.DashboardSharing
resource manages the sharing settings for that dashboard.Below is a TypeScript program that demonstrates how to set up a Dynatrace dashboard and share it with a specific user group. This script assumes you've already set up the necessary Dynatrace provider and authentication configurations.
First, we define a new dashboard using the
dynatrace.Dashboard
resource. Then we use thedynatrace.DashboardSharing
resource to share that dashboard. In the sharing settings, we can specify which user groups will have permissions to view or edit the dashboard. Note that thedashboardId
parameter in thedynatrace.DashboardSharing
resource must match the id of the createddynatrace.Dashboard
.Here's the Pulumi TypeScript program:
import * as pulumi from "@pulumi/pulumi"; import * as dynatrace from "@pulumi/dynatrace"; // Create a new Dynatrace dashboard const myDashboard = new dynatrace.Dashboard("myDashboard", { // The dashboard's metadata, which includes the name, tags, and more. dashboardMetadata: { name: "My Dashboard", // ... other metadata properties }, // Specify the tiles and their configurations for your dashboard. tiles: [ // Add the necessary tiles objects here ], // ... other dashboard properties }); // Share the created dashboard with a specific User Group const myDashboardSharing = new dynatrace.DashboardSharing("myDashboardSharing", { dashboardId: myDashboard.id, // Reference the ID of the created dashboard permissions: { permissions: [ { type: "GROUP", id: "<user-group-id>", // Replace with your actual user group ID level: "VIEW", // You can set this to 'VIEW' or 'EDIT' }, // Add other groups or users if needed ], }, // ... other sharing properties }); // Export the dashboard ID and the URL of the shared dashboard. export const dashboardId = myDashboard.id; export const sharedDashboardUrl = myDashboardSharing.url; // This will be the URL users can use to access the shared dashboard
Explanation:
- We import the necessary modules from both Pulumi and the Dynatrace Pulumi provider.
- We create a dashboard using
dynatrace.Dashboard
, defining the properties that configure the dashboard's appearance and functionality. - We configure dashboard sharing using
dynatrace.DashboardSharing
, linking it to our previously created dashboard by itsid
.
Important details such as user group IDs to share the dashboard with, and the tile configuration for the dashboard itself, must be filled in accordingly to match your Dynatrace setup.
At the end of the program, we export
dashboardId
andsharedDashboardUrl
which provide convenient outputs that can be used to reference the dashboard and its shared URL after the resources have been provisioned by Pulumi.For more detailed properties of each resource, you can refer to the official Dynatrace Dashboard and Dynatrace DashboardSharing documentation.