Skip to content

Instantly share code, notes, and snippets.

@giuseppecossu
giuseppecossu / update-healthchecks-regions.py
Created August 3, 2017 15:12
Update Health Checks with custom Regions (not supported on CFN)
#!/usr/bin/env python
import boto3, sys
'''
Update Health Checks with custom Regions (not supported on CFN)
Args:
PROFILE_NAME: account profile name
REGIONS: list of regions
'''
PROFILE_NAME='AWS_CLI_PROFILE'
@giuseppecossu
giuseppecossu / update-cloudwatchlogs-retention.py
Created August 3, 2017 15:09
Update Amazon CloudWatch Logs Retention
#!/usr/bin/env python
import boto3, sys
'''
Update Amazon CloudWatch Logs Retention
Args:
PROFILE_NAME: account profile name
RETENTION: The number of days log events are kept in CloudWatch Logs.
'''
PROFILE_NAME='AWS_CLI_PROFILE'
@giuseppecossu
giuseppecossu / update_hostnames.sh
Last active May 19, 2017 09:01
Update /etc/hosts with a local alias-name.
#!/bin/bash
# Insert here the domain e.g., www.google.it
domain='<your_domain_to_resolve>'
domain_ip=`nslookup $domain | grep ^Address| awk '{print $2}' | awk END{print}`
# Insert here your alias www.local-google.it
canonical_hostname='<alias_local_domain>'
# You need to create manually the first entry on /etc/hosts
@giuseppecossu
giuseppecossu / update-route53.sh
Created March 7, 2017 16:11 — forked from ddepaoli3/route53-update.sh
BASH Script to keep Route53 updated with your current external IP address
#!/bin/bash
# (optional) You might need to set your PATH variable at the top here
# depending on how you run this script
#PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Hosted Zone ID e.g. BJBK35SKMM9OE
ZONEID=$1
# The CNAME you want to update e.g. hello.example.com
@giuseppecossu
giuseppecossu / aws-certification.md
Created February 4, 2017 14:49 — forked from miglen/aws-certification.md
AWS Certification guide and notes on how to prepare for the aws associate certification architect, sysops and developer exams

AWS Certification notes

Those are my personal notes on AWS Solution Architect certification preparation. Hope you find them usefull.

To pass AWS certification, you should have:

  • Sound knowledge about most of the AWS services ( EC2, VPC, RDS, Cloudfront, S3, Route53 etc,)
  • Hands on experience with AWS services.
  • Good knowledge of disaster recovery, security and High availability architectures.

If you do not have prior hands-on experience and knowledge or you have little knowledge about AWS services, it is better to take an online course. If you already have experience in architecting solutions on AWS it is not necessary to take an online course.

@giuseppecossu
giuseppecossu / script_log.sh
Last active February 13, 2017 14:12
Log Dir and Files
#!/bin/bash
#launch with nohup ./script_log.sh > /tmp/log-nohup.txt &
while true
do
echo -e "$(date -u +%Y-%m-%d' '%H:%M:%S) \n $(df -h) \n *** \n" >> /var/log/log_disk.log
echo -e "$(date -u +%Y-%m-%d' '%H:%M:%S) \n $(du -S -h --max-depth=4 /my-dir/mysubdir) \n *** \n" >> /var/log/log_mydir.log
echo -e "$(date -u +%Y-%m-%d' '%H:%M:%S) \n $(find /my-dir/mysubdir -type f -print0 | du -h --files0-from=-) \n *** \n" >> /var/log/log_myfiles.log
sleep 5
done
@giuseppecossu
giuseppecossu / bootstrap_AWS_local_ansible_ubuntu_16_04.sh
Last active January 26, 2017 10:10 — forked from ddepaoli3/bootstrap_AWS_local_ansible_ubuntu_16_04.sh
Bootstrap to install and configure ubuntu 16.04 to allow it to run ansible locally and to clone git repo from codecommit
#!/bin/bash
sudo apt-get update
sudo apt-get install --yes python2.7 git ansible awscli
# You need to associate IAM role to your instance
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
# Now it is possibile to clone from codecommit and run ansiblo locally
# Clone your repo and run ansible
@giuseppecossu
giuseppecossu / .ssh-config
Created January 20, 2017 14:26
SSH Configuration for AWS Codecommit
Host codecommit-profile-name_1
HostName git-codecommit.us-east-1.amazonaws.com
User <AWS-SSH-ID_1>
IdentityFile ~/.ssh/id_rsa
Host codecommit-profile-name_2
HostName git-codecommit.eu-west-1.amazonaws.com
User <AWS-SSH-ID_2>
IdentityFile ~/.ssh/id_rsa
@giuseppecossu
giuseppecossu / .aws-credentials
Created January 20, 2017 14:22
AWS CLI credentials file
[profile-name]
aws_access_key_id = <your-key_id>
aws_secret_access_key = <your-access_key>
region = <your-default-region>
@giuseppecossu
giuseppecossu / Vagrantfile
Created January 20, 2017 14:13
Vagrant AWS Provider
# Reference: https://github.com/mitchellh/vagrant-aws
# Install Requirements:
# vagrant plugin install vagrant-aws
# vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
# Select with AMI start
# Ubuntu
# CentOS
# Amazon Linux