Skip to content

Instantly share code, notes, and snippets.

View housni's full-sized avatar

Housni Yakoob housni

View GitHub Profile
@housni
housni / config.yaml
Created October 25, 2018 12:37
Verdaccio config file
#
# This is the config file used for the docker images.
# It allows all users to do anything, so don't use it on production systems.
#
# Do not configure host and port under `listen` in this file
# as it will be ignored when using docker.
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/conf
@housni
housni / bash-starter-template.sh
Last active October 29, 2018 18:40
My Bash script starter template
#!/usr/bin/env bash
# See: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# Set DEBUG to true for enhanced debugging: run prefixed with "DEBUG=true"
# Credits: https://github.com/ModusCreateOrg/devops-infra-demo
${DEBUG:-false} && set -o verbose; set -o xtrace
# Set CHECK to true to check script for syntax errors.
${CHECK:-false} && set -o noexec
$ aws apigateway test-invoke-method \
--rest-api-id 3obl3k5ugh \
--resource-id 5z8bpy \
--http-method GET \
--path-with-query-string '/test/path?key1=val1&key2=val2&key3=val3'
$ curl \
-X GET \
-s \
-w "%{url_effective}\n%{http_code}\n%{redirect_url}" \
"https://3obl3k5ugh.execute-api.us-east-1.amazonaws.com/Prod/test/path?key1=val1&key2=val2&key3=val3"
$ curl \
-X GET \
-s \
-w "%{url_effective}\n%{http_code}\n%{redirect_url}" \
"https://3obl3k5ugh.execute-api.us-east-1.amazonaws.com/Prod"
https://3obl3k5ugh.execute-api.us-east-1.amazonaws.com/Prod
302
$ aws cloudformation package \
--template-file app_spec.yml \
--output-template-file packaged.yml \
--s3-bucket MyRedirectorBucket
Successfully packaged artifacts and wrote output template to file packaged.yml.
Execute the following command to deploy the packaged template
aws cloudformation deploy --template-file /home/housni/modus-create/lambda-redirector/packaged.yml --stack-name <YOUR STACK NAME>
$ aws cloudformation deploy \
--template-file packaged.yml \
--stack-name Redirector \
---
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
HTTPResponse:
Type: Number
Default: 302
AllowedValues: [301, 302]
Description: "The HTTP response status code."
NewDomain:
$ curl \
-X GET \
-s \
-w "%{url_effective}\n%{http_code}\n%{redirect_url}" \
"https://3obl3k5ugh.execute-api.us-east-1.amazonaws.com/Prod"
https://3obl3k5ugh.execute-api.us-east-1.amazonaws.com/Prod
301
http://example.org
$ aws cloudformation package \
--template-file app_spec.yml \
--output-template-file packaged.yml \
--s3-bucket MyRedirectorBucket
Successfully packaged artifacts and wrote output template to file packaged.yml.
Execute the following command to deploy the packaged template
aws cloudformation deploy --template-file /home/housni/modus-create/lambda-redirector/packaged.yml --stack-name <YOUR STACK NAME>
$ aws cloudformation deploy \
---
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
GetFunction:
Type: AWS::Serverless::Function
Properties:
Description: "Handles GET requests."
Handler: get.handler
Runtime: nodejs6.10