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

feat: add SRE Security Hub automation rule role #207

Merged
merged 3 commits into from
Oct 6, 2023

Conversation

patheard
Copy link
Member

@patheard patheard commented Oct 6, 2023

Summary

Add an OIDC rule that can be used by the SRE repo by the tools/aws-security-automation-rules script to manage Security Hub automation rules.

Related

Add an OIDC rule that can be used by the SRE repo by
the `tools/aws-security-automation-rules` script to manage
Security Hub automation rules.
@patheard patheard self-assigned this Oct 6, 2023
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Plan for log_archive/sre_bot

✅   Terraform Init: success
✅   Terraform Validate: success
✅   Terraform Format: success
✅   Terraform Plan: success
✅   Conftest: success

Plan: 3 to add, 0 to change, 0 to destroy
Show summary
CHANGE NAME
add aws_iam_policy.sre_sechub_automation_rules
aws_iam_role_policy_attachment.sre_sechub_automation_rules
module.OIDC_Roles.aws_iam_role.this["sre_sechub_automation_rules_github_action"]
Show plan
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_iam_policy.sre_sechub_automation_rules will be created
  + resource "aws_iam_policy" "sre_sechub_automation_rules" {
      + arn         = (known after apply)
      + id          = (known after apply)
      + name        = "sre_sechub_automation_rules"
      + name_prefix = (known after apply)
      + path        = "/"
      + policy      = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = [
                          + "securityhub:ListAutomationRules",
                          + "securityhub:CreateAutomationRule",
                          + "securityhub:BatchGetAutomationRules",
                          + "securityhub:BatchDeleteAutomationRules",
                        ]
                      + Effect   = "Allow"
                      + Resource = "*"
                      + Sid      = "ManageSecurityHubAutomationRules"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + policy_id   = (known after apply)
      + tags        = {
          + "CostCentre" = "cds-aft-log-archive-production"
          + "Terraform"  = "true"
        }
      + tags_all    = {
          + "CostCentre" = "cds-aft-log-archive-production"
          + "Terraform"  = "true"
        }
    }

  # aws_iam_role_policy_attachment.sre_sechub_automation_rules will be created
  + resource "aws_iam_role_policy_attachment" "sre_sechub_automation_rules" {
      + id         = (known after apply)
      + policy_arn = (known after apply)
      + role       = "sre_sechub_automation_rules_github_action"
    }

  # module.OIDC_Roles.aws_iam_role.this["sre_sechub_automation_rules_github_action"] will be created
  + resource "aws_iam_role" "this" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = "sts:AssumeRoleWithWebIdentity"
                      + Condition = {
                          + StringLike = {
                              + token.actions.githubusercontent.com:sub = [
                                  + "repo:cds-snc/site-reliability-engineering:ref:refs/heads/main",
                                ]
                            }
                        }
                      + Effect    = "Allow"
                      + Principal = {
                          + Federated = "arn:aws:iam::274536870005:oidc-provider/token.actions.githubusercontent.com"
                        }
                      + Sid       = ""
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "sre_sechub_automation_rules_github_action"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + role_last_used        = (known after apply)
      + tags                  = {
          + "CostCentre" = "cds-aft-log-archive-production"
          + "Terraform"  = "true"
        }
      + tags_all              = {
          + "CostCentre" = "cds-aft-log-archive-production"
          + "Terraform"  = "true"
        }
      + unique_id             = (known after apply)

      + inline_policy {
          + name   = (known after apply)
          + policy = (known after apply)
        }
    }

Plan: 3 to add, 0 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: plan.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfplan"
Releasing state lock. This may take a few moments...
Show Conftest results
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.assume_sre_vulnerability_report"]

18 tests, 17 passed, 1 warning, 0 failures, 0 exceptions

@patheard patheard requested a review from a team October 6, 2023 19:42
Copy link
Member

@wanpengyang wanpengyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@patheard patheard merged commit 6c63c4c into main Oct 6, 2023
12 checks passed
@patheard patheard deleted the feat/sre-aws-sechub-role branch October 6, 2023 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants