ScheduledAction class

Example Usage

Pause Cluster Action

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const assumeRole = aws.iam.getPolicyDocument({
    statements: [{
        principals: [{
            type: "Service",
            identifiers: ["scheduler.redshift.amazonaws.com"],
        }],
        effect: "Allow",
        actions: ["sts:AssumeRole"],
    }],
});
const exampleRole = new aws.iam.Role("example", {
    name: "redshift_scheduled_action",
    assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json),
});
const example = aws.iam.getPolicyDocument({
    statements: [{
        effect: "Allow",
        actions: [
            "redshift:PauseCluster",
            "redshift:ResumeCluster",
            "redshift:ResizeCluster",
        ],
        resources: ["*"],
    }],
});
const examplePolicy = new aws.iam.Policy("example", {
    name: "redshift_scheduled_action",
    policy: example.then(example => example.json),
});
const exampleRolePolicyAttachment = new aws.iam.RolePolicyAttachment("example", {
    policyArn: examplePolicy.arn,
    role: exampleRole.name,
});
const exampleScheduledAction = new aws.redshift.ScheduledAction("example", {
    targetAction: {
        pauseCluster: {
            clusterIdentifier: "tf-redshift001",
        },
    },
    name: "tf-redshift-scheduled-action",
    schedule: "cron(00 23 * * ? *)",
    iamRole: exampleRole.arn,
});
import pulumi
import pulumi_aws as aws

assume_role = aws.iam.get_policy_document(statements=[{
    "principals": [{
        "type": "Service",
        "identifiers": ["scheduler.redshift.amazonaws.com"],
    }],
    "effect": "Allow",
    "actions": ["sts:AssumeRole"],
}])
example_role = aws.iam.Role("example",
    name="redshift_scheduled_action",
    assume_role_policy=assume_role.json)
example = aws.iam.get_policy_document(statements=[{
    "effect": "Allow",
    "actions": [
        "redshift:PauseCluster",
        "redshift:ResumeCluster",
        "redshift:ResizeCluster",
    ],
    "resources": ["*"],
}])
example_policy = aws.iam.Policy("example",
    name="redshift_scheduled_action",
    policy=example.json)
example_role_policy_attachment = aws.iam.RolePolicyAttachment("example",
    policy_arn=example_policy.arn,
    role=example_role.name)
example_scheduled_action = aws.redshift.ScheduledAction("example",
    target_action={
        "pause_cluster": {
            "cluster_identifier": "tf-redshift001",
        },
    },
    name="tf-redshift-scheduled-action",
    schedule="cron(00 23 * * ? *)",
    iam_role=example_role.arn)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var assumeRole = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "Service",
                        Identifiers = new[]
                        {
                            "scheduler.redshift.amazonaws.com",
                        },
                    },
                },
                Effect = "Allow",
                Actions = new[]
                {
                    "sts:AssumeRole",
                },
            },
        },
    });

    var exampleRole = new Aws.Iam.Role("example", new()
    {
        Name = "redshift_scheduled_action",
        AssumeRolePolicy = assumeRole.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

    var example = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Effect = "Allow",
                Actions = new[]
                {
                    "redshift:PauseCluster",
                    "redshift:ResumeCluster",
                    "redshift:ResizeCluster",
                },
                Resources = new[]
                {
                    "*",
                },
            },
        },
    });

    var examplePolicy = new Aws.Iam.Policy("example", new()
    {
        Name = "redshift_scheduled_action",
        PolicyDocument = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

    var exampleRolePolicyAttachment = new Aws.Iam.RolePolicyAttachment("example", new()
    {
        PolicyArn = examplePolicy.Arn,
        Role = exampleRole.Name,
    });

    var exampleScheduledAction = new Aws.RedShift.ScheduledAction("example", new()
    {
        TargetAction = new Aws.RedShift.Inputs.ScheduledActionTargetActionArgs
        {
            PauseCluster = new Aws.RedShift.Inputs.ScheduledActionTargetActionPauseClusterArgs
            {
                ClusterIdentifier = "tf-redshift001",
            },
        },
        Name = "tf-redshift-scheduled-action",
        Schedule = "cron(00 23 * * ? *)",
        IamRole = exampleRole.Arn,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/redshift"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Type: "Service",
							Identifiers: []string{
								"scheduler.redshift.amazonaws.com",
							},
						},
					},
					Effect: pulumi.StringRef("Allow"),
					Actions: []string{
						"sts:AssumeRole",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		exampleRole, err := iam.NewRole(ctx, "example", &iam.RoleArgs{
			Name:             pulumi.String("redshift_scheduled_action"),
			AssumeRolePolicy: pulumi.String(assumeRole.Json),
		})
		if err != nil {
			return err
		}
		example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Effect: pulumi.StringRef("Allow"),
					Actions: []string{
						"redshift:PauseCluster",
						"redshift:ResumeCluster",
						"redshift:ResizeCluster",
					},
					Resources: []string{
						"*",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		examplePolicy, err := iam.NewPolicy(ctx, "example", &iam.PolicyArgs{
			Name:   pulumi.String("redshift_scheduled_action"),
			Policy: pulumi.String(example.Json),
		})
		if err != nil {
			return err
		}
		_, err = iam.NewRolePolicyAttachment(ctx, "example", &iam.RolePolicyAttachmentArgs{
			PolicyArn: examplePolicy.Arn,
			Role:      exampleRole.Name,
		})
		if err != nil {
			return err
		}
		_, err = redshift.NewScheduledAction(ctx, "example", &redshift.ScheduledActionArgs{
			TargetAction: &redshift.ScheduledActionTargetActionArgs{
				PauseCluster: &redshift.ScheduledActionTargetActionPauseClusterArgs{
					ClusterIdentifier: pulumi.String("tf-redshift001"),
				},
			},
			Name:     pulumi.String("tf-redshift-scheduled-action"),
			Schedule: pulumi.String("cron(00 23 * * ? *)"),
			IamRole:  exampleRole.Arn,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "assumeRole" {
  statements {
    principals {
      type        = "Service"
      identifiers = ["scheduler.redshift.amazonaws.com"]
    }
    effect  = "Allow"
    actions = ["sts:AssumeRole"]
  }
}
data "aws_iam_getpolicydocument" "example" {
  statements {
    effect    = "Allow"
    actions   = ["redshift:PauseCluster", "redshift:ResumeCluster", "redshift:ResizeCluster"]
    resources = ["*"]
  }
}

resource "aws_iam_role" "example" {
  name               = "redshift_scheduled_action"
  assume_role_policy = data.aws_iam_getpolicydocument.assumeRole.json
}
resource "aws_iam_policy" "example" {
  name   = "redshift_scheduled_action"
  policy = data.aws_iam_getpolicydocument.example.json
}
resource "aws_iam_rolepolicyattachment" "example" {
  policy_arn = aws_iam_policy.example.arn
  role       = aws_iam_role.example.name
}
resource "aws_redshift_scheduledaction" "example" {
  target_action = {
    pause_cluster = {
      cluster_identifier = "tf-redshift001"
    }
  }
  name     = "tf-redshift-scheduled-action"
  schedule = "cron(00 23 * * ? *)"
  iam_role = aws_iam_role.example.arn
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.Policy;
import com.pulumi.aws.iam.PolicyArgs;
import com.pulumi.aws.iam.RolePolicyAttachment;
import com.pulumi.aws.iam.RolePolicyAttachmentArgs;
import com.pulumi.aws.redshift.ScheduledAction;
import com.pulumi.aws.redshift.ScheduledActionArgs;
import com.pulumi.aws.redshift.inputs.ScheduledActionTargetActionArgs;
import com.pulumi.aws.redshift.inputs.ScheduledActionTargetActionPauseClusterArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var assumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("Service")
                    .identifiers("scheduler.redshift.amazonaws.com")
                    .build())
                .effect("Allow")
                .actions("sts:AssumeRole")
                .build())
            .build());

        var exampleRole = new Role("exampleRole", RoleArgs.builder()
            .name("redshift_scheduled_action")
            .assumeRolePolicy(assumeRole.json())
            .build());

        final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .effect("Allow")
                .actions(
                    "redshift:PauseCluster",
                    "redshift:ResumeCluster",
                    "redshift:ResizeCluster")
                .resources("*")
                .build())
            .build());

        var examplePolicy = new Policy("examplePolicy", PolicyArgs.builder()
            .name("redshift_scheduled_action")
            .policy(example.json())
            .build());

        var exampleRolePolicyAttachment = new RolePolicyAttachment("exampleRolePolicyAttachment", RolePolicyAttachmentArgs.builder()
            .policyArn(examplePolicy.arn())
            .role(exampleRole.name())
            .build());

        var exampleScheduledAction = new ScheduledAction("exampleScheduledAction", ScheduledActionArgs.builder()
            .targetAction(ScheduledActionTargetActionArgs.builder()
                .pauseCluster(ScheduledActionTargetActionPauseClusterArgs.builder()
                    .clusterIdentifier("tf-redshift001")
                    .build())
                .build())
            .name("tf-redshift-scheduled-action")
            .schedule("cron(00 23 * * ? *)")
            .iamRole(exampleRole.arn())
            .build());

    }
}
resources:
  exampleRole:
    type: aws:iam:Role
    name: example
    properties:
      name: redshift_scheduled_action
      assumeRolePolicy: ${assumeRole.json}
  examplePolicy:
    type: aws:iam:Policy
    name: example
    properties:
      name: redshift_scheduled_action
      policy: ${example.json}
  exampleRolePolicyAttachment:
    type: aws:iam:RolePolicyAttachment
    name: example
    properties:
      policyArn: ${examplePolicy.arn}
      role: ${exampleRole.name}
  exampleScheduledAction:
    type: aws:redshift:ScheduledAction
    name: example
    properties:
      targetAction:
        pauseCluster:
          clusterIdentifier: tf-redshift001
      name: tf-redshift-scheduled-action
      schedule: cron(00 23 * * ? *)
      iamRole: ${exampleRole.arn}
variables:
  assumeRole:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - principals:
              - type: Service
                identifiers:
                  - scheduler.redshift.amazonaws.com
            effect: Allow
            actions:
              - sts:AssumeRole
  example:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - effect: Allow
            actions:
              - redshift:PauseCluster
              - redshift:ResumeCluster
              - redshift:ResizeCluster
            resources:
              - '*'

Resize Cluster Action

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.redshift.ScheduledAction("example", {
    targetAction: {
        resizeCluster: {
            clusterIdentifier: "tf-redshift001",
            clusterType: "multi-node",
            nodeType: "dc1.large",
            numberOfNodes: 2,
        },
    },
    name: "tf-redshift-scheduled-action",
    schedule: "cron(00 23 * * ? *)",
    iamRole: exampleAwsIamRole.arn,
});
import pulumi
import pulumi_aws as aws

example = aws.redshift.ScheduledAction("example",
    target_action={
        "resize_cluster": {
            "cluster_identifier": "tf-redshift001",
            "cluster_type": "multi-node",
            "node_type": "dc1.large",
            "number_of_nodes": 2,
        },
    },
    name="tf-redshift-scheduled-action",
    schedule="cron(00 23 * * ? *)",
    iam_role=example_aws_iam_role["arn"])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.RedShift.ScheduledAction("example", new()
    {
        TargetAction = new Aws.RedShift.Inputs.ScheduledActionTargetActionArgs
        {
            ResizeCluster = new Aws.RedShift.Inputs.ScheduledActionTargetActionResizeClusterArgs
            {
                ClusterIdentifier = "tf-redshift001",
                ClusterType = "multi-node",
                NodeType = "dc1.large",
                NumberOfNodes = 2,
            },
        },
        Name = "tf-redshift-scheduled-action",
        Schedule = "cron(00 23 * * ? *)",
        IamRole = exampleAwsIamRole.Arn,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/redshift"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := redshift.NewScheduledAction(ctx, "example", &redshift.ScheduledActionArgs{
			TargetAction: &redshift.ScheduledActionTargetActionArgs{
				ResizeCluster: &redshift.ScheduledActionTargetActionResizeClusterArgs{
					ClusterIdentifier: pulumi.String("tf-redshift001"),
					ClusterType:       pulumi.String("multi-node"),
					NodeType:          pulumi.String("dc1.large"),
					NumberOfNodes:     pulumi.Int(2),
				},
			},
			Name:     pulumi.String("tf-redshift-scheduled-action"),
			Schedule: pulumi.String("cron(00 23 * * ? *)"),
			IamRole:  pulumi.Any(exampleAwsIamRole.Arn),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_redshift_scheduledaction" "example" {
  target_action = {
    resize_cluster = {
      cluster_identifier = "tf-redshift001"
      cluster_type       = "multi-node"
      node_type          = "dc1.large"
      number_of_nodes    = 2
    }
  }
  name     = "tf-redshift-scheduled-action"
  schedule = "cron(00 23 * * ? *)"
  iam_role = exampleAwsIamRole.arn
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.redshift.ScheduledAction;
import com.pulumi.aws.redshift.ScheduledActionArgs;
import com.pulumi.aws.redshift.inputs.ScheduledActionTargetActionArgs;
import com.pulumi.aws.redshift.inputs.ScheduledActionTargetActionResizeClusterArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new ScheduledAction("example", ScheduledActionArgs.builder()
            .targetAction(ScheduledActionTargetActionArgs.builder()
                .resizeCluster(ScheduledActionTargetActionResizeClusterArgs.builder()
                    .clusterIdentifier("tf-redshift001")
                    .clusterType("multi-node")
                    .nodeType("dc1.large")
                    .numberOfNodes(2)
                    .build())
                .build())
            .name("tf-redshift-scheduled-action")
            .schedule("cron(00 23 * * ? *)")
            .iamRole(exampleAwsIamRole.arn())
            .build());

    }
}
resources:
  example:
    type: aws:redshift:ScheduledAction
    properties:
      targetAction:
        resizeCluster:
          clusterIdentifier: tf-redshift001
          clusterType: multi-node
          nodeType: dc1.large
          numberOfNodes: 2
      name: tf-redshift-scheduled-action
      schedule: cron(00 23 * * ? *)
      iamRole: ${exampleAwsIamRole.arn}

