createDashboard

Creates a new dashboard that can contain multiple widgets displaying cost and usage data. You can add custom widgets or use predefined widgets, arranging them in your preferred layout.

Samples

import aws.sdk.kotlin.services.bcmdashboards.model.CostAndUsageQuery
import aws.sdk.kotlin.services.bcmdashboards.model.DateTimeRange
import aws.sdk.kotlin.services.bcmdashboards.model.DateTimeType
import aws.sdk.kotlin.services.bcmdashboards.model.DateTimeValue
import aws.sdk.kotlin.services.bcmdashboards.model.DisplayConfig
import aws.sdk.kotlin.services.bcmdashboards.model.Granularity
import aws.sdk.kotlin.services.bcmdashboards.model.GraphDisplayConfig
import aws.sdk.kotlin.services.bcmdashboards.model.GroupDefinition
import aws.sdk.kotlin.services.bcmdashboards.model.GroupDefinitionType
import aws.sdk.kotlin.services.bcmdashboards.model.MetricName
import aws.sdk.kotlin.services.bcmdashboards.model.QueryParameters
import aws.sdk.kotlin.services.bcmdashboards.model.VisualType
import aws.sdk.kotlin.services.bcmdashboards.model.Widget
import aws.sdk.kotlin.services.bcmdashboards.model.WidgetConfig

fun main() { 
   //sampleStart 
   // Creating a dashboard
bcmDashboardsClient.createDashboard {
    name = "cost-dashboards"
    description = "Dashboard for tracking costs"
    widgets = listOf<Widget>(
        Widget {
            title = "Monthly Cost Trend"
            width = 4
            height = 7
            horizontalOffset = 0
            configs = listOf<WidgetConfig>(
                WidgetConfig {
                    displayConfig = DisplayConfig.Graph(mapOf<String, GraphDisplayConfig>(
                        "costTrend" to GraphDisplayConfig {
                            visualType = VisualType.fromValue("LINE")
                        }
                    )
                    )
                    queryParameters = QueryParameters.CostAndUsage(CostAndUsageQuery {
                        granularity = Granularity.fromValue("MONTHLY")
                        groupBy = listOf<GroupDefinition>(
                            GroupDefinition {
                                key = "SERVICE"
                                type = GroupDefinitionType.fromValue("DIMENSION")
                            }                                
                        )
                        metrics = listOf<MetricName>(
                            MetricName.fromValue("UnblendedCost")
                        )
                        timeRange = DateTimeRange {
                            endTime = DateTimeValue {
                                type = DateTimeType.fromValue("RELATIVE")
                                value = "now"
                            }
                            startTime = DateTimeValue {
                                type = DateTimeType.fromValue("RELATIVE")
                                value = "-9M"
                            }
                        }
                    }
                    )
                }                    
            )
        }            
    )
} 
   //sampleEnd
}