This file contains hidden or 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 json | |
def lambda_handler(event, context): | |
print("Received event: " + json.dumps(event)) | |
if event['detail']['eventName'] == 'ModifyInstanceAttribute' and 'instanceType' in event['detail']['requestParameters']: | |
instance_id = event['detail']['requestParameters']['instanceId'] | |
instance_type = event['detail']['requestParameters']['instanceType']['value'] | |
cw = boto3.client('cloudwatch') | |
alarms = cw.describe_alarms() |
This file contains hidden or 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
#!/bin/bash | |
# Prompt the user to enter the instance ID to check for | |
read -p "Enter the instance ID to check for: " INSTANCE_ID | |
# Get a list of all load balancer ARNs in the current AWS account | |
LB_ARNS=$(aws elbv2 describe-load-balancers --query "LoadBalancers[].LoadBalancerArn" --output text) | |
# Loop through each load balancer ARN and check if the instance is registered with any target groups | |
for LB_ARN in $LB_ARNS |
This file contains hidden or 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 json | |
import time | |
ssm = boto3.client('ssm') | |
def lambda_handler(event, context): | |
# Check if the event is a ModifyInstanceAttribute event and has an instance-type change | |
if event['detail']['eventName'] == 'ModifyInstanceAttribute' and \ | |
event['detail']['requestParameters'].get('instanceType') is not None: |
This file contains hidden or 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
{ | |
"source": ["aws.ec2"], | |
"detail-type": ["AWS API Call via CloudTrail"], | |
"detail": { | |
"eventSource": ["ec2.amazonaws.com"], | |
"eventName": ["ModifyInstanceAttribute"] | |
} | |
} |
This file contains hidden or 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
{ | |
"metrics": { | |
"append_dimensions": { | |
"AutoScalingGroupName": "${aws:AutoScalingGroupName}", | |
"ImageId": "${aws:ImageId}", | |
"InstanceId": "${aws:InstanceId}", | |
"InstanceType": "${aws:InstanceType}" | |
}, | |
"metrics_collected": { | |
"LogicalDisk": { |
This file contains hidden or 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 json | |
import urllib.parse | |
import boto3 | |
print('Loading function') | |
s3 = boto3.client('s3') | |
mt = boto3.client('mediatailor') | |
This file contains hidden or 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
Course url: https://linuxacademy.com/containers/training/course/name/docker-deep-dive-part-1 | |
==================== All Docker Command While Learning Docker ========================= | |
Get a list of all of the Docker commands: | |
docker -h | |
====== Attaching to Container , run in background , name it ========== | |
Create a container and attach to it: |
This file contains hidden or 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
from datetime import datetime | |
import boto3 | |
def lambda_handler(event, context): | |
account_id = boto3.client('sts').get_caller_identity().get('Account') | |
ec2 = boto3.client('ec2') | |
regions = [region['RegionName'] | |
for region in ec2.describe_regions()['Regions']] | |
#Iterate over each Region |
This file contains hidden or 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
from datetime import datetime | |
import boto3 | |
def lambda_handler(event, context): | |
ec2_client = boto3.client('ec2') | |
regions = [region['RegionName'] | |
for region in ec2_client.describe_regions()['Regions']] | |
for region in regions: |
This file contains hidden or 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 | |
def lambda_handler(event, context): | |
#Get list of Regions | |
ec2_client = boto3.client('ec2') | |
regions = [region['RegionName'] | |
for region in ec2_client.describe_regions()['Regions']] | |
#Iterate over each Region | |
for region in regions: |