Skip to content

Instantly share code, notes, and snippets.

@GMKBabu
GMKBabu / opt1_template.j2
Created May 17, 2019 19:12 — forked from halberom/opt1_template.j2
ansible - example of template if else
{# style 1 - long form #}
{% if filepath == '/var/opt/tomcat_1' %}
{% set tomcat_value = tomcat_1_value %}
{% else %}
{% set tomcat_value = tomcat_2_value %}
{% endif %}
{# style 2 - short form #}
{% set tomcat_value = tomcat_1_value if (filepath == '/var/opt/tomcat_1') else tomcat_2_value %}
@GMKBabu
GMKBabu / test.tf
Created July 15, 2019 05:00 — forked from joestump/test.tf
Trigger AWS CodePipeline with a GitHub webhook using Terraform
provider "aws" {}
provider "github" {}
resource "github_repository" "test" {
name = "joestump-test"
description = "Terraform test repository"
private = true
}
resource "aws_s3_bucket" "test" {
@GMKBabu
GMKBabu / ec2_info_retriever.py
Created August 30, 2019 11:34 — forked from dastergon/ec2_info_retriever.py
A basic boto3 based tool for retrieving information from running EC2 instances.
from collections import defaultdict
import boto3
"""
A tool for retrieving basic information from the running EC2 instances.
"""
# Connect to EC2
ec2 = boto3.resource('ec2')
[https://computingforgeeks.com/install-ansible-awx-on-centos-7-fedora-with-nginx-reverse-proxy-letsencrypt/]
###Appendix: Let's Encrypt with Certbot on Amazon Linux
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-an-instance.html#letsencrypt
# Insall EPEL repository
yum -y install epel-release
@GMKBabu
GMKBabu / Terraform_functions.md
Created September 4, 2019 09:18 — forked from davewongillies/Terraform_functions.md
Terraform Functions

Supported built-in functions

  • abs(float) - Returns the absolute value of a given float. Example: abs(1) returns 1, and abs(-1) would also return 1, whereas abs(-3.14) would return 3.14. See also the signum function.

  • basename(path) - Returns the last element of a path.

  • base64decode(string) - Given a base64-encoded string, decodes it and returns the original string.

@GMKBabu
GMKBabu / awc-ecs-access-to-aws-efs.md
Created September 4, 2019 13:00 — forked from duluca/awc-ecs-access-to-aws-efs.md
Step-by-step Instructions to Setup an AWS ECS Cluster

Configuring AWS ECS to have access to AWS EFS

If you would like to persist data from your ECS containers, i.e. hosting databases like MySQL or MongoDB with Docker, you need to ensure that you can mount the data directory of the database in the container to volume that's not going to dissappear when your container or worse yet, the EC2 instance that hosts your containers, is restarted or scaled up or down for any reason.

Don't know how to create your own AWS ECS Cluster? Go here!

New Cluster

Sadly the EC2 provisioning process doesn't allow you to configure EFS during the initial config. After your create your cluster, follow the guide below.

New Task Definition for Web App

If you're using an Alpine-based Node server like duluca/minimal-node-web-server follow this guide:

provider "aws" {
region = "us-west-2"
}
resource "aws_s3_bucket" "mybucket" {
bucket = "mys3bucket-withkms-serverside-encryption"
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
kms_master_key_id = "${var.kms_key}"
@GMKBabu
GMKBabu / ASL
Created November 6, 2019 08:32 — forked from djg07/ASL
{
"Comment": "A simple AWS Step Functions state machine that automates a call center support session.",
"StartAt": "ProcessTransaction",
"States": {
"ProcessTransaction": {
"Type" : "Choice",
"Choices": [
{
"Variable": "$.TransactionType",
"StringEquals": "PURCHASE",
@GMKBabu
GMKBabu / vpc-fargate.yaml
Created November 19, 2019 09:41 — forked from lizrice/vpc-fargate.yaml
Cloudformation template for setting up VPC and subnets for Fargate
# Usage:
# aws cloudformation --region <region> create-stack --stack-name <stack name> --template-body file://vpc-fargate.yaml
# This template will:
# Create a VPC with:
# 2 Public Subnets
# 2 Private Subnets
# An Internet Gateway (with routes to it for Public Subnets)
# A NAT Gateway for outbound access (with routes from Private Subnets set to use it)
#
@GMKBabu
GMKBabu / Simple-S3Bucket-SNS
Created November 23, 2019 06:37 — forked from austoonz/Simple-S3Bucket-SNS
A CloudFormation template sample for creating an S3 Bucket with an SNS Trigger.
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Simple S3 Bucket with SNS Trigger
Parameters:
BucketName:
Type: String
Description: The name of the S3 Bucket to create