github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cloudwatch/dashboard.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package cloudwatch 5 6 import ( 7 "context" 8 "reflect" 9 10 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides a CloudWatch Dashboard resource. 16 // 17 // ## Example Usage 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "encoding/json" 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // tmpJSON0, err := json.Marshal(map[string]interface{}{ 35 // "widgets": []interface{}{ 36 // map[string]interface{}{ 37 // "type": "metric", 38 // "x": 0, 39 // "y": 0, 40 // "width": 12, 41 // "height": 6, 42 // "properties": map[string]interface{}{ 43 // "metrics": [][]string{ 44 // []string{ 45 // "AWS/EC2", 46 // "CPUUtilization", 47 // "InstanceId", 48 // "i-012345", 49 // }, 50 // }, 51 // "period": 300, 52 // "stat": "Average", 53 // "region": "us-east-1", 54 // "title": "EC2 Instance CPU", 55 // }, 56 // }, 57 // map[string]interface{}{ 58 // "type": "text", 59 // "x": 0, 60 // "y": 7, 61 // "width": 3, 62 // "height": 3, 63 // "properties": map[string]interface{}{ 64 // "markdown": "Hello world", 65 // }, 66 // }, 67 // }, 68 // }) 69 // if err != nil { 70 // return err 71 // } 72 // json0 := string(tmpJSON0) 73 // _, err = cloudwatch.NewDashboard(ctx, "main", &cloudwatch.DashboardArgs{ 74 // DashboardName: pulumi.String("my-dashboard"), 75 // DashboardBody: pulumi.String(json0), 76 // }) 77 // if err != nil { 78 // return err 79 // } 80 // return nil 81 // }) 82 // } 83 // 84 // ``` 85 // <!--End PulumiCodeChooser --> 86 // 87 // ## Import 88 // 89 // Using `pulumi import`, import CloudWatch dashboards using the `dashboard_name`. For example: 90 // 91 // ```sh 92 // $ pulumi import aws:cloudwatch/dashboard:Dashboard sample dashboard_name 93 // ``` 94 type Dashboard struct { 95 pulumi.CustomResourceState 96 97 // The Amazon Resource Name (ARN) of the dashboard. 98 DashboardArn pulumi.StringOutput `pulumi:"dashboardArn"` 99 // The detailed information about the dashboard, including what widgets are included and their location on the dashboard. You can read more about the body structure in the [documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html). 100 DashboardBody pulumi.StringOutput `pulumi:"dashboardBody"` 101 // The name of the dashboard. 102 DashboardName pulumi.StringOutput `pulumi:"dashboardName"` 103 } 104 105 // NewDashboard registers a new resource with the given unique name, arguments, and options. 106 func NewDashboard(ctx *pulumi.Context, 107 name string, args *DashboardArgs, opts ...pulumi.ResourceOption) (*Dashboard, error) { 108 if args == nil { 109 return nil, errors.New("missing one or more required arguments") 110 } 111 112 if args.DashboardBody == nil { 113 return nil, errors.New("invalid value for required argument 'DashboardBody'") 114 } 115 if args.DashboardName == nil { 116 return nil, errors.New("invalid value for required argument 'DashboardName'") 117 } 118 opts = internal.PkgResourceDefaultOpts(opts) 119 var resource Dashboard 120 err := ctx.RegisterResource("aws:cloudwatch/dashboard:Dashboard", name, args, &resource, opts...) 121 if err != nil { 122 return nil, err 123 } 124 return &resource, nil 125 } 126 127 // GetDashboard gets an existing Dashboard resource's state with the given name, ID, and optional 128 // state properties that are used to uniquely qualify the lookup (nil if not required). 129 func GetDashboard(ctx *pulumi.Context, 130 name string, id pulumi.IDInput, state *DashboardState, opts ...pulumi.ResourceOption) (*Dashboard, error) { 131 var resource Dashboard 132 err := ctx.ReadResource("aws:cloudwatch/dashboard:Dashboard", name, id, state, &resource, opts...) 133 if err != nil { 134 return nil, err 135 } 136 return &resource, nil 137 } 138 139 // Input properties used for looking up and filtering Dashboard resources. 140 type dashboardState struct { 141 // The Amazon Resource Name (ARN) of the dashboard. 142 DashboardArn *string `pulumi:"dashboardArn"` 143 // The detailed information about the dashboard, including what widgets are included and their location on the dashboard. You can read more about the body structure in the [documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html). 144 DashboardBody *string `pulumi:"dashboardBody"` 145 // The name of the dashboard. 146 DashboardName *string `pulumi:"dashboardName"` 147 } 148 149 type DashboardState struct { 150 // The Amazon Resource Name (ARN) of the dashboard. 151 DashboardArn pulumi.StringPtrInput 152 // The detailed information about the dashboard, including what widgets are included and their location on the dashboard. You can read more about the body structure in the [documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html). 153 DashboardBody pulumi.StringPtrInput 154 // The name of the dashboard. 155 DashboardName pulumi.StringPtrInput 156 } 157 158 func (DashboardState) ElementType() reflect.Type { 159 return reflect.TypeOf((*dashboardState)(nil)).Elem() 160 } 161 162 type dashboardArgs struct { 163 // The detailed information about the dashboard, including what widgets are included and their location on the dashboard. You can read more about the body structure in the [documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html). 164 DashboardBody string `pulumi:"dashboardBody"` 165 // The name of the dashboard. 166 DashboardName string `pulumi:"dashboardName"` 167 } 168 169 // The set of arguments for constructing a Dashboard resource. 170 type DashboardArgs struct { 171 // The detailed information about the dashboard, including what widgets are included and their location on the dashboard. You can read more about the body structure in the [documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html). 172 DashboardBody pulumi.StringInput 173 // The name of the dashboard. 174 DashboardName pulumi.StringInput 175 } 176 177 func (DashboardArgs) ElementType() reflect.Type { 178 return reflect.TypeOf((*dashboardArgs)(nil)).Elem() 179 } 180 181 type DashboardInput interface { 182 pulumi.Input 183 184 ToDashboardOutput() DashboardOutput 185 ToDashboardOutputWithContext(ctx context.Context) DashboardOutput 186 } 187 188 func (*Dashboard) ElementType() reflect.Type { 189 return reflect.TypeOf((**Dashboard)(nil)).Elem() 190 } 191 192 func (i *Dashboard) ToDashboardOutput() DashboardOutput { 193 return i.ToDashboardOutputWithContext(context.Background()) 194 } 195 196 func (i *Dashboard) ToDashboardOutputWithContext(ctx context.Context) DashboardOutput { 197 return pulumi.ToOutputWithContext(ctx, i).(DashboardOutput) 198 } 199 200 // DashboardArrayInput is an input type that accepts DashboardArray and DashboardArrayOutput values. 201 // You can construct a concrete instance of `DashboardArrayInput` via: 202 // 203 // DashboardArray{ DashboardArgs{...} } 204 type DashboardArrayInput interface { 205 pulumi.Input 206 207 ToDashboardArrayOutput() DashboardArrayOutput 208 ToDashboardArrayOutputWithContext(context.Context) DashboardArrayOutput 209 } 210 211 type DashboardArray []DashboardInput 212 213 func (DashboardArray) ElementType() reflect.Type { 214 return reflect.TypeOf((*[]*Dashboard)(nil)).Elem() 215 } 216 217 func (i DashboardArray) ToDashboardArrayOutput() DashboardArrayOutput { 218 return i.ToDashboardArrayOutputWithContext(context.Background()) 219 } 220 221 func (i DashboardArray) ToDashboardArrayOutputWithContext(ctx context.Context) DashboardArrayOutput { 222 return pulumi.ToOutputWithContext(ctx, i).(DashboardArrayOutput) 223 } 224 225 // DashboardMapInput is an input type that accepts DashboardMap and DashboardMapOutput values. 226 // You can construct a concrete instance of `DashboardMapInput` via: 227 // 228 // DashboardMap{ "key": DashboardArgs{...} } 229 type DashboardMapInput interface { 230 pulumi.Input 231 232 ToDashboardMapOutput() DashboardMapOutput 233 ToDashboardMapOutputWithContext(context.Context) DashboardMapOutput 234 } 235 236 type DashboardMap map[string]DashboardInput 237 238 func (DashboardMap) ElementType() reflect.Type { 239 return reflect.TypeOf((*map[string]*Dashboard)(nil)).Elem() 240 } 241 242 func (i DashboardMap) ToDashboardMapOutput() DashboardMapOutput { 243 return i.ToDashboardMapOutputWithContext(context.Background()) 244 } 245 246 func (i DashboardMap) ToDashboardMapOutputWithContext(ctx context.Context) DashboardMapOutput { 247 return pulumi.ToOutputWithContext(ctx, i).(DashboardMapOutput) 248 } 249 250 type DashboardOutput struct{ *pulumi.OutputState } 251 252 func (DashboardOutput) ElementType() reflect.Type { 253 return reflect.TypeOf((**Dashboard)(nil)).Elem() 254 } 255 256 func (o DashboardOutput) ToDashboardOutput() DashboardOutput { 257 return o 258 } 259 260 func (o DashboardOutput) ToDashboardOutputWithContext(ctx context.Context) DashboardOutput { 261 return o 262 } 263 264 // The Amazon Resource Name (ARN) of the dashboard. 265 func (o DashboardOutput) DashboardArn() pulumi.StringOutput { 266 return o.ApplyT(func(v *Dashboard) pulumi.StringOutput { return v.DashboardArn }).(pulumi.StringOutput) 267 } 268 269 // The detailed information about the dashboard, including what widgets are included and their location on the dashboard. You can read more about the body structure in the [documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html). 270 func (o DashboardOutput) DashboardBody() pulumi.StringOutput { 271 return o.ApplyT(func(v *Dashboard) pulumi.StringOutput { return v.DashboardBody }).(pulumi.StringOutput) 272 } 273 274 // The name of the dashboard. 275 func (o DashboardOutput) DashboardName() pulumi.StringOutput { 276 return o.ApplyT(func(v *Dashboard) pulumi.StringOutput { return v.DashboardName }).(pulumi.StringOutput) 277 } 278 279 type DashboardArrayOutput struct{ *pulumi.OutputState } 280 281 func (DashboardArrayOutput) ElementType() reflect.Type { 282 return reflect.TypeOf((*[]*Dashboard)(nil)).Elem() 283 } 284 285 func (o DashboardArrayOutput) ToDashboardArrayOutput() DashboardArrayOutput { 286 return o 287 } 288 289 func (o DashboardArrayOutput) ToDashboardArrayOutputWithContext(ctx context.Context) DashboardArrayOutput { 290 return o 291 } 292 293 func (o DashboardArrayOutput) Index(i pulumi.IntInput) DashboardOutput { 294 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Dashboard { 295 return vs[0].([]*Dashboard)[vs[1].(int)] 296 }).(DashboardOutput) 297 } 298 299 type DashboardMapOutput struct{ *pulumi.OutputState } 300 301 func (DashboardMapOutput) ElementType() reflect.Type { 302 return reflect.TypeOf((*map[string]*Dashboard)(nil)).Elem() 303 } 304 305 func (o DashboardMapOutput) ToDashboardMapOutput() DashboardMapOutput { 306 return o 307 } 308 309 func (o DashboardMapOutput) ToDashboardMapOutputWithContext(ctx context.Context) DashboardMapOutput { 310 return o 311 } 312 313 func (o DashboardMapOutput) MapIndex(k pulumi.StringInput) DashboardOutput { 314 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Dashboard { 315 return vs[0].(map[string]*Dashboard)[vs[1].(string)] 316 }).(DashboardOutput) 317 } 318 319 func init() { 320 pulumi.RegisterInputType(reflect.TypeOf((*DashboardInput)(nil)).Elem(), &Dashboard{}) 321 pulumi.RegisterInputType(reflect.TypeOf((*DashboardArrayInput)(nil)).Elem(), DashboardArray{}) 322 pulumi.RegisterInputType(reflect.TypeOf((*DashboardMapInput)(nil)).Elem(), DashboardMap{}) 323 pulumi.RegisterOutputType(DashboardOutput{}) 324 pulumi.RegisterOutputType(DashboardArrayOutput{}) 325 pulumi.RegisterOutputType(DashboardMapOutput{}) 326 }