Skip to content

Commit 0ac699d

Browse files
jinrohdiogocpAlicia Scott
authored
Update documentation with general architecture and concepts (#143)
* Update documentation with general architecture and concepts * Update modules/scanning-delegate-role/README.md Co-authored-by: Diogo Pereira <[email protected]> * Apply suggestions from code review Co-authored-by: Diogo Pereira <[email protected]> * Apply suggestions from code review Co-authored-by: Alicia Scott <[email protected]> --------- Co-authored-by: Diogo Pereira <[email protected]> Co-authored-by: Alicia Scott <[email protected]>
1 parent 35538f4 commit 0ac699d

File tree

7 files changed

+93
-7
lines changed

7 files changed

+93
-7
lines changed

README.md

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,34 @@ Before using this module, make sure you have the following:
1212
## Usage
1313

1414
To use this module in your Terraform configuration, add the following code in your existing Terraform code:
15+
1516
```hcl
17+
# First we need to define the proper roles for our scanners. It consists of two different modules that have a two way bindings between them.
18+
19+
# 1. The "scanning delegate role" defines all the policies and IAM roles necessary for the scanner to interact and scan some specific account resources.
20+
# It shall be created for every account that the agentless scanner will be able scan. These roles are meant to be assumed by the "agentless scanner role".
21+
module "delegate_role" {
22+
source = "git::https://github.com/DataDog/terraform-module-datadog-agentless-scanner//modules/scanning-delegate-role"
23+
24+
scanner_roles = [module.scanner_role.role.arn]
25+
}
26+
27+
# 2. The "agentless scanner role" creates an EC2 instance profile along with an IAM role allowing the EC2 instance scanner to assume the scanning delegate role(s).
28+
# It shall be created in the same account as the agentless scanner instance.
1629
module "scanner_role" {
1730
source = "git::https://github.com/DataDog/terraform-module-datadog-agentless-scanner//modules/agentless-scanner-role"
1831
1932
account_roles = [module.delegate_role.role.arn]
2033
api_key_secret_arns = [module.agentless_scanner.api_key_secret_arn]
2134
}
2235
23-
module "delegate_role" {
24-
source = "git::https://github.com/DataDog/terraform-module-datadog-agentless-scanner//modules/scanning-delegate-role"
25-
26-
scanner_roles = [module.scanner_role.role.arn]
27-
}
36+
# As you can see there is a two way binding between these two "role" modules.
37+
# - the scanner role requires the list of delegate role ARNs for the scanner to assume.
38+
# - the delegate role(s) require the scanner role ARN as input in order to define the trust relationship between the EC2 scanner role and the delegate role to be assumed.
2839
40+
# Finally we can create the agentless scanner instance. It requires the instance profile name that was created by the scanner_role.
41+
# This module will define the VPC, subnets, network and compute resources required for the agentless scanner.
42+
# See the documentation of each module for more information or our examples for a complete setup.
2943
module "agentless_scanner" {
3044
source = "git::https://github.com/DataDog/terraform-module-datadog-agentless-scanner"
3145
@@ -54,6 +68,44 @@ To uninstall, remove the Agentless scanner module from your Terraform code. Remo
5468
> [!WARNING]
5569
> Exercise caution when deleting Terraform resources. Review the plan carefully to ensure everything is in order.
5670
71+
## Architecture
72+
73+
The Agentless Scanner deployment is split into different modules to allow for more flexibility and customization. The following modules are available:
74+
75+
- [scanning-delegate-role](./modules/scanning-delegate-role/): Creates the necessary IAM role and policies for the scanning delegate. It creates an IAM role in a specific account that the scanner can then assume to scan the account. This role allows read access to many different resources (EBS snapshots, Lambdas etc.) in the account to be able to scan them.
76+
- [agentless-scanner-role](./modules/agentless-scanner-role/): Creates the necessary IAM role and policies for the agentless scanner instance. It creates an IAM role that allows the scanner to assume the role of the scanning delegate.
77+
- [instance](./modules/instance/): Creates the EC2 instance that runs the agentless scanner. This instance is launched as part of an Auto Scaling group to ensure high availability.
78+
- [user_data](./modules/user_data/): Creates the user data script that installs and configures the agentless scanner on the EC2 instance.
79+
- [vpc](./modules/vpc/): Creates the VPC, subnets and all network resources required for the agentless scanner.
80+
81+
The main module provided at the root of this repository is a thin wrapper around the vpc, user_data and instance modules, with simplified inputs. The scanning-delegate-role and agentless-scanner-role modules are intended to be used in conjunction with this module, as they define the proper IAM permissions for the scanner.
82+
83+
```mermaid
84+
flowchart TD
85+
subgraph "Account A"
86+
subgraph "Main module"
87+
UD[user_data]
88+
VPC[vpc]
89+
I[instance]
90+
UD-->I
91+
VPC-->I
92+
end
93+
94+
SR[agentless-scanner-role]
95+
SR-->I
96+
97+
DRA[scanning-delegate-role A]
98+
DRA-- trusts -->SR
99+
SR-- assumes -->DRA
100+
end
101+
102+
subgraph "Account B"
103+
DRB[scanning-delegate-role B]
104+
DRB-- trusts -->SR
105+
SR-- assumes -->DRB
106+
end
107+
```
108+
57109
## Examples
58110

59111
For complete examples, refer to the [examples](./examples/) directory in this repository.

examples/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ To scan across accounts, see the [example](cross_account/README.md)
2020
# Custom VPC Example
2121

2222
If you want to avoid creating a new VPC for the Agentless scanners, and you want to reuse one of your own, see the [example](custom_vpc/README.md)
23+
24+
# Custom Agent Configurations Example
25+
26+
If you want to add custom configurations for our Datadog Agent running alongside our scanners, see the [example](custom_agent_configurations/README.md)

modules/agentless-scanner-role/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Description
2+
3+
The agentless-scanner-role module creates the proper role and policies for the agentless scanner instance to be able to assume the scanning delegate roles.
4+
5+
It exports the role and instance profile that should be attached to the agentless scanner instance.
6+
17
<!-- BEGIN_TF_DOCS -->
28
## Requirements
39

modules/instance/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Description
2+
3+
The instance module can be used to spawn a dedicated instance specifically crafted for running the agentless scanner.
4+
5+
It creates an auto scaling group with a launch template that installs the agentless scanner on the instance.
6+
17
<!-- BEGIN_TF_DOCS -->
28
## Requirements
39

@@ -45,4 +51,4 @@ No modules.
4551
## Outputs
4652

4753
No outputs.
48-
<!-- END_TF_DOCS -->
54+
<!-- END_TF_DOCS -->

modules/scanning-delegate-role/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Description
2+
3+
The scanning-delegate-role module creates the proper role and policies to allow the agentless scanner to interact with AWS services of a specific account.
4+
5+
It should be installed in every account that the agentless scanner will scan.
6+
17
<!-- BEGIN_TF_DOCS -->
28
## Requirements
39

modules/user_data/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Description
2+
3+
The user_data module exports a script that can be used to install the Datadog agentless scanner on a target instance. This script can be configured to install the scanner.
4+
5+
It is then used to create the launch template for the agentless scanner instance.
6+
17
<!-- BEGIN_TF_DOCS -->
28
## Requirements
39

modules/vpc/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Description
2+
3+
The vpc module can be used to spawn a dedicated VPC specifically crafted for running the agentless scanner instance.
4+
5+
It provides dedicated private subnet, associated with the proper private endpoints to AWS services in order to reduce the network cost induced by scanning resources.
6+
17
<!-- BEGIN_TF_DOCS -->
28
## Requirements
39

@@ -61,4 +67,4 @@ No modules.
6167
| <a name="output_public_subnets"></a> [public\_subnets](#output\_public\_subnets) | The public subnets of the created VPC |
6268
| <a name="output_routing_ready"></a> [routing\_ready](#output\_routing\_ready) | Indicates whether routing resources have been successfully provisioned |
6369
| <a name="output_vpc"></a> [vpc](#output\_vpc) | The VPC created for the Datadog agentless scanner |
64-
<!-- END_TF_DOCS -->
70+
<!-- END_TF_DOCS -->

0 commit comments

Comments
 (0)