Skip to content

Instantly share code, notes, and snippets.

View giuliocalzolari's full-sized avatar

Giulio Calzolari giuliocalzolari

View GitHub Profile
@giuliocalzolari
giuliocalzolari / linux-vmimport_checker.sh
Last active May 8, 2024 15:20
AWS IMPORT VM Checker
#!/bin/bash
##########################################################################################
# AWS VM Import Instance Checker 1.2 #
# #
# The script has been implemented to simplify the VM Import process of the virtual #
# environment in AWS. #
# #
# The script checks that the requirements to import a VM in AWS are verified. #
# Please make a backup of the VM before to proceed. #
@giuliocalzolari
giuliocalzolari / Cloudwatch Agent Install
Last active April 29, 2024 03:08 — forked from naavveenn/Cloudwatch Agent Install
Cloudwatch agent installation: Make sure to attach a cloudwatch role to your ec2 instance. amazon-cloudwatch-agent.json file should be created before hand (on your local machine or from where you are executing your ansible playbook), other wise cw_agent will not start. Below is the example of amazon-cloudwatch-agent.json.
---
###Cloudwatch role should be attached to the ec2 instance###
- hosts: dd ###servers on which you need to run the cw_agent
become: yes
remote_user: root
gather_facts: true
tasks:
- name: Check if Cloudwatch Agent is Installed Already
shell: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status
register: init_status_result
@giuliocalzolari
giuliocalzolari / nginx.conf
Created February 7, 2018 15:05
Using nginx to proxy to an AWS internal ELB
daemon off;
worker_processes auto;
events { worker_connections 1024; }
http {
sendfile on;
@giuliocalzolari
giuliocalzolari / vault-acme-plugin.sh
Last active June 13, 2022 07:21
Vault + Let's encrypt integration
# source https://github.com/remilapeyre/vault-acme
wget https://github.com/remilapeyre/vault-acme/releases/download/v0.0.8/linux_amd64.zip -O /tmp/acme.zip
unzip /tmp/acme.zip -d /tmp/
mv /tmp/acme-plugin /opt/vault/plugins/
chmod vault:vault /opt/vault/plugins/acme-plugin
sudo setcap cap_ipc_lock=+ep /opt/vault/plugins/acme-plugin
vault write sys/plugins/catalog/secret/acme sha_256=29b5d33532cd55fddd5de199c4717683ccc3957bf8d8fe645974be984c1abd5a command=acme-plugin
vault secrets enable -path acme -plugin-name acme plugin
@giuliocalzolari
giuliocalzolari / lambda_poweroff_ec2_all_region.py
Last active February 15, 2022 14:28
Lambda poweroff ec2 across all regions
from datetime import datetime, timedelta, time
import boto3
# last update 2022/02/15
TIME = {
"eu-central-1": {
"description": "Europe(Frankfurt)",
"permitted_ec2_time": "8-19",
"utc_offset": "+1"
@giuliocalzolari
giuliocalzolari / run.sh
Last active October 13, 2021 07:55
quick port check
</dev/tcp/10.228.196.124/22 && echo "Port is open" || echo "Port is closed"
@giuliocalzolari
giuliocalzolari / s3-to-es-lambda.py
Last active January 27, 2021 18:25
S3 Logs to Elasticsearch
##################################################
### Elasticsearch host name
ES_HOST = "search-******************.ap-northeast-1.es.amazonaws.com"
### Elasticsearch prefix for index name
INDEX_PREFIX = "elb_log"
### ELB name for type name
ELB_NAME = "*****"
@giuliocalzolari
giuliocalzolari / aws-backup.yaml
Last active November 13, 2019 13:50 — forked from quiver/cloudformation-template-for-aws-backup-thin-backups.yaml
CloudFormation template to configure thin backup rules for AWS Backup
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Create AWS Backup Vault, Backup Plan and Backup Selection
Parameters:
# Backup
CreateNewBackupVault:
Type: String
AllowedValues:
- true
- false
@giuliocalzolari
giuliocalzolari / C:\Program Files\Amazon\EC2config\Settings\AWS.EC2.Windows.CloudWatch.json
Last active July 23, 2019 07:56
AWS CloudWatch with Custom metrics(Memory,FreeDisk) with EC2config
{
"EngineConfiguration":{
"PollInterval":"00:00:15",
"Components":[
{
"Id":"ApplicationEventLog",
"FullName":"AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters":{
"LogName":"Application",
"Levels":"1"
@giuliocalzolari
giuliocalzolari / .gitlab-ci.yml
Created April 10, 2019 13:19
terraform .gitlab-ci.yml
# source https://github.com/radekg/terraform-provisioner-ansible
image:
name: rflume/terraform-aws-ansible:latest
stages:
# 'global' stages
- validate global
- plan global
- apply global
# Dev env stages