Skip to content

Instantly share code, notes, and snippets.

View ashwiniag's full-sized avatar

Ashwini Gaddagi ashwiniag

View GitHub Profile
@ashwiniag
ashwiniag / iam_user.sh
Last active April 20, 2020 05:17
To create/ delete AWS IAM user.
#aws_access_key_id and aws_secret_access_key are displayed just once hence note down it safely
#Just sharing the AWS-GK :P
#For each user only Two times aws_secret_access_key can be created.
# /bin/bash createuser.sh create_user/delete_user
#!/bin/bash
set -euo pipefail
declare -r aws_profile="<value>"
@ashwiniag
ashwiniag / ecs_service.tf
Last active April 17, 2020 06:20
An example to understand usage of Dynamic block.
variable "target_groups" {
type = list
default = ["xxx", "yyy"] #can be empty too
}
@ashwiniag
ashwiniag / AWS-param-store.sh
Created February 6, 2020 16:44
Add multi-AWS parameters with bash script
#1. Script adds environment vraiables with the parameter_name as: /project/env/parameter_name
# hence change script variables as per need.
#2. Save environment variables within file named vars.txt
#3. environment variables and its values should be seperated by spaces and NOT = symbol
# ex:
# name1 val1
# name2 val2
#4. command line: ./AWS-param-store.sh {env} {add / delete}
###########################################################################
version: 0.2
phases:
install:
commands:
runtime-versions:
java: openjdk11
pre_build:
commands:
- echo Login to ECR
@ashwiniag
ashwiniag / faragte.tf
Created November 24, 2019 07:07
Create ecs to run docker image
##############################################################
### ECSfargate
##############################################################
resource "aws_ecs_cluster" "hk-cluster-name" {
name ="ECR_cluster"
}
##############################################################
# Task definition for application to run
##############################################################
@ashwiniag
ashwiniag / vpc.tf
Created November 24, 2019 07:04
Create private network
##############################################################
# Once the image is build,run it inside your own private network
# (VPC) using Fargate
##############################################################
##############################################################
#Create VPC
##############################################################
resource "aws_vpc" "hk-vpc" {
cidr_block = "10.0.0.0/16"
tags = {
@ashwiniag
ashwiniag / iam.tf
Created November 24, 2019 06:58
IAM role and policy for codebuild
##############################################################
# Create a Role, attach policy to it.
#Allowing access to S3 and ECR aws resources
##############################################################
resource "aws_iam_role" "codebuild-role" {
name = "codebuild-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
@ashwiniag
ashwiniag / codebuild.tf
Created November 24, 2019 06:53
Create codebuild project, refers to .yml file present in source directory.
##############################################################
#create codeuild.
#define the right environment variables.
# Set the environment varaibles based on variable in .yml file
##############################################################
resource "aws_codebuild_project" "codebuild" {
name = "codebuild_project"
description = "codebuild to build java application push artifacts to s3 output bucket and docker image to ECR "
build_timeout = "5"
service_role = "${aws_iam_role.codebuild-role.name}"
@ashwiniag
ashwiniag / S3_bucket and ECR.tf
Last active November 24, 2019 06:57
Create S3 bucket and ECR repo
#Use aws provider and IAM User "name"
provider "aws" {
profile = "name"
region = "eu-west-2"
}
//
##############################################################
# Create S3 input bucket for storing application in zip format.
##############################################################
@ashwiniag
ashwiniag / Vagrantfile
Last active July 30, 2019 12:15
Creates a ubuntu vagrant and installs nginx with ansible
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at