Coder Social home page Coder Social logo

aws-iam-role-last-used-config-rule's Introduction

aws-iam-role-last-used-config-rule

Creates an AWS Config rule and Lambda to check all roles' last used compliance.

See: https://aws.amazon.com/blogs/security/continuously-monitor-unused-iam-roles-aws-config/

Housekeeping:

  • Target region (in this example is the current region):

      MY_AWS_REGION=$(curl http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/.$//')
    
  • S3 bucket where to save the zip function code package (the name, not the ARN):

      MY_AWS_S3_BUCKET_NAME=<MY S3 BUCKET NAME>
    
  • Lambda layer ARN(s) (optional):

      MY_AWS_LAMBDA_LAYER_ARNS=<MY COMMA SEPARATED LAMBDA LAYER ARNS>
    

Delete previous deployment:

aws cloudformation delete-stack --stack-name iam-role-last-used

Package function code and transform the template to point to zipped code on S3:

aws cloudformation package --region $MY_AWS_REGION --template-file iam-role-last-used.yml \
--s3-bucket $MY_AWS_S3_BUCKET_NAME \
--output-template-file iam-role-last-used-transformed.yml

Peploy the lambda function:

aws cloudformation deploy --region $MY_AWS_REGION --template-file iam-role-last-used-transformed.yml \
--stack-name iam-role-last-used \
--parameter-overrides NameOfSolution='iam-role-last-used' \
MaxDaysForLastUsed=60 \
RolePatternWhitelist='/breakglass-role|/security-*' \
LambdaLayerArn="$MY_AWS_LAMBDA_LAYER_ARNS" \
--capabilities CAPABILITY_NAMED_IAM

aws-iam-role-last-used-config-rule's People

Contributors

emanueleborin avatar emanueleborinatscaiitec avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.