Skip to content

Instantly share code, notes, and snippets.

View jtroberts83's full-sized avatar

Jamison Roberts jtroberts83

View GitHub Profile
policies:
- name: ec2-terminate-non-standard-region
resource: ec2
description: |
Any EC2 instance launched in a non standard region outside
of us-east-1 and eu-west-1 will be terminated
mode:
type: cloudtrail
events:
@jtroberts83
jtroberts83 / terminate-ec2-stopped-over-x-days.yaml
Last active March 27, 2018 21:12
Terminate EC2 Instances Stopped For 60 Days or More
policies:
- name: ec2-mark-stopped-instance-realtime
tags: [Realtime,Tag]
resource: ec2
mode:
type: cloudtrail
events:
- source: ec2.amazonaws.com
event: StopInstances
#!/bin/bash
ASGName='YOUR_CUSTODIAN_AUTOSCALING_GROUP_NAME'
RESOURCE_BUCKET='S3_BUCKET_CONTAINING_YOUR_POLICIES_AND_CONFIG'
## Sets up proxy for instance run
export no_proxy="169.254.169.254"
export http_proxy='http://PROXYADDRESSHERE.com:9090'
export https_proxy="$http_proxy"
@jtroberts83
jtroberts83 / s3-public-object-acl-deny.yaml
Last active December 4, 2018 18:06
AWS S3 Bucket Policy To Block All Public Object ACLs From Being Set
policies:
- name: s3-deny-public-object-acl-poll
resource: s3
description: |
Appends a bucket policy statement to all existing buckets to deny anyone from setting s3 objects
in the bucket to public-read, public-read-write, or any authenticated AWS user.
actions:
- type: set-statements
statements:
policies:
- name: sg-auto-tag-user
resource: security-group
description: |
Creates a Tag called CreatorName with a value of the user who created the Security Group
mode:
type: cloudtrail
events:
- source: ec2.amazonaws.com
{
"account":"accountaliashere",
"account_id":"1234567890",
"region":"us-west-1",
"action":{
"violation_desc":"Public IP Address:",
"to":[
"[email protected]",
"event-owner"
],
<!DOCTYPE html>
<html lang="en">
{#
Template customizations:
- additional parameters for slack channel and email for questions
- link to our internal docs
- case-insensitive tag lookups in the getTag macro
- formatting that renders correctly in Office365 and acceptably in GMail
@jtroberts83
jtroberts83 / Fixed
Created April 10, 2018 21:22
Fixed file for user
policies:
- name: high-risk-security-groups-remediate3
resource: security-group
description: |
Remove any rule from a security group that allows test ingress
and notify the user who added the violating rule.
mode:
type: cloudtrail
events:
- source: ec2.amazonaws.com
- name: delete-old-snapshots-under-20-gb
resource: ebs-snapshot
description: |
Deletes a snapshot if its older than 7 days and it was created by cloud custodian
filters:
- type: value
key: VolumeSize
op: lt
value: 20
@jtroberts83
jtroberts83 / SageMakerNotebookEnforce.yaml
Created April 27, 2018 22:13
Cloud Custodian policy chain to enforce encryption and vpc mode for new SageMaker Notebooks
policies:
- name: sagemaker-notebook-auto-tag-user
resource: sagemaker-notebook
description: |
When a new Sagemaker notebook is created tag the creators ID to CreatorName tag
mode:
type: cloudtrail
events: