Cloud Custodian Policies not working for EC2 and S3

0 votes
I am trying to write Cloud custodian policies but I couldn't find a straight up rules filters for this in the official docs.

I am writing policies to terminate all internet facing ec2 instances and public S3 buckets.

Can someone help me as where am going wrong?
Oct 30, 2018 in AWS by findingbugs
• 3,260 points
1,553 views

2 answers to this question.

0 votes
policies: - name: find-ec2-on-public-subnets resource: ec2 filters: - type: value key: "SubnetId" op: in value: - subnet-d1e4xxxxx - subnet-d1e4xxxxx actions: - stop - name: s3-global-access resource: s3 filters: - type: global-grants actions: - type: delete-global-grants grantees: - "http://acs.amazonaws.com/groups/global/AllUsers" - "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"
answered Oct 30, 2018 by Priyaj
• 58,060 points
+1 vote

There are no straight up examples. Best to run a policy to capture resources of what you are looking for and build a filter based upon what you find in the resources.json file. Below is some sample code to get you started along your path. Try running the custodian policy with no filter defined, just the resource then look at the resources.json contents..

policies:

  - name: purge-lambda-after-7-days

    resource: lambda

    filters:

    - type: value

      value: ec2

      key: FunctionName

      value_type: normalize

     op: not_in

Example resources.json file;

[

  {

    "FunctionName": "EC2_Instance_Check",

answered Mar 1, 2019 by anonymous

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Attaching multiple policies for S3

As per the AWS documentation here, an ...READ MORE

answered Jul 30, 2019 in AWS by Praveen
• 700 points
2,557 views
+1 vote
1 answer

i have configure docker on AWS EC2 instance but commands are not working inside docker container.

Hello @Aniket , The docker exec command runs a new command ...READ MORE

answered Aug 5, 2020 in AWS by Niroj
• 82,840 points
1,684 views
0 votes
1 answer

How to transfer files between AWS s3 and AWS ec2?

Hi@akhtar, You can use the AWS CLI command to ...READ MORE

answered Sep 22, 2020 in AWS by MD
• 95,460 points
1,455 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP