Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(modular): handle deprecated resources and fix warnings #20

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions modules/agentless-scanning/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ resource "aws_iam_role" "scanning_stackset_admin_role" {
name = "AWSCloudFormationStackSetAdministrationRoleForScanning"
tags = var.tags

assume_role_policy = <<EOF
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
Expand All @@ -84,7 +84,12 @@ resource "aws_iam_role" "scanning_stackset_admin_role" {
]
}
EOF
managed_policy_arns = ["arn:aws:iam::aws:policy/AWSCloudFormationFullAccess"]
}

resource "aws_iam_role_policy_attachments_exclusive" "scanning_stackset_admin_role_managed_policy" {
count = !var.auto_create_stackset_roles ? 0 : 1
role_name = aws_iam_role.scanning_stackset_admin_role[0].id
policy_arns = ["arn:aws:iam::aws:policy/AWSCloudFormationFullAccess"]
}

resource "aws_iam_role_policy" "scanning_stackset_admin_role_policy" {
Expand Down Expand Up @@ -135,9 +140,12 @@ resource "aws_iam_role" "scanning_stackset_execution_role" {
]
}
EOF
managed_policy_arns = [
"arn:aws:iam::aws:policy/AWSCloudFormationFullAccess"
]
}

resource "aws_iam_role_policy_attachments_exclusive" "scanning_stackset_execution_role_managed_policy" {
count = !var.auto_create_stackset_roles ? 0 : 1
role_name = aws_iam_role.scanning_stackset_execution_role[0].id
policy_arns = ["arn:aws:iam::aws:policy/AWSCloudFormationFullAccess"]
}

resource "aws_iam_role_policy" "scanning_stackset_execution_role_policy" {
Expand Down
14 changes: 10 additions & 4 deletions modules/config-posture/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ data "sysdig_secure_tenant_external_id" "external_id" {}
# Since this is not an Organizational deploy, create role/polices directly
#----------------------------------------------------------
resource "aws_iam_role" "cspm_role" {
name = local.config_posture_role_name
tags = var.tags
assume_role_policy = <<EOF
name = local.config_posture_role_name
tags = var.tags
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
Expand All @@ -40,7 +40,13 @@ resource "aws_iam_role" "cspm_role" {
]
}
EOF
managed_policy_arns = ["arn:aws:iam::aws:policy/SecurityAudit"]
}

resource "aws_iam_role_policy_attachments_exclusive" "cspm_role_managed_policy" {
role_name = aws_iam_role.cspm_role.id
policy_arns = [
"arn:aws:iam::aws:policy/SecurityAudit"
]
}

resource "aws_iam_role_policy" "cspm_role_policy" {
Expand Down
18 changes: 15 additions & 3 deletions modules/integrations/event-bridge/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ resource "aws_iam_role" "event_bus_stackset_admin_role" {
name = "AWSCloudFormationStackSetAdministrationRoleForEB"
tags = var.tags

assume_role_policy = <<EOF
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
Expand All @@ -73,7 +73,14 @@ resource "aws_iam_role" "event_bus_stackset_admin_role" {
]
}
EOF
managed_policy_arns = ["arn:aws:iam::aws:policy/AWSCloudFormationFullAccess"]
}

resource "aws_iam_role_policy_attachments_exclusive" "event_bus_stackset_admin_role_managed_policy" {
count = !var.auto_create_stackset_roles ? 0 : 1
role_name = aws_iam_role.event_bus_stackset_admin_role[0].id
policy_arns = [
"arn:aws:iam::aws:policy/AWSCloudFormationFullAccess"
]
}

#-----------------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -105,7 +112,12 @@ resource "aws_iam_role" "event_bus_stackset_execution_role" {
]
}
EOF
managed_policy_arns = [
}

resource "aws_iam_role_policy_attachments_exclusive" "event_bus_stackset_execution_role_managed_policy" {
count = !var.auto_create_stackset_roles ? 0 : 1
role_name = aws_iam_role.event_bus_stackset_execution_role[0].id
policy_arns = [
"arn:aws:iam::aws:policy/AWSCloudFormationFullAccess",
"arn:aws:iam::aws:policy/AmazonEventBridgeFullAccess"
]
Expand Down
21 changes: 13 additions & 8 deletions modules/onboarding/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,28 @@ resource "aws_iam_role" "onboarding_role" {
]
}
EOF
managed_policy_arns = compact([
"arn:aws:iam::aws:policy/AWSAccountManagementReadOnlyAccess",
var.is_organizational ? "arn:aws:iam::aws:policy/AWSOrganizationsReadOnlyAccess" : ""
])

lifecycle {
ignore_changes = [tags]
}
}

resource "aws_iam_role_policy_attachments_exclusive" "onboarding_role_managed_policy" {
role_name = aws_iam_role.onboarding_role.id
policy_arns = compact([
"arn:aws:iam::aws:policy/AWSAccountManagementReadOnlyAccess",
var.is_organizational ? "arn:aws:iam::aws:policy/AWSOrganizationsReadOnlyAccess" : ""
])
}

data "aws_caller_identity" "current" {}

resource "sysdig_secure_cloud_auth_account" "cloud_auth_account" {
enabled = true
provider_id = data.aws_caller_identity.current.account_id
provider_type = "PROVIDER_AWS"
provider_alias = var.account_alias
enabled = true
provider_id = data.aws_caller_identity.current.account_id
provider_type = "PROVIDER_AWS"
provider_alias = var.account_alias
regulatory_framework = "REGULATORY_FRAMEWORK_UNSPECIFIED"
jose-pablo-camacho marked this conversation as resolved.
Show resolved Hide resolved

component {
type = "COMPONENT_TRUSTED_ROLE"
Expand Down