Skip to content

Instantly share code, notes, and snippets.

View akloya's full-sized avatar

Ajaya Loya akloya

View GitHub Profile
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ViewOwnUserInfo",
"Effect": "Allow",
"Action": [
"iam:GetUserPolicy",
"iam:ListGroupsForUser",
"iam:ListAttachedUserPolicies",
@akloya
akloya / loop_multiple_profiles.py
Created October 15, 2021 02:37
loop through multiple aws profiles in python
import boto3
for profile in ['profile1', 'profile2']:
print("fetching from account => " + profile)
session = boto3.session.Session()
client = session.client(
service_name='secretsmanager',
region_name='us-west-2'
)
response = client.list_secrets()
print(response)
sam build --use-containter
sam deploy --guided
sam local invoke --env-vars env.json --profile=XXXX --region XXXX
sam package --template-file template.yaml --output-template-file packaged.yaml --s3-bucket bucket_name
sam publish --template packaged.yaml --region XXXXX
variable "myvar" {
default = [
{
"name" : "config_bucket",
"value" : "bucketname"
},
{
"name" : "version",
"value" : "1.2.3"
import boto3
import sys
ec2 = boto3.client('ec2')
instances_list = []
instancetype_with_count = ()
current_instances = ec2.describe_instances()
count = 0
# Fetching all reserved instances that are active
# scripts delete all the ebs volumes that are in available state
import boto3
ec2 = boto3.client("ec2")
response = ec2.describe_volumes(
Filters=[
{
'Name': 'status',
'Values': [
'available',
]
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["iam:ListVirtualMFADevices"],
"Resource": "*"
},
{
"Sid": "AllowUsersToManageCoreCredentials",
import boto3
ec2 = boto3.client("ec2")
ec2_resource = boto3.resource('ec2')
for vpc in ec2.describe_vpcs()['Vpcs']:
vpc = ec2_resource.Vpc(vpc['VpcId'])
network_acl_iterator = vpc.network_acls.all()
for i in network_acl_iterator:
response = ec2.describe_network_acls(
NetworkAclIds=[
@akloya
akloya / gist:0aad344f2f0eacbb8396174dac634745
Created April 3, 2018 22:02
GPG transfer private keys
GPG: transfer/import private keys to different machine
Some time you might need to copy your keys to another machine
Identify your private key by running
> gpg --list-secret-keys.
Run this command to export your key:
> gpg --export-secret-keys $ID > my-private-key.asc
Copy the key to the other machine using scp
To import the key, run
@akloya
akloya / mysql useful commands
Created March 29, 2018 20:43
mysql password less command execution
#
mysql_config_editor set --login-path=<PATH> --host=<DB_NAME>
-—user=<USERNAME>
--password