Giter VIP home page Giter VIP logo

amazon-redshift-auto-pause's Introduction

Overview

Customers who use Redshift on-demand may need a mechanism to pause their Redshift cluster when it’s not in use. This project shows how you can use lambda to auto-pause your Redshift Cluster. It will check for user activity using a user-defined interval and if there is no activity, the cluster will be paused.

Architecture

This solution leverages the following components:

  1. Cloudwatch Event to schedule the execution of the Lambda function.
  2. A Lambda function which:
    1. Connects to Amazon Redshift via the Redshift Data API and checks if there has been any activity since the last execution and logs the result in the autopause_log table.
    2. If there was activity, it exits.
    3. If there was no activity, it uses the Redshift Admin API to execute the pause_cluster command.

Cloud Formation

You can deploy this solution using a Cloud Formation Template. Which will expect the following inputs:

  • Cluster - The Amazon Redshift cluster name.
  • Database - The name of the database which will be used in the connection.
  • User - The user which will be used to check for activity.
  • Schedule - The frequency to check for activity. E.g. rate(1 hour)
  • Topic - (Optional) If populated, will send a message to the SNS Topic when the cluster is paused.
  • Email - (Optional) If populated, will create a new SNS topic using the above Topic Name along with a subscription using this Email address.

For newly created topic/email, confirm the email subscription in order to receive notifications.

The template will create the following objects:

  • Log Table - this will be created within the Redshift Cluster and will log execution and entries where the cluster was paused.
  • Lambda Function - the function which will orchestrate the logic
  • IAM Role - the role needed by the lambda function to execute, log, and perform Redshift functions. The permissions for this role will be scoped to only provide access to the Redshift Cluster provided in the CFN template. The role will include a trust relationship to assume allowing lambda to assume this role.
  • Cloudwatch Event Rule - the component which will schedule the activity checks. This rule will pass in the parameters specified in the CFN template.

amazon-redshift-auto-pause's People

Contributors

rjvgupta avatar amazon-auto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.