Skip to content

Commit e2e7711

Browse files
authored
Merge pull request #7 from non-existing-organization/fix/readme-examples
modify readme, move example script
2 parents 256cbc7 + f6812e4 commit e2e7711

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848

4949
## About The Project
5050

51-
This is a simple project that involves a python script that scans the Ec2 API in search of a certain criteria (currently is fixed to a SG (Security Group) rule matching *0.0.0.0/0*) and then store that SG id in a DynamoDB table. If that criteria is "remediated" the script will delete that SG id from the table, that way you can keep a live record of SG ids you wish to keep monitored. Everything is glued together with terraform which will zip the python script and deploy it to the lambda function.
51+
This is a simple terraform module that deploys an Lambda function and a DynamoDB table and the necessary IAM permissions to allow interaction between them. Inside this same module there's a simple example of how the module is invoked and a simple python script that scans the Security Groups in the region and stores any SG with a "0.0.0.0/0" rule in the DynamoDB table.
5252

53-
I made this project as part of my learning process since i did not have that much practice with the DynamoDB service, but also i wanted to glue everything with python and terraform and have some fun along the way.
53+
The user must provide it's own script, runtime and source code hash.
5454

5555

5656
### Built With
File renamed without changes.

example/example1/main.tf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module "security_group_checker" {
2+
//source = "git::https://github.com/non-existing-organization/terraform_module_security_group_checker.git?ref=master"
23
source = "../../"
3-
source_file = "../../aws-lambda-script/sg-checker.py"
4-
output_path = "sg-checker.zip"
4+
output_path = "aws-lambda-script/sg-checker.zip"
55
function_name = "security_group_checker_lambda"
66
table_name = "sg-checker-table"
77
attribute_name = "SecurityGroupId"
@@ -10,4 +10,12 @@ module "security_group_checker" {
1010
dynamodb_policy_name = "sg-checker-dynamodb-policy"
1111
cloudwatch_event_rule_name = "trigger-sg-checker-lambda"
1212
lambda_role_name = "iam_for_lambda"
13+
lambda_runtime = "python3.8"
14+
source_code_hash = data.archive_file.lambda_zip.output_base64sha256
15+
}
16+
17+
data "archive_file" "lambda_zip" {
18+
type = "zip"
19+
source_file = "aws-lambda-script/sg-checker.py"
20+
output_path = "aws-lambda-script/sg-checker.zip"
1321
}

0 commit comments

Comments
 (0)