Skip to content

Commit 7a18058

Browse files
author
iru
authored
chore: remove secretmanager and kms permissions from workload (#60)
* chore: remove secretmanager and kms permissions from workload as they're not required * doc: ssm usage * chore: small changes for future permission refact
1 parent b4fc8c2 commit 7a18058

File tree

4 files changed

+12
-33
lines changed

4 files changed

+12
-33
lines changed

modules/infrastructure/permissions/cloud-scanning/main.tf

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ data "aws_iam_policy_document" "cloud_scanner" {
4444
"ecr:ListTagsForResource",
4545
"ecr:DescribeImageScanFindings"
4646
]
47-
resources = ["*"] # TODO. make an input-var out of this, so user can pin it to its own ECR ARN's
47+
resources = ["*"]
48+
# resources = var.is_organizational ? ["arn:aws:ecr:*:*:repository/*", "arn:aws:ecr-public::*:repository/*", "arn:aws:ecr-public::*:registry/*"] : ["arn:aws:ecr-public::${data.aws_caller_identity.me.account_id}:repository/*", "arn:aws:ecr-public::${data.aws_caller_identity.me.account_id}:repository/*", "arn:aws:ecr-public::${data.aws_caller_identity.me.account_id}:registry/*"]O. make an input-var out of this, so user can pin it to its own ECR ARN's
4849
}
4950

5051
statement {
@@ -53,16 +54,7 @@ data "aws_iam_policy_document" "cloud_scanner" {
5354
actions = [
5455
"ecs:DescribeTaskDefinition"
5556
]
56-
resources = ["*"] # TODO
57-
}
58-
59-
statement {
60-
sid = "AllowScanningTo" # TODO
61-
effect = "Allow"
62-
actions = [
63-
"kms:Decrypt",
64-
"secretsmanager:GetSecretValue"
65-
]
66-
resources = ["*"] # TODO
57+
resources = ["*"]
58+
#resources = [var.is_organizational?"arn:aws:ecs:*:425287181461:cluster/*":var.ecs_cluster_name] # TODO pin-down
6759
}
6860
}

modules/infrastructure/ssm/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# AWS Security Manager
1+
# AWS System Manager
22

33

4+
Sysdig Secure for Cloud uses [ssm](https://docs.aws.amazon.com/systems-manager/latest/userguide/what-is-systems-manager.html) in order to store the `sysdig_secure_api_token` parameter in its "Parameter Store"
5+
and pass it, in a safe way, to all the modules that require it.
6+
47
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
58
## Requirements
69

modules/services/cloud-connector/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ A task deployed on an **ECS deployment** will detect events in your infrastructu
3434
| [aws_iam_role.task](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
3535
| [aws_iam_role_policy.ecr_reader](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
3636
| [aws_iam_role_policy.execution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
37-
| [aws_iam_role_policy.secrets_reader](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
3837
| [aws_iam_role_policy.task](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
3938
| [aws_iam_role_policy.task_definition_reader](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
4039
| [aws_iam_role_policy.task_read_parameters](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
@@ -49,7 +48,6 @@ A task deployed on an **ECS deployment** will detect events in your infrastructu
4948
| [aws_iam_policy_document.execution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
5049
| [aws_iam_policy_document.execution_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
5150
| [aws_iam_policy_document.iam_role_task_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
52-
| [aws_iam_policy_document.secrets_reader](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
5351
| [aws_iam_policy_document.task_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
5452
| [aws_iam_policy_document.task_definition_reader](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
5553
| [aws_iam_policy_document.task_read_parameters](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |

modules/services/cloud-connector/permissions.tf

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ data "aws_iam_policy_document" "iam_role_task_policy" {
5252
"s3:ListBucket",
5353
]
5454
resources = ["*"]
55+
# resources = [var.cloudtrail_s3_arn # would need this as param]
5556
}
5657
statement {
5758
effect = "Allow"
5859
actions = [
5960
"sts:AssumeRole",
6061
]
6162
resources = ["*"]
63+
# resources = [var.connector_ecs_task_role_name]
6264
}
6365

6466
statement {
@@ -107,24 +109,7 @@ data "aws_iam_policy_document" "task_definition_reader" {
107109
"ecs:DescribeTaskDefinition"
108110
]
109111
resources = ["*"]
110-
}
111-
}
112-
113-
114-
resource "aws_iam_role_policy" "secrets_reader" {
115-
name = "SecretsReader"
116-
role = local.ecs_task_role_id
117-
policy = data.aws_iam_policy_document.secrets_reader.json
118-
}
119-
120-
data "aws_iam_policy_document" "secrets_reader" {
121-
statement {
122-
effect = "Allow"
123-
actions = [
124-
"kms:Decrypt",
125-
"secretsmanager:GetSecretValue"
126-
]
127-
resources = ["*"]
112+
# resources = var.is_organizational?["arn:aws:ecs:*:*:cluster/*"]:["arn:aws:ecs:*:${data.aws_caller_identity.me.account_id}:cluster/${var.ecs_cluster_name}"]
128113
}
129114
}
130115

@@ -155,6 +140,7 @@ data "aws_iam_policy_document" "ecr_reader" {
155140
"ecr:DescribeImageScanFindings"
156141
]
157142
resources = ["*"]
143+
# resources = var.is_organizational ? ["arn:aws:ecr:*:*:repository/*", "arn:aws:ecr-public::*:repository/*", "arn:aws:ecr-public::*:registry/*"] : ["arn:aws:ecr-public::${data.aws_caller_identity.me.account_id}:repository/*", "arn:aws:ecr-public::${data.aws_caller_identity.me.account_id}:repository/*", "arn:aws:ecr-public::${data.aws_caller_identity.me.account_id}:registry/*"]
158144
}
159145
}
160146

0 commit comments

Comments
 (0)