Skip to content

Instantly share code, notes, and snippets.

@jtroberts83
Last active September 12, 2019 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtroberts83/85d0b432491b73fcc80f82ea0e82b322 to your computer and use it in GitHub Desktop.
Save jtroberts83/85d0b432491b73fcc80f82ea0e82b322 to your computer and use it in GitHub Desktop.
Terminate EC2s launch with public IP
- name: no-ec2-public-ips-realtime
resource: ec2
description: |
If a EC2 instance is launched with a public IP attached initially
it will get terminated.
mode:
type: cloudtrail
events:
- RunInstances
filters:
- type: event
key: "detail.requestParameters.networkInterfaceSet.items[0].associatePublicIpAddress"
value: true
actions:
- type: terminate
force: true
- name: ec2-find-existing-public-ips
resource: ec2
description: |
If a EC2 instance has a public IP attached, take some action.
filters:
- "PublicIpAddress": present
actions:
<DO SOMETHING HERE>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment