Coder Social home page Coder Social logo

amazon-archives / aws-lambda-java-awshealth-check Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 13.0 296 KB

Java SAM Lambda module for periodically checking AWS Health API for both general AWS Service issues and customer specific system maintenance events and notify via SES if updates are found.

License: MIT No Attribution

Dockerfile 1.01% Shell 2.87% Java 96.12%

aws-lambda-java-awshealth-check's Introduction

AWS Lambda Java module for periodic checking of new AWS Health events

Java SAM Lambda module for periodical checking of AWS Health API for new events and notify via SES if updates are found.

screenshot

License Summary

This sample code is made available under a modified MIT license. See the LICENSE file.

AWS Costs

AWS Lambda Invocation (Usually Free https://aws.amazon.com/free/)
Amazon SES (Usually Free https://aws.amazon.com/free/)
Minimal Amazon S3 Usage
AWS Support for AWS Health API access (Requires at least Business Support Plan)
https://aws.amazon.com/premiumsupport/pricing

Prerequisites

awscli - https://aws.amazon.com/cli/

configure AWS credentials for target account
aws configure

Verified Amazon SES Sender email
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html
If you verify an email, you can send from/to that address. To send to other addresses, you need to move SES out of sandbox mode:
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/request-production-access.html

Docker (For building the Java jar package with the necessary dependencies) - https://www.docker.com/

Building

Run build.sh to build a new lambda deployment package. This requires Docker, as it builds the package in an Amazon Linux container.

sh build.sh

Deploying (SAM / Script)

Update the values in deploy.sh for your AWS account details.
CONFIG_BUCKET: S3 Bucket to use for storing the deployment artifacts CONFIG_FILE: Configuration file name
BUCKET: Bucket for -

  1. Keeping previous AWS Health API call result history and SHA256 fingerprint for the last Health API call result that had returned events.

And then run deploy.sh

sh deploy.sh

Deploy Manually (Lambda Console)

  1. Create a lambda function (Java 8 runtime)
  2. Create a lambda IAM execution role with ses:, s3:, organizations:DescribeAccount:, health:
  3. Upload to console from AWSHealthCheck-1.0-SNAPSHOT.jar produced by running 'build.sh'.
  4. Update ENV Variables in Lambda console
    CONFIG_FILE: Configuration file name
    DEFAULT_REGION: Bucket Region
    BUCKET: Bucket for storing previous AWS Health API call history and SHA256 fingerprint.
  5. Create a trigger (CloudWatch Event)

Manually Running / Testing

Once the lambda is created, find it in the AWS Lambda console.
You can create a test event with any test event parameter(this solution does not parse passed in Lambda parameter) for manual/user-initiated execution.

{}

https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-test-function.html

Customize the settings

Edit the contents of src/config.yaml

# Refer to https://docs.aws.amazon.com/health/latest/APIReference/API_EventFilter.html for limitations of filter
# Regions to check for the AWSHealth API data (cannot exceed 10)
regions:
  - "ap-northeast-1"
  - "ap-northeast-2"
#  - "ap-northeast-3"
#  - "ap-south-1"
#  - "ap-southeast-1"
#  - "ap-southeast-2"
#  - "ca-central-1"
#  - "eu-central-1"
  - "eu-west-1"
#  - "eu-west-2"
#  - "eu-west-3"
#  - "sa-east-1"
  - "us-east-1"
  - "us-east-2"
  - "us-west-1"
  - "us-west-2"

# Category to check for the AWSHealth API data
category:
  - "issue"
  - "scheduledChange"
  - "accountNotification"

# Status codes to check for for the AWSHealth API data
status:
  - "open"
  - "upcoming"
#  - "closed"

# Resource tags to filter for for the AWSHealth API data
tags:
#  - {"key": "value"}
#  - {"key2": "value"}

# SES settings
ses_region: "us-east-1"
ses_from: "changeme" # Sender
ses_send: "changeme" # Recipient list separated by comma

# Email template for sending blocked IP found notification.
email_template: "check-AWSHealth\n\n
New AWSHealth API update(s) found: \n\n
%s\n"

aws-lambda-java-awshealth-check's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.