Skip to content

Commit a16d6b1

Browse files
miketnthayk99iru
authored
feat: new beta scanning ecr (#131)
⚠️ currently for testing purpose only. not supported yet available examples - ✅ single and org ecs - ✅ single k8s, apprunner --- to be tested with snippet (for org) ``` terraform { required_providers { sysdig = { source = "sysdiglabs/sysdig" } } } provider "sysdig" { sysdig_secure_url = var.url sysdig_secure_api_token = var.api_token } provider "aws" { region = var.region } provider "aws" { alias = "member" region = var.region assume_role { role_arn = var.assume_role_arn } } module "secure-for-cloud_example_organizational" { providers = { aws.member = aws.member } source = "github.com/sysdiglabs/terraform-aws-cloudvision//examples/organizational?ref=new-beta-scanning-ecr" name = var.name deploy_beta_image_scanning_ecr = true sysdig_secure_for_cloud_member_account_id = var.member_account_id } --- before merging - ✅ [revert the tag before merge and rollback to `quay.io/sysdig/cloud-connector:latest`](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/compare/new-beta-scanning-ecr?expand=1#diff-ce830ac4b16a540ab381428ae0ff9d043ceae7063638ff36a93ef3daf2b7a82eR128) - this has been partially released already ``` <!-- Thank you for your contribution! ## General recommendations Check contribution guidelines at https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/blob/master/CONTRIBUTE.md#contribution-checklist For a cleaner PR make sure you follow these recommendations: - Review modified files and delete small changes that were not intended and maybe slip the commit. - Use Pull Request Drafts for visibility on Work-In-Progress branches and use them on daily mob/pairing for team review - Unless an external revision is desired, in order to validate or gather some feedback, you are free to merge as long as **validation checks are green-lighted** ## Checklist - [ ] If `test/fixtures/*/main.tf` files are modified. I have updated: - [ ] the snippets in the README.md file under root folder. - [ ] the snippets in the README.md file for the corresponding example. - [ ] If `examples` folder are modified. I have updated: - [ ] README.md file with pertinent changes. - [ ] `test/fixtures/*/main.tf` in case the snippet needs modifications. - [ ] If any architectural change has been made, I have updated the diagrams. --> Co-authored-by: Hayk Kocharyan <[email protected]> Co-authored-by: iru <[email protected]>
1 parent 36840d3 commit a16d6b1

File tree

22 files changed

+97
-34
lines changed

22 files changed

+97
-34
lines changed

examples/organizational/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ $ terraform apply
187187
| <a name="input_connector_ecs_task_role_name"></a> [connector\_ecs\_task\_role\_name](#input\_connector\_ecs\_task\_role\_name) | Name for the ecs task role. This is only required to resolve cyclic dependency with organizational approach | `string` | `"organizational-ECSTaskRole"` | no |
188188
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | Whether to deploy or not the cloud benchmarking | `bool` | `true` | no |
189189
| <a name="input_deploy_benchmark_organizational"></a> [deploy\_benchmark\_organizational](#input\_deploy\_benchmark\_organizational) | true/false whether benchmark module should be deployed on organizational or single-account mode (1 role per org accounts if true, 1 role in default aws provider account if false)</li></ul> | `bool` | `true` | no |
190+
| <a name="input_deploy_beta_image_scanning_ecr"></a> [deploy\_beta\_image\_scanning\_ecr](#input\_deploy\_beta\_image\_scanning\_ecr) | true/false whether to deploy the beta image scanning on ECR pushed images (experimental and unsupported) | `bool` | `false` | no |
190191
| <a name="input_deploy_image_scanning_ecr"></a> [deploy\_image\_scanning\_ecr](#input\_deploy\_image\_scanning\_ecr) | true/false whether to deploy the image scanning on ECR pushed images | `bool` | `false` | no |
191192
| <a name="input_deploy_image_scanning_ecs"></a> [deploy\_image\_scanning\_ecs](#input\_deploy\_image\_scanning\_ecs) | true/false whether to deploy the image scanning on ECS running images | `bool` | `false` | no |
192193
| <a name="input_ecs_cluster_name"></a> [ecs\_cluster\_name](#input\_ecs\_cluster\_name) | Name of a pre-existing ECS (elastic container service) cluster. If defaulted, a new ECS cluster/VPC/Security Group will be created. If specified all three parameters `ecs_cluster_name`, `ecs_vpc_id` and `ecs_vpc_subnets_private_ids` are required. ECS location will/must be within the `sysdig_secure_for_cloud_member_account_id` parameter accountID | `string` | `"create"` | no |

examples/organizational/main.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# with default provider
44
#-------------------------------------
55
locals {
6-
deploy_same_account = data.aws_caller_identity.me.account_id == var.sysdig_secure_for_cloud_member_account_id
6+
deploy_same_account = data.aws_caller_identity.me.account_id == var.sysdig_secure_for_cloud_member_account_id
7+
deploy_old_image_scanning_with_codebuild = (var.deploy_image_scanning_ecr && !var.deploy_beta_image_scanning_ecr) || var.deploy_image_scanning_ecs
78
}
89

910
module "resource_group" {
@@ -40,7 +41,7 @@ module "ssm" {
4041
# cloud-connector
4142
#-------------------------------------
4243
module "codebuild" {
43-
count = var.deploy_image_scanning_ecr || var.deploy_image_scanning_ecs ? 1 : 0
44+
count = local.deploy_old_image_scanning_with_codebuild ? 1 : 0
4445

4546
providers = {
4647
aws = aws.member
@@ -64,8 +65,9 @@ module "cloud_connector" {
6465

6566
secure_api_token_secret_name = module.ssm.secure_api_token_secret_name
6667

67-
deploy_image_scanning_ecr = var.deploy_image_scanning_ecr
68-
deploy_image_scanning_ecs = var.deploy_image_scanning_ecs
68+
deploy_beta_image_scanning_ecr = var.deploy_beta_image_scanning_ecr
69+
deploy_image_scanning_ecr = var.deploy_image_scanning_ecr
70+
deploy_image_scanning_ecs = var.deploy_image_scanning_ecs
6971

7072
#
7173
# note;

examples/organizational/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ variable "existing_cloudtrail_config" {
8282
# scanning configuration
8383
#
8484

85+
variable "deploy_beta_image_scanning_ecr" {
86+
type = bool
87+
description = "true/false whether to deploy the beta image scanning on ECR pushed images (experimental and unsupported)"
88+
default = false
89+
}
90+
8591
variable "deploy_image_scanning_ecr" {
8692
type = bool
8793
description = "true/false whether to deploy the image scanning on ECR pushed images"

examples/single-account-apprunner/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ $ terraform apply
101101
| <a name="input_cloudtrail_kms_enable"></a> [cloudtrail\_kms\_enable](#input\_cloudtrail\_kms\_enable) | true/false whether cloudtrail delivered events to S3 should persist encrypted | `bool` | `true` | no |
102102
| <a name="input_cloudtrail_sns_arn"></a> [cloudtrail\_sns\_arn](#input\_cloudtrail\_sns\_arn) | ARN of a pre-existing cloudtrail\_sns. If defaulted, a new cloudtrail will be created. ARN of a pre-existing cloudtrail\_sns. If defaulted, a new cloudtrail will be created. If specified, sysdig deployment account and region must match with the specified SNS | `string` | `"create"` | no |
103103
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | Whether to deploy or not the cloud benchmarking | `bool` | `true` | no |
104+
| <a name="input_deploy_beta_image_scanning_ecr"></a> [deploy\_beta\_image\_scanning\_ecr](#input\_deploy\_beta\_image\_scanning\_ecr) | true/false whether to deploy the beta image scanning on ECR pushed images (experimental and unsupported) | `bool` | `false` | no |
104105
| <a name="input_deploy_image_scanning_ecr"></a> [deploy\_image\_scanning\_ecr](#input\_deploy\_image\_scanning\_ecr) | true/false whether to deploy the image scanning on ECR pushed images | `bool` | `false` | no |
105106
| <a name="input_deploy_image_scanning_ecs"></a> [deploy\_image\_scanning\_ecs](#input\_deploy\_image\_scanning\_ecs) | true/false whether to deploy the image scanning on ECS running images | `bool` | `false` | no |
106107
| <a name="input_name"></a> [name](#input\_name) | Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances | `string` | `"sfc"` | no |

examples/single-account-apprunner/main.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ module "cloud_connector" {
4343
build_project_name = length(module.codebuild) == 1 ? module.codebuild[0].project_name : "na"
4444

4545
cloudconnector_ecr_image_uri = var.cloudconnector_ecr_image_uri
46-
deploy_image_scanning_ecr = var.deploy_image_scanning_ecr
47-
deploy_image_scanning_ecs = var.deploy_image_scanning_ecs
46+
47+
48+
deploy_beta_image_scanning_ecr = var.deploy_beta_image_scanning_ecr
49+
deploy_image_scanning_ecr = var.deploy_image_scanning_ecr
50+
deploy_image_scanning_ecs = var.deploy_image_scanning_ecs
4851

4952
cloudtrail_sns_arn = local.cloudtrail_sns_arn
5053
tags = var.tags

examples/single-account-apprunner/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ variable "cloudtrail_kms_enable" {
3030
# scanning configuration
3131
#
3232

33+
variable "deploy_beta_image_scanning_ecr" {
34+
type = bool
35+
description = "true/false whether to deploy the beta image scanning on ECR pushed images (experimental and unsupported)"
36+
default = false
37+
}
38+
3339
variable "deploy_image_scanning_ecr" {
3440
type = bool
3541
description = "true/false whether to deploy the image scanning on ECR pushed images"

examples/single-account-ecs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ $ terraform apply
102102
| <a name="input_cloudtrail_s3_bucket_expiration_days"></a> [cloudtrail\_s3\_bucket\_expiration\_days](#input\_cloudtrail\_s3\_bucket\_expiration\_days) | Number of days that the logs will persist in the bucket | `number` | `5` | no |
103103
| <a name="input_cloudtrail_sns_arn"></a> [cloudtrail\_sns\_arn](#input\_cloudtrail\_sns\_arn) | ARN of a pre-existing cloudtrail\_sns. If defaulted, a new cloudtrail will be created. If specified, sysdig deployment account and region must match with the specified SNS | `string` | `"create"` | no |
104104
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | Whether to deploy or not the cloud benchmarking | `bool` | `true` | no |
105+
| <a name="input_deploy_beta_image_scanning_ecr"></a> [deploy\_beta\_image\_scanning\_ecr](#input\_deploy\_beta\_image\_scanning\_ecr) | true/false whether to deploy the beta image scanning on ECR pushed images (experimental and unsupported) | `bool` | `false` | no |
105106
| <a name="input_deploy_image_scanning_ecr"></a> [deploy\_image\_scanning\_ecr](#input\_deploy\_image\_scanning\_ecr) | true/false whether to deploy the image scanning on ECR pushed images | `bool` | `false` | no |
106107
| <a name="input_deploy_image_scanning_ecs"></a> [deploy\_image\_scanning\_ecs](#input\_deploy\_image\_scanning\_ecs) | true/false whether to deploy the image scanning on ECS running images | `bool` | `false` | no |
107108
| <a name="input_ecs_cluster_name"></a> [ecs\_cluster\_name](#input\_ecs\_cluster\_name) | Name of a pre-existing ECS (elastic container service) cluster. If defaulted, a new ECS cluster/VPC/Security Group will be created. If specified all three parameters `ecs_cluster_name`, `ecs_vpc_id` and `ecs_vpc_subnets_private_ids` are required. | `string` | `"create"` | no |

examples/single-account-ecs/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ module "cloud_connector" {
4343

4444
secure_api_token_secret_name = module.ssm.secure_api_token_secret_name
4545

46-
deploy_image_scanning_ecr = var.deploy_image_scanning_ecr
47-
deploy_image_scanning_ecs = var.deploy_image_scanning_ecs
46+
deploy_beta_image_scanning_ecr = var.deploy_beta_image_scanning_ecr
47+
deploy_image_scanning_ecr = var.deploy_image_scanning_ecr
48+
deploy_image_scanning_ecs = var.deploy_image_scanning_ecs
4849

4950
is_organizational = false
5051

examples/single-account-ecs/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ variable "ecs_task_memory" {
7777
# scanning configuration
7878
#
7979

80+
variable "deploy_beta_image_scanning_ecr" {
81+
type = bool
82+
description = "true/false whether to deploy the beta image scanning on ECR pushed images (experimental and unsupported)"
83+
default = false
84+
}
85+
8086
variable "deploy_image_scanning_ecr" {
8187
type = bool
8288
description = "true/false whether to deploy the image scanning on ECR pushed images"

examples/single-account-k8s/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ $ terraform apply
120120
| <a name="input_cloudtrail_sns_arn"></a> [cloudtrail\_sns\_arn](#input\_cloudtrail\_sns\_arn) | ARN of a pre-existing cloudtrail\_sns. If defaulted, a new cloudtrail will be created. If specified, deployment region must match Cloudtrail S3 bucket region | `string` | `"create"` | no |
121121
| <a name="input_deploy_aws_iam_user"></a> [deploy\_aws\_iam\_user](#input\_deploy\_aws\_iam\_user) | true/false whether to deploy an iam user. if set to false, check [required role permissions](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/blob/master/resources/policy-single-account-k8s-aws.json) | `bool` | `true` | no |
122122
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | Whether to deploy or not the cloud benchmarking | `bool` | `true` | no |
123+
| <a name="input_deploy_beta_image_scanning_ecr"></a> [deploy\_beta\_image\_scanning\_ecr](#input\_deploy\_beta\_image\_scanning\_ecr) | true/false whether to deploy the beta image scanning on ECR pushed images (experimental and unsupported) | `bool` | `false` | no |
123124
| <a name="input_deploy_image_scanning_ecr"></a> [deploy\_image\_scanning\_ecr](#input\_deploy\_image\_scanning\_ecr) | true/false whether to deploy the image scanning on ECR pushed images | `bool` | `false` | no |
124125
| <a name="input_deploy_image_scanning_ecs"></a> [deploy\_image\_scanning\_ecs](#input\_deploy\_image\_scanning\_ecs) | true/false whether to deploy the image scanning on ECS running images | `bool` | `false` | no |
125126
| <a name="input_name"></a> [name](#input\_name) | Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances | `string` | `"sfc"` | no |

0 commit comments

Comments
 (0)