Skip to content

Commit b4fc8c2

Browse files
authored
feat: AWS event triggering module (#62)
* feat: aws event triggering module * chore: add module to main README * fix: remove unused parameter * fix: pre-commit
1 parent f963830 commit b4fc8c2

File tree

6 files changed

+106
-1
lines changed

6 files changed

+106
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ Notice that:
116116

117117
**Threat Detection**
118118

119-
Choose one of the rules contained in the `AWS Best Practices` policy and execute it in your AWS account.
119+
Terraform example module to trigger **Create IAM Policy that Allows All** event can be found on [examples/trigger-events](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/blob/master/examples/trigger-events).
120+
121+
In another case, you can do it manually. Choose one of the rules contained in the `AWS Best Practices` policy and execute it in your AWS account.
120122

121123
ex.: 'Delete Bucket Public Access Block' can be easily tested going to an
122124
`S3 bucket > Permissions > Block public access (bucket settings) > edit >

examples/trigger-events/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Sysdig Secure for Cloud in AWS<br/> [ Example :: Trigger-Events]
2+
3+
This example helps to trigger AWS Events. Cloud Connector stack is required to be able to generate events.
4+
After applying this module, a new AWS IAM Policy will be created. **Create IAM Policy that Allows All** event will prompt once the module is applied.
5+
6+
## Prerequisites
7+
8+
Minimum requirements:
9+
10+
1. Deploy Cloud Connector Stack on AWS.
11+
2. Configure [Terraform **AWS** Provider](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)
12+
13+
## Usage
14+
15+
For quick testing, use this snippet on your terraform files
16+
17+
```terraform
18+
provider "aws" {
19+
region = "<AWS-REGION>; ex. us-east-1"
20+
}
21+
22+
module "secure_for_cloud_aws_trigger-events"{
23+
source = "sysdiglabs/secure-for-cloud/aws//examples/trigger-events"
24+
}
25+
```
26+
27+
To run this example you need have your [aws account profile configured in CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) and to execute:
28+
```terraform
29+
$ terraform init
30+
$ terraform plan
31+
$ terraform apply
32+
```
33+
34+
Notice that:
35+
* This example will create resources that cost money.<br/>Run `terraform destroy` when you don't need them anymore
36+
* All created resources will be created within the tags `product:sysdig-secure-for-cloud`, within the resource-group `sysdig-secure-for-cloud`
37+
38+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
39+
## Requirements
40+
41+
| Name | Version |
42+
|------|---------|
43+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.15.0 |
44+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.50.0 |
45+
46+
## Providers
47+
48+
| Name | Version |
49+
|------|---------|
50+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.74.1 |
51+
52+
## Modules
53+
54+
No modules.
55+
56+
## Resources
57+
58+
| Name | Type |
59+
|------|------|
60+
| [aws_iam_policy.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
61+
| [aws_iam_policy_document.flow_log_cloudwatch_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
62+
63+
## Inputs
64+
65+
No inputs.
66+
67+
## Outputs
68+
69+
No outputs.
70+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
71+
72+
73+
## Authors
74+
75+
Module is maintained and supported by [Sysdig](https://sysdig.com).
76+
77+
## License
78+
79+
Apache 2 Licensed. See LICENSE for full details.

examples/trigger-events/main.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
data "aws_iam_policy_document" "flow_log_cloudwatch_assume_role" {
2+
statement {
3+
effect = "Allow"
4+
actions = ["cloudformation:*"]
5+
resources = ["*"]
6+
}
7+
}
8+
9+
resource "aws_iam_policy" "policy" {
10+
name = "test_policy"
11+
description = "Trigger event policy"
12+
13+
# Terraform's "jsonencode" function converts a
14+
# Terraform expression result to valid JSON syntax.
15+
policy = data.aws_iam_policy_document.flow_log_cloudwatch_assume_role.json
16+
}

examples/trigger-events/outputs.tf

Whitespace-only changes.

examples/trigger-events/variables.tf

Whitespace-only changes.

examples/trigger-events/versions.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
terraform {
2+
required_version = ">= 0.15.0"
3+
required_providers {
4+
aws = {
5+
version = ">= 3.50.0"
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)