Import

Using pulumi import, import Redshift Scheduled Action using the name. For example:

$ pulumi import aws:redshift/scheduledAction:ScheduledAction example tf-redshift-scheduled-action

Constructors

ScheduledAction(String name, {ScheduledActionArgs? args, CustomResourceOptions? options})
Creates a new ScheduledAction. name The Pulumi resource name. args Arguments used to configure this ScheduledAction. The set of arguments for ScheduledAction. options Resource options controlling this resource's behavior.
ScheduledAction.reference(String urn)
Creates a typed reference to an existing ScheduledAction resource.

Properties

childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
description ↔ Output<String?>
The description of the scheduled action.
latefinal
enable ↔ Output<bool?>
Whether to enable the scheduled action. Default is true .
latefinal
endTime ↔ Output<String?>
The end time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ).
latefinal
hashCode → int
The hash code for this object.
no setterinherited
iamRole ↔ Output<String>
The IAM role to assume to run the scheduled action.
latefinal
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
name ↔ Output<String>
The scheduled action name.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
schedule ↔ Output<String>
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 for more information.
latefinal
startTime ↔ Output<String?>
The start time in UTC when the schedule is active, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ).
latefinal
targetAction ↔ Output<ScheduledActionTargetAction>
Target action. Documented below.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {ScheduledActionState? state, CustomResourceOptions? options}) → ScheduledAction
Gets an existing ScheduledAction resource's state with the given name and id.