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

fix: tf module source syntax #323

Merged
merged 1 commit into from Jul 10, 2023
Merged

fix: tf module source syntax #323

merged 1 commit into from Jul 10, 2023

Conversation

gcharest
Copy link
Contributor

Summary | Résumé

Fix TF module source syntax

Signed-off-by: Guillaume Charest <guillaume.charest@cds-snc.ca>
@github-actions
Copy link

base

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

⚠️   Warning: resources will be destroyed by this change!

Plan: 4 to add, 0 to change, 4 to destroy
Show summary
CHANGE NAME
add module.oidc.aws_iam_role.this[&quot;gh_admin_role&quot;]
module.oidc.aws_iam_role.this[&quot;gh_plan_role&quot;]
delete module.oidc.aws_iam_role.this[0]
module.oidc.aws_iam_role.this[1]
recreate module.vpc.aws_network_acl_rule.block_rdp[0]
module.vpc.aws_network_acl_rule.block_ssh[0]
Show plan
Resource actions are indicated with the following symbols:
  + create
  - destroy
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.oidc.aws_iam_role.this[0] will be destroyed
  # (because resource does not use count)
  - resource "aws_iam_role" "this" {
      - arn                   = "arn:aws:iam::794722365809:role/gh_plan_role" -> null
      - assume_role_policy    = jsonencode(
            {
              - Statement = [
                  - {
                      - Action    = "sts:AssumeRoleWithWebIdentity"
                      - Condition = {
                          - StringLike = {
                              - "token.actions.githubusercontent.com:sub" = "repo:cds-snc/security-tools:*"
                            }
                        }
                      - Effect    = "Allow"
                      - Principal = {
                          - Federated = "arn:aws:iam::794722365809:oidc-provider/token.actions.githubusercontent.com"
                        }
                      - Sid       = ""
                    },
                ]
              - Version   = "2012-10-17"
            }
        ) -> null
      - create_date           = "2022-05-13T13:14:57Z" -> null
      - force_detach_policies = false -> null
      - id                    = "gh_plan_role" -> null
      - managed_policy_arns   = [
          - "arn:aws:iam::794722365809:policy/TFPlan",
          - "arn:aws:iam::aws:policy/ReadOnlyAccess",
        ] -> null
      - max_session_duration  = 3600 -> null
      - name                  = "gh_plan_role" -> null
      - path                  = "/" -> null
      - role_last_used        = [
          - {
              - last_used_date = "2023-07-09T09:04:25Z"
              - region         = "ca-central-1"
            },
        ] -> null
      - tags                  = {
          - "CostCentre" = "security-tools-794722365809"
          - "Terraform"  = "true"
        } -> null
      - tags_all              = {
          - "CostCentre" = "security-tools-794722365809"
          - "Terraform"  = "true"
        } -> null
      - unique_id             = "AROA3SCJE6FYXRDNJ27BQ" -> null

      - inline_policy {}
    }

  # module.oidc.aws_iam_role.this[1] will be destroyed
  # (because resource does not use count)
  - resource "aws_iam_role" "this" {
      - arn                   = "arn:aws:iam::794722365809:role/gh_admin_role" -> null
      - assume_role_policy    = jsonencode(
            {
              - Statement = [
                  - {
                      - Action    = "sts:AssumeRoleWithWebIdentity"
                      - Condition = {
                          - StringLike = {
                              - "token.actions.githubusercontent.com:sub" = "repo:cds-snc/security-tools:ref:refs/heads/main"
                            }
                        }
                      - Effect    = "Allow"
                      - Principal = {
                          - Federated = "arn:aws:iam::794722365809:oidc-provider/token.actions.githubusercontent.com"
                        }
                      - Sid       = ""
                    },
                ]
              - Version   = "2012-10-17"
            }
        ) -> null
      - create_date           = "2022-05-13T13:14:57Z" -> null
      - force_detach_policies = false -> null
      - id                    = "gh_admin_role" -> null
      - managed_policy_arns   = [
          - "arn:aws:iam::aws:policy/AdministratorAccess",
        ] -> null
      - max_session_duration  = 3600 -> null
      - name                  = "gh_admin_role" -> null
      - path                  = "/" -> null
      - role_last_used        = [
          - {
              - last_used_date = "2023-07-10T04:03:27Z"
              - region         = "ca-central-1"
            },
        ] -> null
      - tags                  = {
          - "CostCentre" = "security-tools-794722365809"
          - "Terraform"  = "true"
        } -> null
      - tags_all              = {
          - "CostCentre" = "security-tools-794722365809"
          - "Terraform"  = "true"
        } -> null
      - unique_id             = "AROA3SCJE6FYVGJADO6ZD" -> null

      - inline_policy {}
    }

  # module.oidc.aws_iam_role.this["gh_admin_role"] 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/security-tools:ref:refs/heads/main",
                                ]
                            }
                        }
                      + Effect    = "Allow"
                      + Principal = {
                          + Federated = "arn:aws:iam::794722365809: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                  = "gh_admin_role"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + role_last_used        = (known after apply)
      + tags                  = {
          + "CostCentre" = "security-tools-794722365809"
          + "Terraform"  = "true"
        }
      + tags_all              = {
          + "CostCentre" = "security-tools-794722365809"
          + "Terraform"  = "true"
        }
      + unique_id             = (known after apply)

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

  # module.oidc.aws_iam_role.this["gh_plan_role"] 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/security-tools:*",
                                ]
                            }
                        }
                      + Effect    = "Allow"
                      + Principal = {
                          + Federated = "arn:aws:iam::794722365809: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                  = "gh_plan_role"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + role_last_used        = (known after apply)
      + tags                  = {
          + "CostCentre" = "security-tools-794722365809"
          + "Terraform"  = "true"
        }
      + tags_all              = {
          + "CostCentre" = "security-tools-794722365809"
          + "Terraform"  = "true"
        }
      + unique_id             = (known after apply)

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

  # module.vpc.aws_network_acl_rule.block_rdp[0] must be replaced
-/+ resource "aws_network_acl_rule" "block_rdp" {
      ~ cidr_block     = "10.0.0.0/16" -> "0.0.0.0/0" # forces replacement
      ~ id             = "nacl-1544954046" -> (known after apply)
      ~ protocol       = "6" -> "tcp"
        # (6 unchanged attributes hidden)
    }

  # module.vpc.aws_network_acl_rule.block_ssh[0] must be replaced
-/+ resource "aws_network_acl_rule" "block_ssh" {
      ~ cidr_block     = "10.0.0.0/16" -> "0.0.0.0/0" # forces replacement
      ~ id             = "nacl-3350424785" -> (known after apply)
      ~ protocol       = "6" -> "tcp"
        # (6 unchanged attributes hidden)
    }

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

Warning: Argument is deprecated

  with module.athena.aws_s3_bucket.this,
  on .terraform/modules/athena/S3/main.tf line 7, in resource "aws_s3_bucket" "this":
   7: resource "aws_s3_bucket" "this" {

Use the aws_s3_bucket_server_side_encryption_configuration resource instead

(and 9 more similar warnings elsewhere)

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

Saved the plan to: plan.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfplan"
Show Conftest results
WARN - plan.json - main - Missing Common Tags: ["aws_iam_user.security_tools"]
WARN - plan.json - main - Missing Common Tags: ["module.attach_tf_plan_policy.aws_iam_policy.this"]

19 tests, 17 passed, 2 warnings, 0 failures, 0 exceptions

@github-actions
Copy link

csp_violation_report_service

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

Plan: 1 to add, 0 to change, 0 to destroy
Show summary
CHANGE NAME
add module.purge_csp_reports_lambda.aws_cloudwatch_query_definition.lambda_statistics
Show plan
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # module.purge_csp_reports_lambda.aws_cloudwatch_query_definition.lambda_statistics will be created
  + resource "aws_cloudwatch_query_definition" "lambda_statistics" {
      + id                  = (known after apply)
      + log_group_names     = [
          + "aws_cloudwatch_log_group.this",
        ]
      + name                = "Lambda Statistics - purge_stale_reports"
      + query_definition_id = (known after apply)
      + query_string        = <<-EOT
            filter @type = “REPORT”
            | stats
            count(@type) as countInvocations,
            count(@initDuration) as countColdStarts, (count(@initDuration)/count(@type))*100 as percentageColdStarts,
            max(@initDuration) as maxColdStartTime,
            avg(@duration) as averageDuration,
            max(@duration) as maxDuration,
            min(@duration) as minDuration,
            avg(@maxMemoryUsed) as averageMemoryUsed,
            max(@memorySize) as memoryAllocated, (avg(@maxMemoryUsed)/max(@memorySize))*100 as percentageMemoryUsed
            by bin(1h) as timeFrame
        EOT
    }

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

Warning: Argument is deprecated

  with aws_ecs_cluster.csp_reports,
  on ecs.tf line 1, in resource "aws_ecs_cluster" "csp_reports":
   1: resource "aws_ecs_cluster" "csp_reports" {

Use the aws_ecs_cluster_capacity_providers resource instead

(and 3 more similar warnings elsewhere)

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

Saved the plan to: plan.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfplan"
Show Conftest results
WARN - plan.json - main - Missing Common Tags: ["aws_ecs_service.csp_reports"]

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

@gcharest gcharest merged commit ba36bfa into main Jul 10, 2023
8 checks passed
@gcharest gcharest deleted the fix/tf_modules_source_syntax branch July 10, 2023 20:06
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.

None yet

2 participants