Skip to content

Instantly share code, notes, and snippets.

response = client.list_suppressed_destinations(Reasons=['BOUNCE'], PageSize=50)
addresses = response['SuppressedDestinationSummaries']
while "NextToken" in response:
response = client.list_suppressed_destinations(NextToken=response["NextToken"], Reasons=['BOUNCE'],PageSize=50)
addresses.extend(response['SuppressedDestinationSummaries'])
print(len(addresses))
TOKEN=$(curl --silent -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 600")
INSTANCEID=$(curl --silent -H "X-aws-ec2-metadata-token: ${TOKEN}" http://169.254.169.254/latest/dynamic/instance-identity/document | python3 -c 'import json,sys;print(json.load(sys.stdin)["instanceId"])')
@markymarkus
markymarkus / sf_paginate.yml
Last active March 18, 2022 09:48
Step Functions with paginate
---
Parameters:
pBucketName:
Type: String
Default: ''
Description: Input S3 Bucket
Resources:
StateMachine:
Type: AWS::StepFunctions::StateMachine
Properties:
@markymarkus
markymarkus / gist:c28cb92889d6826eca1fe551a1088a98
Created December 30, 2021 05:30
Install SSM Agent to Debian instance
UserData:
Fn::Base64:
!Sub |
#!/bin/bash
cd /tmp
wget https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb
sudo dpkg -i amazon-ssm-agent.deb
sudo systemctl enable amazon-ssm-agent
sudo systemctl start amazon-ssm-agent
LogsRule:
Type: AWS::Events::Rule
Properties:
EventBusName: 'default'
EventPattern:
source:
- aws.ssm
detail-type:
- "EC2 State Manager Association State Change"
State: ENABLED
# usage json_to_firehose.py input_file.json my_firehose_stream
import json
import sys
import boto3
client = boto3.client('firehose')
filename = sys.argv[1]
streamname = sys.argv[2]
#!/bin/bash
TO="USER@XXXX.XXX"
FROM="SENDER@XXXX.XXX"
SUBJECT="Test mail"
MESSAGE="liam tseT"
date="$(date +"%a, %d %b %Y %H:%M:%S %Z")"
priv_key="AWS_SECRET_KEY"
access_key="AWS_ACCESS_KEY"
@markymarkus
markymarkus / gist:9defa002e8ac27992c83ca7d93d313cb
Created February 9, 2021 10:58
sh script to assume-role from Gitlab
#!/bin/sh
echo "Assuming role based on CI job name $CI_JOB_NAME"
case "$CI_JOB_NAME" in
*"prod")
AWS_DEPLOYMENT_ROLE=$AWS_DEPLOYMENT_ROLE_PROD
AWS_EXTERNALID=$AWS_EXTERNALID_PROD
;;
*"test")
aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[?contains(Tags[?Key==`tag_key`].Value, `tag_value`)].[AutoScalingGroupName]'
# If the tag value is true it must be escaped with "
aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[?contains(Tags[?Key==`tag_key`].Value, `"true"`)].[AutoScalingGroupName]'
#!/bin/bash
#
set -e
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_SECURITY_TOKEN
ROLEARN="${1}"
SESSIONNAME="sumething"
KST=$(aws2 sts assume-role --role-arn $ROLEARN \
--role-session-name $SESSIONNAME)