Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOG-4540 - Rewritten lambda to use more efficient API calls #2

Merged
merged 3 commits into from Jan 30, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Updated readme

  • Loading branch information
Jiri Tomek
Jiri Tomek committed May 23, 2019
commit e16d192aa23c079efcb816fa0d865746c1c5bcc7
@@ -11,52 +11,52 @@ article](https://docs.aws.amazon.com/lambda/latest/dg/getting-started.html). The

## Creating lambda function in AWS
1. Build lambda function code
1. Clone the Git repository:
* Clone the Git repository:
`git clone https://github.com/psquickitjayant/cloudwatch-metrics-to-loggly.git`
1. Go to cloned folder:
* Go to cloned folder:
`cd cloudwatch-metrics-to-loggly`
1. Install dependencies:
* Install dependencies:
`npm install`
1. Create a .zip file for upload to AWS console later:
* Create a .zip file for upload to AWS console later:
`zip -r cloudwatchMetrics2Loggly.zip index.js node_modules`
1. Create Role
1. Sign in to your AWS account and open IAM console https://console.aws.amazon.com/iam/
2. In your IAM console create a new Role say, `cloudwatch-full-access`
3. Select Role Type as **AWS Lambda**
4. Apply policy **CloudWatchFullAccess** and save.
* Sign in to your AWS account and open IAM console https://console.aws.amazon.com/iam/
* In your IAM console create a new Role say, `cloudwatch-full-access`
* Select Role Type as **AWS Lambda**
* Apply policy **CloudWatchFullAccess** and save.
1. Create KMS Key
1. Create a KMS key - http://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html
1. Encrypt the Loggly Customer Token using the AWS CLI
* Create a KMS key - http://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html
* Encrypt the Loggly Customer Token using the AWS CLI
`aws kms encrypt --key-id alias/<your KMS key alias> --plaintext "<your loggly customer token>"`
1. Copy or keep `CiphertextBlob` attribute for furhter usage in the next step.
* Copy or keep `CiphertextBlob` attribute for furhter usage in the next step.
1. Create lambda function
1. Go to https://console.aws.amazon.com/lambda/home
1. Click **Create a Lambda function** button.
1. Select **Author from scratch** option
1. Set **Function name** for example to `cloudwatchMetrics2Loggly`
1. Set **Runtime** to `Node.js 10.x`
1. Under **Permissions** click on **Choose or create an execution role**
1. Select **Use an existing role** and select **cloudwatch-full-access** role created above in step 1
1. Click on **Create function** button
1. Scroll to **Function code** section
1. Select **Upload a .zip file** in **Code entry type** dropdown
1. Upload lambda function (zip file `cloudwatchMetrics2Loggly.zip` you made above)
1. Go to **Environment variables** section
1. Define new environment variable **kmsEncryptedCustomerToken** and set it to `CiphertextBlob` value from step 3 above (Create KMS Key)
1. Scroll to **Basic settings** section
1. Set **Memory (MB)** to **512 MB**
1. Set Timeout to **2** minutes
1. Scroll up to **Designer** section (expand if it's collapsed)
1. Click on **CloudWatch Events** in **Add triggers** section to add the trigger item
1. Click on added **CloudWatch Events** trigger and scroll down to trigger settings
1. Select **Create a new rule** in **Rule** dropdown
1. **Name:** Provide any customized name. e.g. cloudwatchMetrics2Loggly Event Source
1. **Description:** Invokes Lambda function in every 5 minutes
1. **Schedule expression:** rate(5 minutes)
1. Make sure the checkbox **Enable trigger** is checked
1. Click on **Add**
1. Click on **Save** to save the whole lambda function.
1. Wait for the events to occur in Loggly
* Go to https://console.aws.amazon.com/lambda/home
* Click **Create a Lambda function** button.
* Select **Author from scratch** option
* Set **Function name** for example to `cloudwatchMetrics2Loggly`
* Set **Runtime** to `Node.js 10.x`
* Under **Permissions** click on **Choose or create an execution role**
* Select **Use an existing role** and select **cloudwatch-full-access** role created above in step 1
* Click on **Create function** button
* Scroll to **Function code** section
* Select **Upload a .zip file** in **Code entry type** dropdown
* Upload lambda function (zip file `cloudwatchMetrics2Loggly.zip` you made above)
* Go to **Environment variables** section
* Define new environment variable **kmsEncryptedCustomerToken** and set it to `CiphertextBlob` value from step 3 above (Create KMS Key)
* Scroll to **Basic settings** section
* Set **Memory (MB)** to **512 MB**
* Set Timeout to **2** minutes
* Scroll up to **Designer** section (expand if it's collapsed)
* Click on **CloudWatch Events** in **Add triggers** section to add the trigger item
* Click on added **CloudWatch Events** trigger and scroll down to trigger settings
* Select **Create a new rule** in **Rule** dropdown
* **Name:** Provide any customized name. e.g. cloudwatchMetrics2Loggly Event Source
* **Description:** Invokes Lambda function in every 5 minutes
* **Schedule expression:** rate(5 minutes)
* Make sure the checkbox **Enable trigger** is checked
* Click on **Add**
* Click on **Save** to save the whole lambda function.
* Wait for the events to occur in Loggly

**NOTE**: Always use latest version of **AWSCLI**. Some features like KMS may not work on older versions of AWSCLI. To upgrade, use the command given below

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.