Skip to content

Instantly share code, notes, and snippets.

View gmirsky's full-sized avatar

Gregory Mirsky gmirsky

View GitHub Profile
@gmirsky
gmirsky / dmidecode.txt
Created July 26, 2017 23:00
Is the server physical or a VM? If VM what type of VM?
VMware Workstation
======================================
$sudo dmidecode -s system-product-name
Output ==> VMware Virtual Platform
VirtualBox
======================================
$sudo dmidecode -s system-product-name
@gmirsky
gmirsky / addUsersWithTemporaryPasswordToGroup.sh
Created March 28, 2019 15:39
Add users with temporary password to group
#!/bin/bash
#
#
# Run as root or sudo su
#
#set -x
if [ "$EUID" -ne 0 ]; then
echo "This script requires elevated permissions."
echo "Please run this script as sudo or root."
exit
@gmirsky
gmirsky / AWSListUnUsedKeyPairs.ps1
Created January 7, 2020 14:54
PowerShell script to find unused AWS EC2 Key Pairs
Param( $AWSRegion = 'us-east-1', $AWSProfileName = 'default')
#
# Store your AWS credentials using the following Powershell AWS command:
#
# Set-AWSCredentials -AccessKey {xx} -SecretKey {xx} -StoreAs {MyProfileName}
#
# Example:
#
# Set-AWSCredentials -AccessKey 'AKIAVJL...OB4XN' -SecretKey 'oxLcrpnd3S+...8e2Me' -StoreAs 'testprofile'
# Set-DefaultAWSRegion us-east-1
@gmirsky
gmirsky / ZabbixDockerCompose.md
Created April 23, 2020 19:51
HOW-TO: Install Zabbix with MySQL as containers using docker-compose

HOW-TO: Install Zabbix with MySQL as containers using docker-compose

Provision EC2 instance

Provision Amazon Linux 2 EC2 with static IP and ports 22, 80, 443 and 10051 open in the security group.

Install docker

sudo yum update -y
@gmirsky
gmirsky / terraformWorkspaceName.txt.txt
Created June 23, 2020 21:23
terraform get workspace name
output "workspace_name" {
value = "${lower(terraform.workspace)}"
description = "Terraform Workspace Name"
sensitive = false
}
@gmirsky
gmirsky / aws_caller_identity.txt.txt
Created June 24, 2020 18:20
terraform get current user id
data "aws_caller_identity" "current" {}
output "account_id" {
value = "${data.aws_caller_identity.current.account_id}"
}
output "caller_arn" {
value = "${data.aws_caller_identity.current.arn}"
}
@gmirsky
gmirsky / dockerfile-dot-net.txt
Created June 30, 2020 18:13
Dockerfile for .NET Framework image with WindowsServerCore
# escape=`
# use .NET Framework image with WindowsServerCore
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8
WORKDIR /app
# copy published application files inside the image
COPY _artifacts/appfiles /.
# configure web servers to bind to port 80 when present
ENV ASPNETCORE_URLS=http://+:80 `
@gmirsky
gmirsky / docker-update-all.sh.sh
Created July 1, 2020 14:54
update all docker images
docker images | grep -v REPOSITORY | awk '{print $1}' | xargs -L1 docker pull
@gmirsky
gmirsky / AwsDeleteSnapshotWithOutVolume.py
Last active July 10, 2020 16:43
AWS Delete Snapshots without a Volume
import boto3
ec2_resource = boto3.resource('ec2')
# Make a list of existing volumes
all_volumes = ec2_resource.volumes.all()
volumes = [volume.volume_id for volume in all_volumes]
# Find snapshots without an existing volume
snapshots = ec2_resource.snapshots.filter(OwnerIds=['self'])
@gmirsky
gmirsky / AwsListUnusedKeyPairs.ps1.ps1
Created July 22, 2020 20:06
AWS List Unused Key Pairs
Param( $AWSRegion = 'us-east-1', $AWSProfileName = 'default')
#
# Store your AWS credentials using the following Powershell AWS command:
#
# Set-AWSCredentials -AccessKey {xx} -SecretKey {xx} -StoreAs {MyProfileName}
#
# Example:
#
# Set-AWSCredentials -AccessKey 'AKIAVJL...KWJKOB4XN' -SecretKey 'oxLcrpnd3S+...1Y5eg3m92E8e2Me' -StoreAs 'testprofile'
# Set-DefaultAWSRegion us-east-1