-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: AWS serverless integration (#106)
* feat: added serveless integration for aws Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com> * feat: added aws serverless integration and GetClientIntegrationToken gql request Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com> * fix: added documentation Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com> * fix: variable name Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com> * fix: update doc Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com> * fix: lint errors Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com> * fix: spelling Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com> * fix: spelling Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com> --------- Signed-off-by: Matthias Theuermann <mtheuermann@infralovers.com>
- Loading branch information
1 parent
dc0deba
commit 6786c25
Showing
6 changed files
with
743 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "mondoo_integration_aws_serverless Resource - terraform-provider-mondoo" | ||
subcategory: "" | ||
description: |- | ||
Continuously scan AWS organization and accounts for misconfigurations and vulnerabilities. | ||
--- | ||
|
||
# mondoo_integration_aws_serverless (Resource) | ||
|
||
Continuously scan AWS organization and accounts for misconfigurations and vulnerabilities. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
variable "mondoo_org" { | ||
description = "Mondoo Organization" | ||
type = string | ||
} | ||
variable "origin_aws_account" { | ||
description = "Origin AWS Account" | ||
type = string | ||
default = "764453172858" | ||
} | ||
variable "aws_region" { | ||
description = "AWS Region" | ||
type = string | ||
default = "us-east-1" | ||
} | ||
variable "aws_account_id" { | ||
description = "value of the AWS account ID" | ||
type = string | ||
} | ||
provider "mondoo" { | ||
region = "us" | ||
} | ||
provider "aws" { | ||
region = var.aws_region | ||
} | ||
data "aws_region" "current" {} | ||
# Create a new space | ||
resource "mondoo_space" "my_space" { | ||
name = "AWS Terraform" | ||
org_id = var.mondoo_org | ||
} | ||
# Setup the AWS integration | ||
resource "mondoo_integration_aws_serverless" "aws_serverless" { | ||
space_id = mondoo_space.my_space.id | ||
name = "AWS Integration" | ||
region = data.aws_region.current.name | ||
is_organization = false | ||
console_sign_in_trigger = true | ||
instance_state_change_trigger = true | ||
account_ids = [var.aws_account_id] | ||
scan_configuration = { | ||
ec2_scan = true | ||
ecr_scan = false | ||
ecs_scan = false | ||
cron_scan_in_hours = 24 | ||
ec2_scan_options = { | ||
ssm = true | ||
ebs_volume_scan = true | ||
ebs_scan_options = { | ||
target_instances_per_scanner = 5 | ||
max_asg_instances = 10 | ||
} | ||
instance_connect = false | ||
} | ||
} | ||
} | ||
# for single account deploys | ||
resource "aws_cloudformation_stack" "mondoo_stack" { | ||
name = "mondoo-stack" | ||
template_url = "https://s3.amazonaws.com/mondoo.${data.aws_region.current.name}/mondoo-lambda-stackset-cf.json" | ||
capabilities = ["CAPABILITY_NAMED_IAM"] | ||
parameters = { | ||
MondooIntegrationMrn = mondoo_integration_aws_serverless.aws_serverless.mrn | ||
MondooToken = mondoo_integration_aws_serverless.aws_serverless.token | ||
OriginAwsAccount = var.origin_aws_account | ||
} | ||
} | ||
# for organisation wide deploys use aws_cloudformation_stack_set and aws_cloudformation_stack_set_instance instead of aws_cloudformation_stack | ||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack_set | ||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack_set_instance | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) Name of the integration. | ||
- `region` (String) AWS region. | ||
- `scan_configuration` (Attributes) (see [below for nested schema](#nestedatt--scan_configuration)) | ||
- `space_id` (String) Mondoo Space Identifier. | ||
|
||
### Optional | ||
|
||
- `account_ids` (List of String) List of AWS account IDs. | ||
- `console_sign_in_trigger` (Boolean) Enable console sign in trigger. | ||
- `instance_state_change_trigger` (Boolean) Enable instance state change trigger. | ||
- `is_organization` (Boolean) Is organization. | ||
|
||
### Read-Only | ||
|
||
- `mrn` (String) Integration identifier | ||
- `token` (String) Integration token | ||
|
||
<a id="nestedatt--scan_configuration"></a> | ||
### Nested Schema for `scan_configuration` | ||
|
||
Required: | ||
|
||
- `ec2_scan_options` (Attributes) (see [below for nested schema](#nestedatt--scan_configuration--ec2_scan_options)) | ||
|
||
Optional: | ||
|
||
- `cron_scan_in_hours` (Number) Cron scan in hours. | ||
- `ec2_scan` (Boolean) Enable EC2 scan. | ||
- `ecr_scan` (Boolean) Enable ECR scan. | ||
- `ecs_scan` (Boolean) Enable ECS scan. | ||
- `event_scan_triggers` (Attributes) (see [below for nested schema](#nestedatt--scan_configuration--event_scan_triggers)) | ||
|
||
<a id="nestedatt--scan_configuration--ec2_scan_options"></a> | ||
### Nested Schema for `scan_configuration.ec2_scan_options` | ||
|
||
Required: | ||
|
||
- `ebs_scan_options` (Attributes) (see [below for nested schema](#nestedatt--scan_configuration--ec2_scan_options--ebs_scan_options)) | ||
|
||
Optional: | ||
|
||
- `ebs_volume_scan` (Boolean) Enable EBS volume scan. | ||
- `instance_connect` (Boolean) Enable instance connect. | ||
- `instance_ids_filter` (List of String) List of instance IDs filter. | ||
- `regions_filter` (List of String) List of regions filter. | ||
- `ssm` (Boolean) Enable SSM. | ||
- `tags_filter` (Map of String) Tags filter. | ||
|
||
<a id="nestedatt--scan_configuration--ec2_scan_options--ebs_scan_options"></a> | ||
### Nested Schema for `scan_configuration.ec2_scan_options.ebs_scan_options` | ||
|
||
Optional: | ||
|
||
- `max_asg_instances` (Number) Max ASG instances. | ||
- `target_instances_per_scanner` (Number) Target instances per scanner. | ||
|
||
|
||
|
||
<a id="nestedatt--scan_configuration--event_scan_triggers"></a> | ||
### Nested Schema for `scan_configuration.event_scan_triggers` | ||
|
||
Optional: | ||
|
||
- `event_detail_type` (String) Event detail type. | ||
- `event_source` (String) Event source. | ||
- `scan_type` (String) Scan type. |
12 changes: 12 additions & 0 deletions
12
examples/resources/mondoo_integration_aws_serverless/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
terraform { | ||
required_providers { | ||
mondoo = { | ||
source = "mondoohq/mondoo" | ||
version = ">= 0.4.0" | ||
} | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "5.50.0" | ||
} | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
examples/resources/mondoo_integration_aws_serverless/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
variable "mondoo_org" { | ||
description = "Mondoo Organization" | ||
type = string | ||
} | ||
|
||
variable "origin_aws_account" { | ||
description = "Origin AWS Account" | ||
type = string | ||
default = "764453172858" | ||
} | ||
|
||
variable "aws_region" { | ||
description = "AWS Region" | ||
type = string | ||
default = "us-east-1" | ||
} | ||
|
||
variable "aws_account_id" { | ||
description = "value of the AWS account ID" | ||
type = string | ||
} | ||
|
||
provider "mondoo" { | ||
region = "us" | ||
} | ||
|
||
provider "aws" { | ||
region = var.aws_region | ||
} | ||
|
||
data "aws_region" "current" {} | ||
|
||
# Create a new space | ||
resource "mondoo_space" "my_space" { | ||
name = "AWS Terraform" | ||
org_id = var.mondoo_org | ||
} | ||
|
||
# Setup the AWS integration | ||
resource "mondoo_integration_aws_serverless" "aws_serverless" { | ||
space_id = mondoo_space.my_space.id | ||
name = "AWS Integration" | ||
region = data.aws_region.current.name | ||
is_organization = false | ||
console_sign_in_trigger = true | ||
instance_state_change_trigger = true | ||
account_ids = [var.aws_account_id] | ||
scan_configuration = { | ||
ec2_scan = true | ||
ecr_scan = false | ||
ecs_scan = false | ||
cron_scan_in_hours = 24 | ||
ec2_scan_options = { | ||
ssm = true | ||
ebs_volume_scan = true | ||
ebs_scan_options = { | ||
target_instances_per_scanner = 5 | ||
max_asg_instances = 10 | ||
} | ||
instance_connect = false | ||
} | ||
} | ||
} | ||
|
||
# for single account deploys | ||
resource "aws_cloudformation_stack" "mondoo_stack" { | ||
name = "mondoo-stack" | ||
template_url = "https://s3.amazonaws.com/mondoo.${data.aws_region.current.name}/mondoo-lambda-stackset-cf.json" | ||
capabilities = ["CAPABILITY_NAMED_IAM"] | ||
parameters = { | ||
MondooIntegrationMrn = mondoo_integration_aws_serverless.aws_serverless.mrn | ||
MondooToken = mondoo_integration_aws_serverless.aws_serverless.token | ||
OriginAwsAccount = var.origin_aws_account | ||
} | ||
} | ||
|
||
# for organisation wide deploys use aws_cloudformation_stack_set and aws_cloudformation_stack_set_instance instead of aws_cloudformation_stack | ||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack_set | ||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack_set_instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.