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

chore: Github workflow deployment script not working as intended #655

Merged
merged 1 commit into from
May 6, 2024

Conversation

craigzour
Copy link
Contributor

@craigzour craigzour commented May 6, 2024

Summary | Résumé

  • Fixed issue with Github workflow Terraform apply actions. We found a scenario where the Terraform modules were not applied because no detected changes in Lambda functions.

@craigzour craigzour self-assigned this May 6, 2024
Copy link

github-actions bot commented May 6, 2024

Staging: load_balancer

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

Plan: 1 to add, 3 to change, 0 to destroy
Show summary
CHANGE NAME
update aws_wafv2_regex_pattern_set.cognito_login_paths
aws_wafv2_regex_pattern_set.valid_app_uri_paths
aws_wafv2_web_acl.forms_acl
add aws_wafv2_rule_group.rate_limiters_group
Show plan
Resource actions are indicated with the following symbols:
  + create
  ~ update in-place

Terraform will perform the following actions:

  # aws_wafv2_regex_pattern_set.cognito_login_paths will be updated in-place
  ~ resource "aws_wafv2_regex_pattern_set" "cognito_login_paths" {
        id          = "06fb5625-dab4-4133-ab2d-2e618dd01c47"
        name        = "cognito_login_paths"
        tags        = {}
        # (5 unchanged attributes hidden)

      + regular_expression {
          + regex_string = "^\\/(api\\/auth\\/(session|csrf))$"
        }

        # (1 unchanged block hidden)
    }

  # aws_wafv2_regex_pattern_set.valid_app_uri_paths will be updated in-place
  ~ resource "aws_wafv2_regex_pattern_set" "valid_app_uri_paths" {
        id          = "2020c3bc-eb87-45f3-8ee7-99cd707612e7"
        name        = "valid_app_uri_paths"
        tags        = {}
        # (5 unchanged attributes hidden)

      - regular_expression {
          - regex_string = "^\\/(?:en|fr)?\\/?(?:(admin|id|api|auth|signup|profile|forms|unsupported-browser|terms-of-use|404)(?:\\/[\\w-]+)?)(?:\\/.*)?$" -> null
        }
      + regular_expression {
          + regex_string = "^\\/(?:en|fr)?\\/?(?:(admin|id|api|auth|signup|profile|forms|unsupported-browser|terms-of-use|contact|support|404)(?:\\/[\\w-]+)?)(?:\\/.*)?$"
        }

        # (4 unchanged blocks hidden)
    }

  # aws_wafv2_rule_group.rate_limiters_group will be created
  + resource "aws_wafv2_rule_group" "rate_limiters_group" {
      + arn         = (known after apply)
      + capacity    = 32
      + id          = (known after apply)
      + lock_token  = (known after apply)
      + name        = "RateLimitersGroup"
      + name_prefix = (known after apply)
      + scope       = "REGIONAL"
      + tags_all    = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }

      + rule {
          + name     = "BlanketRequestLimit"
          + priority = 1

          + action {
              + block {
                }
            }

          + statement {
              + rate_based_statement {
                  + aggregate_key_type = "IP"
                  + limit              = 2000
                }
            }

          + visibility_config {
              + cloudwatch_metrics_enabled = true
              + metric_name                = "BlanketRequestLimit"
              + sampled_requests_enabled   = true
            }
        }
      + rule {
          + name     = "PostRequestLimit"
          + priority = 2

          + action {
              + block {
                }
            }

          + statement {
              + rate_based_statement {
                  + aggregate_key_type = "IP"
                  + limit              = 100

                  + scope_down_statement {
                      + byte_match_statement {
                          + positional_constraint = "EXACTLY"
                          + search_string         = "post"

                          + field_to_match {
                              + method {}
                            }

                          + text_transformation {
                              + priority = 1
                              + type     = "LOWERCASE"
                            }
                        }
                    }
                }
            }

          + visibility_config {
              + cloudwatch_metrics_enabled = true
              + metric_name                = "PostRequestRateLimit"
              + sampled_requests_enabled   = true
            }
        }

      + visibility_config {
          + cloudwatch_metrics_enabled = true
          + metric_name                = "RateLimitersGroup"
          + sampled_requests_enabled   = false
        }
    }

  # aws_wafv2_web_acl.forms_acl will be updated in-place
  ~ resource "aws_wafv2_web_acl" "forms_acl" {
        id            = "e8fc1b67-9d4d-4a29-8c94-65b37b30a231"
        name          = "GCForms"
        tags          = {}
        # (6 unchanged attributes hidden)

      - rule {
          - name     = "PostRequestLimit" -> null
          - priority = 2 -> null

          - action {
              - block {
                }
            }

          - statement {
              - rate_based_statement {
                  - aggregate_key_type = "IP" -> null
                  - limit              = 100 -> null

                  - scope_down_statement {
                      - byte_match_statement {
                          - positional_constraint = "EXACTLY" -> null
                          - search_string         = "post" -> null

                          - field_to_match {
                              - method {}
                            }

                          - text_transformation {
                              - priority = 1 -> null
                              - type     = "LOWERCASE" -> null
                            }
                        }
                    }
                }
            }

          - visibility_config {
              - cloudwatch_metrics_enabled = true -> null
              - metric_name                = "PostRequestRateLimit" -> null
              - sampled_requests_enabled   = true -> null
            }
        }
      - rule {
          - name     = "AWSManagedRulesAmazonIpReputationList" -> null
          - priority = 1 -> null

          - override_action {
              - none {}
            }

          - statement {
              - managed_rule_group_statement {
                  - name        = "AWSManagedRulesAmazonIpReputationList" -> null
                  - vendor_name = "AWS" -> null
                }
            }

          - visibility_config {
              - cloudwatch_metrics_enabled = true -> null
              - metric_name                = "AWSManagedRulesAmazonIpReputationList" -> null
              - sampled_requests_enabled   = true -> null
            }
        }
      - rule {
          - name     = "AWSManagedRulesKnownBadInputsRuleSet" -> null
          - priority = 6 -> null

          - override_action {
              - none {}
            }

          - statement {
              - managed_rule_group_statement {
                  - name        = "AWSManagedRulesKnownBadInputsRuleSet" -> null
                  - vendor_name = "AWS" -> null
                }
            }

          - visibility_config {
              - cloudwatch_metrics_enabled = true -> null
              - metric_name                = "AWSManagedRulesKnownBadInputsRuleSet" -> null
              - sampled_requests_enabled   = true -> null
            }
        }
      - rule {
          - name     = "AWSManagedRulesLinuxRuleSet" -> null
          - priority = 7 -> null

          - override_action {
              - none {}
            }

          - statement {
              - managed_rule_group_statement {
                  - name        = "AWSManagedRulesLinuxRuleSet" -> null
                  - vendor_name = "AWS" -> null
                }
            }

          - visibility_config {
              - cloudwatch_metrics_enabled = true -> null
              - metric_name                = "AWSManagedRulesLinuxRuleSet" -> null
              - sampled_requests_enabled   = true -> null
            }
        }
      + rule {
          + name     = "AWSManagedRulesAmazonIpReputationList"
          + priority = 1

          + override_action {
              + none {}
            }

          + statement {
              + managed_rule_group_statement {
                  + name        = "AWSManagedRulesAmazonIpReputationList"
                  + vendor_name = "AWS"
                }
            }

          + visibility_config {
              + cloudwatch_metrics_enabled = true
              + metric_name                = "AWSManagedRulesAmazonIpReputationList"
              + sampled_requests_enabled   = true
            }
        }
      + rule {
          + name     = "AWSManagedRulesKnownBadInputsRuleSet"
          + priority = 6

          + override_action {
              + none {}
            }

          + statement {
              + managed_rule_group_statement {
                  + name        = "AWSManagedRulesKnownBadInputsRuleSet"
                  + vendor_name = "AWS"
                }
            }

          + visibility_config {
              + cloudwatch_metrics_enabled = true
              + metric_name                = "AWSManagedRulesKnownBadInputsRuleSet"
              + sampled_requests_enabled   = true
            }
        }
      + rule {
          + name     = "AWSManagedRulesLinuxRuleSet"
          + priority = 7

          + override_action {
              + none {}
            }

          + statement {
              + managed_rule_group_statement {
                  + name        = "AWSManagedRulesLinuxRuleSet"
                  + vendor_name = "AWS"
                }
            }

          + visibility_config {
              + cloudwatch_metrics_enabled = true
              + metric_name                = "AWSManagedRulesLinuxRuleSet"
              + sampled_requests_enabled   = true
            }
        }
      + rule {
          + name     = "RateLimitersRuleGroup"
          + priority = 2

          + override_action {
              + none {}
            }

          + statement {
              + rule_group_reference_statement {
                  + arn = (known after apply)
                }
            }

          + visibility_config {
              + cloudwatch_metrics_enabled = true
              + metric_name                = "rate_limiters_rule_group"
              + sampled_requests_enabled   = false
            }
        }

        # (6 unchanged blocks hidden)
    }

