Skip to content

Instantly share code, notes, and snippets.

@lmakarov
lmakarov / lambda-basic-auth.js
Created August 30, 2017 19:15
Basic HTTP Authentication for CloudFront with Lambda@Edge
'use strict';
exports.handler = (event, context, callback) => {
// Get request and request headers
const request = event.Records[0].cf.request;
const headers = request.headers;
// Configure authentication
const authUser = 'user';
const authPass = 'pass';
@iMilnb
iMilnb / README.md
Last active January 18, 2024 08:08
AWS Terraform configuration: Stream CloudWatch Logs to ElasticSearch

Rationale

This snippet is a sample showing how to implement CloudWatch Logs streaming to ElasticSearch using terraform. I wrote this gist because I didn't found a clear, end-to-end example on how to achieve this task. In particular, I understood the resource "aws_lambda_permission" "cloudwatch_allow" part by reading a couple of bug reports plus this stackoverflow post.

The js file is actually the Lambda function automatically created by AWS when creating this pipeline through the web console. I only added a endpoint variable handling so it is configurable from terraform.

@davidski
davidski / elk-opsworks-stack.json
Created January 3, 2016 19:21
Elasticsearch-Logstash-Kibana Opsworks stack creation via CloudFormation
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Create the ELK OpsWorks Stack.",
"Metadata": {
"AWS::CloudFormation::Interface": {
"ParameterGroups": [{
"Label": { "default": "Network"},
"Parameters": [ "VpcID", "SubnetID", "KeyName" ]
}, {
"Label": { "default": "ELK Config"},