Giter Club home page Giter Club logo

aws-config-detect-environment-variables-secrets-terraform's Introduction

aws-config-detect-environment-variables-secrets

Code to deploy a solution to detect secrets/tokens in Lambda functions using AWS Config.

Table of Contents

Description

This Terraform module create a custom rule on AWS Config that detects secrets/tokens in the Lambda functions in the account.

The following diagram applies to the current solution.

Diagram

Once a secret/token is identified in the environment variables of a Lambda function, they are flagged as NON_COMPLIANT with an annotation showing the type of the detected secret. (Example: JSON Web Token) The AWS Config rule is triggered at any modification of every environment variable in each Lambda functions in the account.

Pay attention: this module is meant to be used as standalone module.

Prerequisites

  • AWS Config: This module expects that AWS Config is already up and running in the region where the rules will be deployed. The setup can be easily carried out by following the official documentation.

  • Docker: In order to properly deploy the resources to your account, Docker needs to be installed on your machine. Please refer to this link.

Dependencies

Variables

The available variables are described in variables.tf file.

Usage

In this example we are going to deploy the custom rule that will automatically check all lambda functions for vulnerable environment variables.

Preparing the Lambda layers (Bash Script)

The lambda function that will be leveraged to carry out the detection process uses two libraries rdklib and detect-secrets Therefore, you need to first ensure those libraries are available to the function in your account as lambda layers.

Use this command in your terminal to prepare them for Terraforms to deploy them in the following section:

cd scripts
./build.sh

Deploying the code (Terraforms)

Option 1: You can use the following sample to utilize the module within your code:

module "deploy_lambda_secrets_detector_rule" {
  config_rule_name = "lambda_has_no_secrets"
  source           = "./modules/lambda_has_no_secrets"
  enabled          = true
}

Please have a look inside inside variables.tf for all the possible options.

Option 2: Alternatively, if you have Terraform installed on your workstation, you can deploy the example by executing:

export AWS_PROFILE=$MY_AWS_PROFILE
terraform init
terraform apply

Pay attention: you should first modify the region in your AWS Profile in accordance to your requirements.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

aws-config-detect-environment-variables-secrets-terraform's People

Contributors

amazon-auto avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.