This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "ViewOwnUserInfo", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:GetUserPolicy", | |
"iam:ListGroupsForUser", | |
"iam:ListAttachedUserPolicies", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "myvar" { | |
default = [ | |
{ | |
"name" : "config_bucket", | |
"value" : "bucketname" | |
}, | |
{ | |
"name" : "version", | |
"value" : "1.2.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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', | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": ["iam:ListVirtualMFADevices"], | |
"Resource": "*" | |
}, | |
{ | |
"Sid": "AllowUsersToManageCoreCredentials", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
mysql_config_editor set --login-path=<PATH> --host=<DB_NAME> | |
-—user=<USERNAME> | |
--password |