|
1 | | -## My Project |
| 1 | +# aws-config-detect-environment-variables-secrets |
2 | 2 |
|
3 | | -TODO: Fill this README out! |
| 3 | +Code to deploy a solution to detect secrets/tokens in Lambda functions using AWS Config. |
4 | 4 |
|
5 | | -Be sure to: |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Description](#description) |
| 8 | +- [Prerequisites](#prerequisites) |
| 9 | +- [Dependencies](#dependencies) |
| 10 | +- [Variables](#variables) |
| 11 | +- [Usage](#usage) |
| 12 | + - [Preparing the Lambda layers (Bash Script)](#preparing-the-lambda-layers-bash-script) |
| 13 | + - [Deploying the code (Terraforms)](#deploying-the-code-terraforms) |
| 14 | +- [Security](#security) |
| 15 | +- [License](#license) |
| 16 | + |
| 17 | + |
| 18 | +## Description |
| 19 | + |
| 20 | +This Terraform module create a custom rule on AWS Config that detects secrets/tokens in the Lambda functions in the account. |
| 21 | + |
| 22 | +The following diagram applies to the current solution. |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +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_) |
| 27 | +The AWS Config rule is triggered at any modification of every environment variable in each Lambda functions in the account. |
| 28 | + |
| 29 | +> Pay attention: |
| 30 | +this module is meant to be used as standalone module. |
| 31 | + |
| 32 | +## Prerequisites |
| 33 | + |
| 34 | +* **AWS Config**: |
| 35 | +This module expects that [AWS Config](https://aws.amazon.com/config/) is already up and running in the region where the rules will be deployed. |
| 36 | +The setup can be easily carried out by following the official [documentation](https://docs.aws.amazon.com/config/latest/developerguide/setting-up-aws-config-rules-with-console.html). |
| 37 | + |
| 38 | +* **Docker**: |
| 39 | +In order to properly deploy the resources to your account, Docker needs to be installed on your machine. Please refer to this [link](https://docs.docker.com/get-docker/). |
| 40 | + |
| 41 | +## Dependencies |
| 42 | + |
| 43 | +* **rdklib**: 0.2.0 [Reference](https://github.com/awslabs/aws-config-rdklib); |
| 44 | +* **detect-secrets**: 1.1.0 [Reference](https://github.com/Yelp/detect-secrets) |
| 45 | + |
| 46 | +## Variables |
| 47 | + |
| 48 | +The available variables are described in [variables.tf](./variables.tf) file. |
| 49 | + |
| 50 | +## Usage |
| 51 | + |
| 52 | +In this example we are going to deploy the custom rule that will automatically check all lambda functions for vulnerable environment variables. |
| 53 | + |
| 54 | +### Preparing the Lambda layers (Bash Script) |
| 55 | + |
| 56 | +The lambda function that will be leveraged to carry out the detection process uses two libraries [rdklib](https://github.com/awslabs/aws-config-rdklib) and [detect-secrets](https://github.com/Yelp/detect-secrets) |
| 57 | +Therefore, you need to first ensure those libraries are available to the function in your account as lambda layers. |
| 58 | + |
| 59 | +Use this command in your terminal to prepare them for Terraforms to deploy them in the following section: |
| 60 | + |
| 61 | +```bash |
| 62 | +cd scripts |
| 63 | +./build.sh |
| 64 | +``` |
| 65 | + |
| 66 | +### Deploying the code (Terraforms) |
| 67 | + |
| 68 | +**Option 1:** |
| 69 | +You can use the following sample to utilize the module within your code: |
| 70 | + |
| 71 | +```yaml |
| 72 | +module "deploy_lambda_secrets_detector_rule" { |
| 73 | + config_rule_name = "lambda_has_no_secrets" |
| 74 | + source = "./modules/lambda_has_no_secrets" |
| 75 | + enabled = true |
| 76 | +} |
| 77 | +``` |
| 78 | +Please have a look inside inside [variables.tf](./variables.tf) for all the possible options. |
| 79 | + |
| 80 | +**Option 2:** |
| 81 | +Alternatively, if you have [Terraform](https://www.terraform.io/) installed on your workstation, you can deploy the example by executing: |
| 82 | + |
| 83 | +```bash |
| 84 | +export AWS_PROFILE=$MY_AWS_PROFILE |
| 85 | +terraform init |
| 86 | +terraform apply |
| 87 | +``` |
| 88 | + |
| 89 | +> Pay attention: |
| 90 | +you should first modify the `region` in your AWS Profile in accordance to your requirements. |
6 | 91 |
|
7 | | -* Change the title in this README |
8 | | -* Edit your repository description on GitHub |
9 | 92 |
|
10 | 93 | ## Security |
11 | 94 |
|
12 | | -See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. |
| 95 | +See CONTRIBUTING for more information. |
13 | 96 |
|
14 | 97 | ## License |
15 | 98 |
|
16 | | -This project is licensed under the Apache-2.0 License. |
17 | | - |
| 99 | +This project is licensed under the Apache-2.0 License. |
0 commit comments