github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/redshift/scheduledAction.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 redshift 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 // ## Example Usage 16 // 17 // ### Pause Cluster Action 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/redshift" 27 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 28 // 29 // ) 30 // 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 34 // Statements: []iam.GetPolicyDocumentStatement{ 35 // { 36 // Effect: pulumi.StringRef("Allow"), 37 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 38 // { 39 // Type: "Service", 40 // Identifiers: []string{ 41 // "scheduler.redshift.amazonaws.com", 42 // }, 43 // }, 44 // }, 45 // Actions: []string{ 46 // "sts:AssumeRole", 47 // }, 48 // }, 49 // }, 50 // }, nil) 51 // if err != nil { 52 // return err 53 // } 54 // exampleRole, err := iam.NewRole(ctx, "example", &iam.RoleArgs{ 55 // Name: pulumi.String("redshift_scheduled_action"), 56 // AssumeRolePolicy: pulumi.String(assumeRole.Json), 57 // }) 58 // if err != nil { 59 // return err 60 // } 61 // example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 62 // Statements: []iam.GetPolicyDocumentStatement{ 63 // { 64 // Effect: pulumi.StringRef("Allow"), 65 // Actions: []string{ 66 // "redshift:PauseCluster", 67 // "redshift:ResumeCluster", 68 // "redshift:ResizeCluster", 69 // }, 70 // Resources: []string{ 71 // "*", 72 // }, 73 // }, 74 // }, 75 // }, nil) 76 // if err != nil { 77 // return err 78 // } 79 // examplePolicy, err := iam.NewPolicy(ctx, "example", &iam.PolicyArgs{ 80 // Name: pulumi.String("redshift_scheduled_action"), 81 // Policy: pulumi.String(example.Json), 82 // }) 83 // if err != nil { 84 // return err 85 // } 86 // _, err = iam.NewRolePolicyAttachment(ctx, "example", &iam.RolePolicyAttachmentArgs{ 87 // PolicyArn: examplePolicy.Arn, 88 // Role: exampleRole.Name, 89 // }) 90 // if err != nil { 91 // return err 92 // } 93 // _, err = redshift.NewScheduledAction(ctx, "example", &redshift.ScheduledActionArgs{ 94 // Name: pulumi.String("tf-redshift-scheduled-action"), 95 // Schedule: pulumi.String("cron(00 23 * * ? *)"), 96 // IamRole: exampleRole.Arn, 97 // TargetAction: &redshift.ScheduledActionTargetActionArgs{ 98 // PauseCluster: &redshift.ScheduledActionTargetActionPauseClusterArgs{ 99 // ClusterIdentifier: pulumi.String("tf-redshift001"), 100 // }, 101 // }, 102 // }) 103 // if err != nil { 104 // return err 105 // } 106 // return nil 107 // }) 108 // } 109 // 110 // ``` 111 // <!--End PulumiCodeChooser --> 112 // 113 // ### Resize Cluster Action 114 // 115 // <!--Start PulumiCodeChooser --> 116 // ```go 117 // package main 118 // 119 // import ( 120 // 121 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/redshift" 122 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 123 // 124 // ) 125 // 126 // func main() { 127 // pulumi.Run(func(ctx *pulumi.Context) error { 128 // _, err := redshift.NewScheduledAction(ctx, "example", &redshift.ScheduledActionArgs{ 129 // Name: pulumi.String("tf-redshift-scheduled-action"), 130 // Schedule: pulumi.String("cron(00 23 * * ? *)"), 131 // IamRole: pulumi.Any(exampleAwsIamRole.Arn), 132 // TargetAction: &redshift.ScheduledActionTargetActionArgs{ 133 // ResizeCluster: &redshift.ScheduledActionTargetActionResizeClusterArgs{ 134 // ClusterIdentifier: pulumi.String("tf-redshift001"), 135 // ClusterType: pulumi.String("multi-node"), 136 // NodeType: pulumi.String("dc1.large"), 137 // NumberOfNodes: pulumi.Int(2), 138 // }, 139 // }, 140 // }) 141 // if err != nil { 142 // return err 143 // } 144 // return nil 145 // }) 146 // } 147 // 148 // ``` 149 // <!--End PulumiCodeChooser --> 150 // 151 // ## Import 152 // 153 // Using `pulumi import`, import Redshift Scheduled Action using the `name`. For example: 154 // 155 // ```sh 156 // $ pulumi import aws:redshift/scheduledAction:ScheduledAction example tf-redshift-scheduled-action 157 // ``` 158 type ScheduledAction struct { 159 pulumi.CustomResourceState 160 161 // The description of the scheduled action. 162 Description pulumi.StringPtrOutput `pulumi:"description"` 163 // Whether to enable the scheduled action. Default is `true` . 164 Enable pulumi.BoolPtrOutput `pulumi:"enable"` 165 // The end time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 166 EndTime pulumi.StringPtrOutput `pulumi:"endTime"` 167 // The IAM role to assume to run the scheduled action. 168 IamRole pulumi.StringOutput `pulumi:"iamRole"` 169 // The scheduled action name. 170 Name pulumi.StringOutput `pulumi:"name"` 171 // The schedule of action. The schedule is defined format of "at expression" or "cron expression", for example `at(2016-03-04T17:27:00)` or `cron(0 10 ? * MON *)`. See [Scheduled Action](https://docs.aws.amazon.com/redshift/latest/APIReference/API_ScheduledAction.html) for more information. 172 Schedule pulumi.StringOutput `pulumi:"schedule"` 173 // The start time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 174 StartTime pulumi.StringPtrOutput `pulumi:"startTime"` 175 // Target action. Documented below. 176 TargetAction ScheduledActionTargetActionOutput `pulumi:"targetAction"` 177 } 178 179 // NewScheduledAction registers a new resource with the given unique name, arguments, and options. 180 func NewScheduledAction(ctx *pulumi.Context, 181 name string, args *ScheduledActionArgs, opts ...pulumi.ResourceOption) (*ScheduledAction, error) { 182 if args == nil { 183 return nil, errors.New("missing one or more required arguments") 184 } 185 186 if args.IamRole == nil { 187 return nil, errors.New("invalid value for required argument 'IamRole'") 188 } 189 if args.Schedule == nil { 190 return nil, errors.New("invalid value for required argument 'Schedule'") 191 } 192 if args.TargetAction == nil { 193 return nil, errors.New("invalid value for required argument 'TargetAction'") 194 } 195 opts = internal.PkgResourceDefaultOpts(opts) 196 var resource ScheduledAction 197 err := ctx.RegisterResource("aws:redshift/scheduledAction:ScheduledAction", name, args, &resource, opts...) 198 if err != nil { 199 return nil, err 200 } 201 return &resource, nil 202 } 203 204 // GetScheduledAction gets an existing ScheduledAction resource's state with the given name, ID, and optional 205 // state properties that are used to uniquely qualify the lookup (nil if not required). 206 func GetScheduledAction(ctx *pulumi.Context, 207 name string, id pulumi.IDInput, state *ScheduledActionState, opts ...pulumi.ResourceOption) (*ScheduledAction, error) { 208 var resource ScheduledAction 209 err := ctx.ReadResource("aws:redshift/scheduledAction:ScheduledAction", name, id, state, &resource, opts...) 210 if err != nil { 211 return nil, err 212 } 213 return &resource, nil 214 } 215 216 // Input properties used for looking up and filtering ScheduledAction resources. 217 type scheduledActionState struct { 218 // The description of the scheduled action. 219 Description *string `pulumi:"description"` 220 // Whether to enable the scheduled action. Default is `true` . 221 Enable *bool `pulumi:"enable"` 222 // The end time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 223 EndTime *string `pulumi:"endTime"` 224 // The IAM role to assume to run the scheduled action. 225 IamRole *string `pulumi:"iamRole"` 226 // The scheduled action name. 227 Name *string `pulumi:"name"` 228 // The schedule of action. The schedule is defined format of "at expression" or "cron expression", for example `at(2016-03-04T17:27:00)` or `cron(0 10 ? * MON *)`. See [Scheduled Action](https://docs.aws.amazon.com/redshift/latest/APIReference/API_ScheduledAction.html) for more information. 229 Schedule *string `pulumi:"schedule"` 230 // The start time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 231 StartTime *string `pulumi:"startTime"` 232 // Target action. Documented below. 233 TargetAction *ScheduledActionTargetAction `pulumi:"targetAction"` 234 } 235 236 type ScheduledActionState struct { 237 // The description of the scheduled action. 238 Description pulumi.StringPtrInput 239 // Whether to enable the scheduled action. Default is `true` . 240 Enable pulumi.BoolPtrInput 241 // The end time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 242 EndTime pulumi.StringPtrInput 243 // The IAM role to assume to run the scheduled action. 244 IamRole pulumi.StringPtrInput 245 // The scheduled action name. 246 Name pulumi.StringPtrInput 247 // The schedule of action. The schedule is defined format of "at expression" or "cron expression", for example `at(2016-03-04T17:27:00)` or `cron(0 10 ? * MON *)`. See [Scheduled Action](https://docs.aws.amazon.com/redshift/latest/APIReference/API_ScheduledAction.html) for more information. 248 Schedule pulumi.StringPtrInput 249 // The start time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 250 StartTime pulumi.StringPtrInput 251 // Target action. Documented below. 252 TargetAction ScheduledActionTargetActionPtrInput 253 } 254 255 func (ScheduledActionState) ElementType() reflect.Type { 256 return reflect.TypeOf((*scheduledActionState)(nil)).Elem() 257 } 258 259 type scheduledActionArgs struct { 260 // The description of the scheduled action. 261 Description *string `pulumi:"description"` 262 // Whether to enable the scheduled action. Default is `true` . 263 Enable *bool `pulumi:"enable"` 264 // The end time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 265 EndTime *string `pulumi:"endTime"` 266 // The IAM role to assume to run the scheduled action. 267 IamRole string `pulumi:"iamRole"` 268 // The scheduled action name. 269 Name *string `pulumi:"name"` 270 // The schedule of action. The schedule is defined format of "at expression" or "cron expression", for example `at(2016-03-04T17:27:00)` or `cron(0 10 ? * MON *)`. See [Scheduled Action](https://docs.aws.amazon.com/redshift/latest/APIReference/API_ScheduledAction.html) for more information. 271 Schedule string `pulumi:"schedule"` 272 // The start time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 273 StartTime *string `pulumi:"startTime"` 274 // Target action. Documented below. 275 TargetAction ScheduledActionTargetAction `pulumi:"targetAction"` 276 } 277 278 // The set of arguments for constructing a ScheduledAction resource. 279 type ScheduledActionArgs struct { 280 // The description of the scheduled action. 281 Description pulumi.StringPtrInput 282 // Whether to enable the scheduled action. Default is `true` . 283 Enable pulumi.BoolPtrInput 284 // The end time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 285 EndTime pulumi.StringPtrInput 286 // The IAM role to assume to run the scheduled action. 287 IamRole pulumi.StringInput 288 // The scheduled action name. 289 Name pulumi.StringPtrInput 290 // The schedule of action. The schedule is defined format of "at expression" or "cron expression", for example `at(2016-03-04T17:27:00)` or `cron(0 10 ? * MON *)`. See [Scheduled Action](https://docs.aws.amazon.com/redshift/latest/APIReference/API_ScheduledAction.html) for more information. 291 Schedule pulumi.StringInput 292 // The start time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 293 StartTime pulumi.StringPtrInput 294 // Target action. Documented below. 295 TargetAction ScheduledActionTargetActionInput 296 } 297 298 func (ScheduledActionArgs) ElementType() reflect.Type { 299 return reflect.TypeOf((*scheduledActionArgs)(nil)).Elem() 300 } 301 302 type ScheduledActionInput interface { 303 pulumi.Input 304 305 ToScheduledActionOutput() ScheduledActionOutput 306 ToScheduledActionOutputWithContext(ctx context.Context) ScheduledActionOutput 307 } 308 309 func (*ScheduledAction) ElementType() reflect.Type { 310 return reflect.TypeOf((**ScheduledAction)(nil)).Elem() 311 } 312 313 func (i *ScheduledAction) ToScheduledActionOutput() ScheduledActionOutput { 314 return i.ToScheduledActionOutputWithContext(context.Background()) 315 } 316 317 func (i *ScheduledAction) ToScheduledActionOutputWithContext(ctx context.Context) ScheduledActionOutput { 318 return pulumi.ToOutputWithContext(ctx, i).(ScheduledActionOutput) 319 } 320 321 // ScheduledActionArrayInput is an input type that accepts ScheduledActionArray and ScheduledActionArrayOutput values. 322 // You can construct a concrete instance of `ScheduledActionArrayInput` via: 323 // 324 // ScheduledActionArray{ ScheduledActionArgs{...} } 325 type ScheduledActionArrayInput interface { 326 pulumi.Input 327 328 ToScheduledActionArrayOutput() ScheduledActionArrayOutput 329 ToScheduledActionArrayOutputWithContext(context.Context) ScheduledActionArrayOutput 330 } 331 332 type ScheduledActionArray []ScheduledActionInput 333 334 func (ScheduledActionArray) ElementType() reflect.Type { 335 return reflect.TypeOf((*[]*ScheduledAction)(nil)).Elem() 336 } 337 338 func (i ScheduledActionArray) ToScheduledActionArrayOutput() ScheduledActionArrayOutput { 339 return i.ToScheduledActionArrayOutputWithContext(context.Background()) 340 } 341 342 func (i ScheduledActionArray) ToScheduledActionArrayOutputWithContext(ctx context.Context) ScheduledActionArrayOutput { 343 return pulumi.ToOutputWithContext(ctx, i).(ScheduledActionArrayOutput) 344 } 345 346 // ScheduledActionMapInput is an input type that accepts ScheduledActionMap and ScheduledActionMapOutput values. 347 // You can construct a concrete instance of `ScheduledActionMapInput` via: 348 // 349 // ScheduledActionMap{ "key": ScheduledActionArgs{...} } 350 type ScheduledActionMapInput interface { 351 pulumi.Input 352 353 ToScheduledActionMapOutput() ScheduledActionMapOutput 354 ToScheduledActionMapOutputWithContext(context.Context) ScheduledActionMapOutput 355 } 356 357 type ScheduledActionMap map[string]ScheduledActionInput 358 359 func (ScheduledActionMap) ElementType() reflect.Type { 360 return reflect.TypeOf((*map[string]*ScheduledAction)(nil)).Elem() 361 } 362 363 func (i ScheduledActionMap) ToScheduledActionMapOutput() ScheduledActionMapOutput { 364 return i.ToScheduledActionMapOutputWithContext(context.Background()) 365 } 366 367 func (i ScheduledActionMap) ToScheduledActionMapOutputWithContext(ctx context.Context) ScheduledActionMapOutput { 368 return pulumi.ToOutputWithContext(ctx, i).(ScheduledActionMapOutput) 369 } 370 371 type ScheduledActionOutput struct{ *pulumi.OutputState } 372 373 func (ScheduledActionOutput) ElementType() reflect.Type { 374 return reflect.TypeOf((**ScheduledAction)(nil)).Elem() 375 } 376 377 func (o ScheduledActionOutput) ToScheduledActionOutput() ScheduledActionOutput { 378 return o 379 } 380 381 func (o ScheduledActionOutput) ToScheduledActionOutputWithContext(ctx context.Context) ScheduledActionOutput { 382 return o 383 } 384 385 // The description of the scheduled action. 386 func (o ScheduledActionOutput) Description() pulumi.StringPtrOutput { 387 return o.ApplyT(func(v *ScheduledAction) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput) 388 } 389 390 // Whether to enable the scheduled action. Default is `true` . 391 func (o ScheduledActionOutput) Enable() pulumi.BoolPtrOutput { 392 return o.ApplyT(func(v *ScheduledAction) pulumi.BoolPtrOutput { return v.Enable }).(pulumi.BoolPtrOutput) 393 } 394 395 // The end time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 396 func (o ScheduledActionOutput) EndTime() pulumi.StringPtrOutput { 397 return o.ApplyT(func(v *ScheduledAction) pulumi.StringPtrOutput { return v.EndTime }).(pulumi.StringPtrOutput) 398 } 399 400 // The IAM role to assume to run the scheduled action. 401 func (o ScheduledActionOutput) IamRole() pulumi.StringOutput { 402 return o.ApplyT(func(v *ScheduledAction) pulumi.StringOutput { return v.IamRole }).(pulumi.StringOutput) 403 } 404 405 // The scheduled action name. 406 func (o ScheduledActionOutput) Name() pulumi.StringOutput { 407 return o.ApplyT(func(v *ScheduledAction) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 408 } 409 410 // The schedule of action. The schedule is defined format of "at expression" or "cron expression", for example `at(2016-03-04T17:27:00)` or `cron(0 10 ? * MON *)`. See [Scheduled Action](https://docs.aws.amazon.com/redshift/latest/APIReference/API_ScheduledAction.html) for more information. 411 func (o ScheduledActionOutput) Schedule() pulumi.StringOutput { 412 return o.ApplyT(func(v *ScheduledAction) pulumi.StringOutput { return v.Schedule }).(pulumi.StringOutput) 413 } 414 415 // The start time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). 416 func (o ScheduledActionOutput) StartTime() pulumi.StringPtrOutput { 417 return o.ApplyT(func(v *ScheduledAction) pulumi.StringPtrOutput { return v.StartTime }).(pulumi.StringPtrOutput) 418 } 419 420 // Target action. Documented below. 421 func (o ScheduledActionOutput) TargetAction() ScheduledActionTargetActionOutput { 422 return o.ApplyT(func(v *ScheduledAction) ScheduledActionTargetActionOutput { return v.TargetAction }).(ScheduledActionTargetActionOutput) 423 } 424 425 type ScheduledActionArrayOutput struct{ *pulumi.OutputState } 426 427 func (ScheduledActionArrayOutput) ElementType() reflect.Type { 428 return reflect.TypeOf((*[]*ScheduledAction)(nil)).Elem() 429 } 430 431 func (o ScheduledActionArrayOutput) ToScheduledActionArrayOutput() ScheduledActionArrayOutput { 432 return o 433 } 434 435 func (o ScheduledActionArrayOutput) ToScheduledActionArrayOutputWithContext(ctx context.Context) ScheduledActionArrayOutput { 436 return o 437 } 438 439 func (o ScheduledActionArrayOutput) Index(i pulumi.IntInput) ScheduledActionOutput { 440 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ScheduledAction { 441 return vs[0].([]*ScheduledAction)[vs[1].(int)] 442 }).(ScheduledActionOutput) 443 } 444 445 type ScheduledActionMapOutput struct{ *pulumi.OutputState } 446 447 func (ScheduledActionMapOutput) ElementType() reflect.Type { 448 return reflect.TypeOf((*map[string]*ScheduledAction)(nil)).Elem() 449 } 450 451 func (o ScheduledActionMapOutput) ToScheduledActionMapOutput() ScheduledActionMapOutput { 452 return o 453 } 454 455 func (o ScheduledActionMapOutput) ToScheduledActionMapOutputWithContext(ctx context.Context) ScheduledActionMapOutput { 456 return o 457 } 458 459 func (o ScheduledActionMapOutput) MapIndex(k pulumi.StringInput) ScheduledActionOutput { 460 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ScheduledAction { 461 return vs[0].(map[string]*ScheduledAction)[vs[1].(string)] 462 }).(ScheduledActionOutput) 463 } 464 465 func init() { 466 pulumi.RegisterInputType(reflect.TypeOf((*ScheduledActionInput)(nil)).Elem(), &ScheduledAction{}) 467 pulumi.RegisterInputType(reflect.TypeOf((*ScheduledActionArrayInput)(nil)).Elem(), ScheduledActionArray{}) 468 pulumi.RegisterInputType(reflect.TypeOf((*ScheduledActionMapInput)(nil)).Elem(), ScheduledActionMap{}) 469 pulumi.RegisterOutputType(ScheduledActionOutput{}) 470 pulumi.RegisterOutputType(ScheduledActionArrayOutput{}) 471 pulumi.RegisterOutputType(ScheduledActionMapOutput{}) 472 }