Skip to content

Instantly share code, notes, and snippets.

View remie's full-sized avatar

Remie Bolte remie

View GitHub Profile
@remie
remie / aws-provision-cloudfront.ts
Created July 18, 2021 12:02
Using AWS CloudFront SDK to provision a distribution
const accessKeyId = process.env.AWS_ACCESS_KEY_ID;
const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
const client = new CloudFront({
credentials: async () => ({ accessKeyId, secretAccessKey }),
region: 'us-east-1'
});
const { Distribution } = await client.createDistribution({
DistributionConfig: {
Enabled: true,
@remie
remie / aws-provision-certificate.ts
Created July 18, 2021 11:54
Using AWS Certificate Manager SDK to provision a certificate
const accessKeyId = process.env.AWS_ACCESS_KEY_ID;
const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
const acm = new ACM({
credentials: async () => ({ accessKeyId, secretAccessKey }),
region: 'us-east-1'
});
const { CertificateArn } = await acm.requestCertificate({
DomainName: <<DOMAIN_NAME>>,
ValidationMethod: ValidationMethod.DNS
{
"name": "redirect-tests",
"version": "1.0.0",
"description": "test the httpd.config redirects",
"main": "redirect.tests.js",
"dependencies": {
"axios": "^0.18.0"
},
"devDependencies": {
"mocha": "^5.1.1"
#!/bin/bash
## Add an additional configuration file to Apache for testing purposes
echo "Include /usr/local/apache2/conf.d/redirect-test.conf" >> /usr/local/apache2/conf/httpd.conf;
cat >> /usr/local/apache2/conf.d/redirect-test.conf <<EOF
RewriteCond %{HTTP_HOST} ^example.org$ [NC]
RewriteRule ^/(.*)$ http://mydomain.com/$1 [R=302,L]
EOF
## Start Httpd
FROM httpd:alpine
## Installing NodeJS
RUN apk add --update nodejs
## Copy Apache redirect rules
COPY ./conf.d /usr/local/apache2/conf.d
COPY ./httpd.conf /usr/local/apache2/conf.d/redirect.conf
RUN echo "Include /usr/local/apache2/conf.d/redirect.conf" >> /usr/local/apache2/conf/httpd.conf;
##########################################################################
## Apache Configuration ##
##########################################################################
ServerSignature Off
ServerName redirect.mydomain.com
LoadModule rewrite_module modules/mod_rewrite.so
Include /usr/local/apache2/conf.d/urlrewrite.conf
##########################################################################
## Url rewrite ##
##########################################################################
RewriteEngine On
## Rewrite myotherdomain.com to mydomain.com
RewriteCond %{HTTP_HOST} ^myotherdomain.com$ [NC]
RewriteRule ^/(.*)$ http://mydomain.com/$1 [R=302,L]
## All other domains
const axios = require('axios');
// check(host, path, expectedRedirect, statusCode)
// {host}: the host header of the request (without http(s)://)
// {path}: the path after the host
// {expectedRedirect}: the full URL of the Location header that should be returned
// {statusCode}: the expected status code (optional, defaults to 302)
const check = function(host, path, expectedRedirect, statusCode) {
path = path || '';
import { Service, ServiceObj } from '@remie/nagios-cli';
@Service({
name: 'generic-service',
service_description: 'Generic Service',
active_checks_enabled: true,
passive_checks_enabled: true,
obsess_over_service: true,
check_freshness: false,
import BaseService from './BaseService';
import { Use, ServiceObj, Check } from '@remie/nagios-cli';
@Use(BaseService)
export class Service extends ServiceObj {
private _check: Check;
constructor(description: string, check: Check) {
super(description);