Plan: 1 to add, 3 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"
Show Conftest results
WARN - plan.json - main - Missing Common Tags: ["aws_acm_certificate.form_viewer"]
WARN - plan.json - main - Missing Common Tags: ["aws_acm_certificate.form_viewer_maintenance_mode"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudfront_distribution.maintenance_mode"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_role.firehose_waf_logs"]
WARN - plan.json - main - Missing Common Tags: ["aws_kinesis_firehose_delivery_stream.firehose_waf_logs"]
WARN - plan.json - main - Missing Common Tags: ["aws_lb.form_viewer"]
WARN - plan.json - main - Missing Common Tags: ["aws_lb_listener.form_viewer_http"]
WARN - plan.json - main - Missing Common Tags: ["aws_lb_listener.form_viewer_https"]
WARN - plan.json - main - Missing Common Tags: ["aws_lb_target_group.form_viewer_1"]
WARN - plan.json - main - Missing Common Tags: ["aws_lb_target_group.form_viewer_2"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_bucket.maintenance_mode"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_object.maintenance_static_page_css_files[\"style.css\"]"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_object.maintenance_static_page_html_files[\"index-fr.html\"]"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_object.maintenance_static_page_html_files[\"index.html\"]"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_object.maintenance_static_page_ico_files[\"favicon.ico\"]"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_object.maintenance_static_page_svg_files[\"site-unavailable.svg\"]"]
WARN - plan.json - main - Missing Common Tags: ["aws_shield_protection.alb"]
WARN - plan.json - main - Missing Common Tags: ["aws_shield_protection.route53_hosted_zone[0]"]
WARN - plan.json - main - Missing Common Tags: ["aws_wafv2_regex_pattern_set.cognito_login_paths"]
WARN - plan.json - main - Missing Common Tags: ["aws_wafv2_regex_pattern_set.forms_base_url"]
WARN - plan.json - main - Missing Common Tags:...

@craigzour craigzour force-pushed the fix/github-workflow-deployment branch from a075730 to 6d7a5df Compare May 6, 2024 19:31
@craigzour craigzour marked this pull request as ready for review May 6, 2024 19:31
@craigzour craigzour requested a review from wmoussa-gc May 6, 2024 19:31
Copy link

github-actions bot commented May 6, 2024

Staging: app

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

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

Plan: 1 to add, 0 to change, 1 to destroy
Show summary
CHANGE NAME
recreate aws_ecs_task_definition.form_viewer
Show plan
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # aws_ecs_task_definition.form_viewer must be replaced
-/+ resource "aws_ecs_task_definition" "form_viewer" {
      ~ arn                      = "arn:aws:ecs:ca-central-1:687401027353:task-definition/form-viewer:1516" -> (known after apply)
      ~ arn_without_revision     = "arn:aws:ecs:ca-central-1:687401027353:task-definition/form-viewer" -> (known after apply)
      ~ container_definitions    = jsonencode(
          ~ [
              ~ {
                  - cpu              = 0
                  - essential        = true
                  ~ linuxParameters  = {
                      ~ capabilities = {
                          - add  = []
                            # (1 unchanged attribute hidden)
                        }
                    }
                  - mountPoints      = []
                    name             = "form_viewer"
                  ~ portMappings     = [
                      ~ {
                          - hostPort      = 3000
                          - protocol      = "tcp"
                            # (1 unchanged attribute hidden)
                        },
                    ]
                  - systemControls   = []
                  - volumesFrom      = []
                    # (4 unchanged attributes hidden)
                },
            ] # forces replacement
        )
      ~ id                       = "form-viewer" -> (known after apply)
      ~ revision                 = 1516 -> (known after apply)
      - tags                     = {} -> null
        # (9 unchanged attributes hidden)
    }

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

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

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_appautoscaling_target.forms[0]"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_log_group.forms"]
WARN - plan.json - main - Missing Common Tags: ["aws_codedeploy_app.app"]
WARN - plan.json - main - Missing Common Tags: ["aws_codedeploy_deployment_group.app"]
WARN - plan.json - main - Missing Common Tags: ["aws_ecs_cluster.forms"]
WARN - plan.json - main - Missing Common Tags: ["aws_ecs_service.form_viewer"]
WARN - plan.json - main - Missing Common Tags: ["aws_ecs_task_definition.form_viewer"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.cognito"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.forms_dynamodb"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.forms_kms"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.forms_s3"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.forms_secrets_manager"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.forms_sqs"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_role.codedeploy"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_role.forms"]

34 tests, 19 passed, 15 warnings, 0 failures, 0 exceptions

@craigzour craigzour requested a review from patheard May 6, 2024 19:34
@craigzour craigzour enabled auto-merge (squash) May 6, 2024 19:37
@craigzour craigzour merged commit f6d16cf into develop May 6, 2024
6 checks passed
@craigzour craigzour deleted the fix/github-workflow-deployment branch May 6, 2024 19:42
@@ -189,7 +190,7 @@ jobs:
run: terragrunt apply --terragrunt-non-interactive -auto-approve

update-lambda-function-image:
needs: [detect-lambda-changes, build-tag-push-lambda-images, terragrunt-apply-all-modules]
needs: [detect-lambda-changes, terragrunt-apply-all-modules]
Copy link
Contributor Author

@craigzour craigzour May 6, 2024

Choose a reason for hiding this comment

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

Removed the build-tag-push-lambda-images dependency as the terragrunt-apply-all-modules job already waits for the build-tag-push-lambda-images to be completed.

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