Skip to content

Instantly share code, notes, and snippets.

View lekansogunle's full-sized avatar

Olalekan Tosin Sogunle lekansogunle

View GitHub Profile
service: init-user
frameworkVersion: '2'
provider:
name: aws
runtime: nodejs12.x
functions:
hello:
handler: handler.initUser
language: node_js
node_js:
- "10"
cache:
directories:
- node_modules
- ${SERVICE_PATH}/node_modules
install:
- yarn global add serverless
- travis_retry yarn install
#!/usr/bin/env bash
cd ${SERVICE_PATH}
serverless deploy -s ${STAGE_NAME}
cd -
const handler = require('../handler');
test('correctly create post', () => {
expect(handler.createPost({foo: 'bar'})).toStrictEqual({
statusCode: 200,
body: JSON.stringify(
{
message: 'Hello From Create Post!',
input: {foo: 'bar'},
},
'use strict';
module.exports.createPost = event => {
return {
statusCode: 200,
body: JSON.stringify(
{
message: 'Hello From Create Post!',
input: event,
},
resource "aws_security_group" "instance" {
name = "openvpn-default"
description = "OpenVPN security group"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
resource "aws_instance" "openvpn" {
ami = local.images[var.server_region]
instance_type = "t2.micro"
vpc_security_group_ids = [aws_security_group.instance.id]
user_data = <<-EOF
admin_user=${var.server_username}
admin_pw=${var.server_password}
EOF
locals {
images = {
us-east-1 = "ami-037ff6453f0855c46"
eu-central-1 = "ami-0764964fdfe99bc31"
ap-northeast-1 = "ami-04f47c2ec43830d77"
}
}
output "access_vpn_url" {
value = "https://${aws_instance.openvpn.public_ip}:943/admin"
description = "The public url address of the vpn server"
}
provider "aws" {
region = var.server_region
}