Skip to content

Instantly share code, notes, and snippets.

View brunodasilvalenga's full-sized avatar

Bruno da Silva Valenga brunodasilvalenga

View GitHub Profile
#!/bin/bash
# Set output file
report_file="aws_network_report_$(date +%Y%m%d_%H%M%S).txt"
echo "AWS Network Infrastructure Report" > "$report_file"
echo "Generated on: $(date)" >> "$report_file"
echo "========================================" >> "$report_file"
# First, let's get Transit Gateways information
@brunodasilvalenga
brunodasilvalenga / rds_restore_from_snapshopt.sh
Created March 23, 2022 20:24
Create RDS Snapshot and restore it.
#!/bin/bash
# set up some variables
NOW_DATE=$(date '+%Y-%m-%d-%H-%M')
RESTORE_FROM_INSTANCE_ID=<source name>
TARGET_INSTANCE_ID=<target name>
TARGET_INSTANCE_CLASS=db.m4.large
VPC_ID=<vpc subnet id>
NEW_MASTER_PASS=<root password>
@brunodasilvalenga
brunodasilvalenga / get_spot_price.py
Created June 4, 2020 06:49
Script python to get spot price with last 4 hours.
import boto3
import datetime
client = boto3.client('ec2', region_name='us-west-2')
regions = [x["RegionName"] for x in client.describe_regions()["Regions"]]
print(regions)
INSTANCE = "t3.xlarge"
print("Instance: %s" % INSTANCE)
results = []
for region in regions:
client = boto3.client('ec2', region_name=region)
image: dnxsolutions/musketeers:1.1.1-ecr
services:
- docker:18.03.1-ce-dind # needs to match gitlab runner version
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
AWS_DEFAULT_REGION: ap-southeast-2
AWS_HOSTED_ZONE: dev.cloud.example.com.au
image: dnxsolutions/musketeers:1.1.1-ecr
services:
- docker:18.03.1-ce-dind # needs to match gitlab runner version
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
BUILD_VERSION: $CI_COMMIT_SHORT_SHA
AWS_ROLE: ci-deploy
AWS_DEFAULT_REGION: ap-southeast-2
variable "aws_account_id" {}
variable "aws_role" {}
variable "org_name" {
default = "example"
}
locals {
env = {
nonprod-ap-southeast-2-dev = {
image: dnxsolutions/musketeers:1.1.0
services:
- docker:18.03.1-ce-dind # needs to match gitlab runner version
variables:
DOCKER_HOST: "tcp://docker:2375"
stages:
- plan-developer
- apply-developer
- destroy-developer
resource "aws_s3_bucket" "app" {
bucket = "${var.org_name}-${local.workspace["app_app_name"]}-${local.workspace["environment_name"]}"
acl = "private"
}
module "app" {
source = "git::https://github.com/DNXLabs/terraform-aws-static-app.git?ref=1.1.1"
name = "${local.workspace["app_app_name"]}"
s3_bucket_id = "${aws_s3_bucket.app.id}"
resource "aws_api_gateway_domain_name" "services_gateway" {
domain_name = "${local.workspace["services_gateway_hostname"]}"
regional_certificate_arn = "${data.aws_acm_certificate.domain_host.arn}"
endpoint_configuration {
types = ["REGIONAL"]
}
}
data "aws_route53_zone" "services_selected" {
@brunodasilvalenga
brunodasilvalenga / DockerCleanupScripts.md
Created October 4, 2019 08:57
Docker - Cleanup resources (containers, volumes, images, networks) ...

Docker - How to cleanup (unused) resources

Cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm