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
USE ROLE ACCOUNTADMIN; | |
USE WAREHOUSE <warehouse_name>; | |
WITH privileged_users_check AS PROCEDURE() | |
RETURNS TABLE() | |
LANGUAGE PYTHON | |
RUNTIME_VERSION = '3.9' | |
PACKAGES = ('snowflake-snowpark-python') | |
HANDLER = 'main' | |
EXECUTE AS CALLER |
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
# batch-get-aggregate-resource-config only accepts 100 resource identifiers. If you need to get the configuration | |
# of more items, use python + boto3: https://gist.github.com/atheiman/9830de25a3fb54a06b86953a2675bbd1 | |
AGGREGATOR_NAME='MyConfigAggregator' | |
aws configservice batch-get-aggregate-resource-config \ | |
--configuration-aggregator-name "$AGGREGATOR_NAME" \ | |
--resource-identifiers "$( | |
aws configservice list-aggregate-discovered-resources \ | |
--configuration-aggregator-name "$AGGREGATOR_NAME" \ | |
--resource-type 'AWS::EC2::Instance' \ |
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
# CW Alarm Template | |
# | |
# Author: Chris Sereno | |
# Description: This template creates or adds CW alarms to EC2 Instances and will restart and recover instances. | |
# There are requirements to instance recovery. See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-recover.html | |
# This is a personal test template and is NOT a vetted or approved template. Use at your own risk. | |
# | |
--- | |
AWSTemplateFormatVersion: '2010-09-09' | |
Description: 'CloudWatch Alarms to recover EC2 Template' |
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
#----------------------------------------------------------------------------------------------- | |
#copy emr conf | |
#----------------------------------------------------------------------------------------------- | |
emr_ip=10.135.241.137 | |
sudo rm -rf /etc/yum.repos.d/emr-*.repo | |
sudo rm -rf /var/aws/emr/repoPublicKey.txt | |
sudo mkdir -p /var/aws/emr/ | |
sudo chmod +r -R /var/aws/ | |
sudo rm -rf /etc/spark/ | |
sudo rm -rf /etc/hadoop/ |
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
### New role creation | |
### Here assume_role_policy MUST be defined for the trust relationship | |
resource "aws_iam_role" "codedeploy_service_role" { | |
name = "CodeDeployServiceRole" | |
assume_role_policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ |
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
Reference: https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/put-metric-alarm.html | |
===HIGH CPU=== | |
aws cloudwatch put-metric-alarm --alarm-name "High CPU Util on INSTANCE" --alarm-description "Alarm when CPU exceeds 90 percent" --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 300 --threshold 90 --comparison-operator GreaterThanThreshold --dimensions "Name=InstanceId,Value=INSTANCE" --evaluation-periods 2 --alarm-actions "arn:aws:sns:REGION:ACCOUNT:SNSTOPIC" --unit Percent | |
===HIGH MEM=== | |
aws cloudwatch put-metric-alarm --alarm-name "High Memory Util on INSTANCE" --alarm-description "Alarm when Memory exceeds 90 percent" --metric-name mem_used_percent --namespace AWS/EC2 --statistic Average --period 300 --threshold 90 --comparison-operator GreaterThanThreshold --dimensions "Name=InstanceId,Value=INSTANCEID" --evaluation-periods 2 --alarm-actions "arn:aws:sns:REGION:ACCOUNT:SNSTOPIC" --unit Percent | |
===StatusCheckFailed=== | |
aws cloudwatch put-metric-alarm --alarm-name "EC |
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
{ | |
"agent": { | |
"metrics_collection_interval": 10, | |
"logfile": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log" | |
}, | |
"metrics": { | |
"metrics_collected": { | |
"cpu": { | |
"resources": [ | |
"*" |
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
function get-instances() { | |
name=$1 | |
( | |
echo 'Name,PrivateIPAddress,State,LaunchTime (↓)' &&\ | |
aws ec2 describe-instances --filters "Name=tag:Name,Values=$name" |\ | |
jq -r '.Reservations[].Instances[] | | |
["\(.Tags | map(select(.Key == "Name").Value)[0])-\(.InstanceId)", .PrivateIpAddress, .State.Name, .LaunchTime] | | |
@csv' |\ | |
tr -d '"' |\ | |
sort -k 4 |
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
# display VPC ID, CIDR Block and Name | |
aws ec2 --output text --query 'Vpcs[*].{VpcId:VpcId,Name:Tags[?Key==`Name`].Value|[0],CidrBlock:CidrBlock}' describe-vpcs |