Skip to content

feat: add product data and update DynamoDB schemas - #56

Merged
maxsonferovante merged 1 commit into
mainfrom
codex/migrate-lambdas-to-zip
Jun 26, 2026
Merged

feat: add product data and update DynamoDB schemas#56
maxsonferovante merged 1 commit into
mainfrom
codex/migrate-lambdas-to-zip

Conversation

@maxsonferovante

Copy link
Copy Markdown
Contributor
  • Added a new JSON file for product data containing various events and their details.
  • Updated the DynamoDB table for certificates to include new attributes and global secondary indexes for better querying.
  • Enhanced the orders table schema with additional attributes and indexes for participant email and product ID.
  • Modified the participants table to include email, CPF, and city attributes with corresponding indexes.
  • Updated the products table schema to include product name and flags for certificate logos and backgrounds, along with new indexes.
  • Adjusted Lambda IAM policies to allow access to new DynamoDB resources.

@maxsonferovante maxsonferovante self-assigned this Jun 26, 2026
- Added a new JSON file for product data containing various events and their details.
- Updated the DynamoDB table for certificates to include new attributes and global secondary indexes for better querying.
- Enhanced the orders table schema with additional attributes and indexes for participant email and product ID.
- Modified the participants table to include email, CPF, and city attributes with corresponding indexes.
- Updated the products table schema to include product name and flags for certificate logos and backgrounds, along with new indexes.
- Adjusted Lambda IAM policies to allow access to new DynamoDB resources.
@maxsonferovante
maxsonferovante force-pushed the codex/migrate-lambdas-to-zip branch from 2309bba to f1ea1ae Compare June 26, 2026 00:04
@github-actions

Copy link
Copy Markdown

Terraform Plan (shared)

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.

@github-actions

Copy link
Copy Markdown

Terraform Plan (dev)

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.certificates_table.aws_dynamodb_table.certificates must be replaced
-/+ resource "aws_dynamodb_table" "certificates" {
      ~ arn                         = "arn:aws:dynamodb:us-east-1:334318883918:table/tech-floripa-certificates-certificates-dev" -> (known after apply)
      - deletion_protection_enabled = false -> null
      ~ hash_key                    = "id" -> "order_id" # forces replacement
      ~ id                          = "tech-floripa-certificates-certificates-dev" -> (known after apply)
        name                        = "tech-floripa-certificates-certificates-dev"
      - range_key                   = "order_id" -> null # forces replacement
      ~ read_capacity               = 0 -> (known after apply)
      + stream_arn                  = (known after apply)
      - stream_enabled              = false -> null
      + stream_label                = (known after apply)
      + stream_view_type            = (known after apply)
      - table_class                 = "STANDARD" -> null
        tags                        = {
            "CostCenter"  = "low-cost"
            "Entity"      = "Certificate"
            "Environment" = "dev"
            "Name"        = "tech-floripa-certificates-certificates-dev"
            "Project"     = "tech-floripa-certificates"
        }
      ~ write_capacity              = 0 -> (known after apply)
        # (3 unchanged attributes hidden)

      + attribute {
          + name = "participant_email"
          + type = "S"
        }
      + attribute {
          + name = "participant_email_product_key"
          + type = "S"
        }
      + attribute {
          + name = "product_id"
          + type = "N"
        }
      + attribute {
          + name = "success_flag"
          + type = "N"
        }

      + global_secondary_index {
          + hash_key           = "id"
          + name               = "certificate_id_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)
            # (1 unchanged attribute hidden)

          + warm_throughput (known after apply)
        }
      + global_secondary_index {
          + hash_key           = "participant_email"
          + name               = "certificates_by_email_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + range_key          = "order_id"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)

          + warm_throughput (known after apply)
        }
      + global_secondary_index {
          + hash_key           = "participant_email_product_key"
          + name               = "certificates_by_email_product_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + range_key          = "order_id"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)

          + warm_throughput (known after apply)
        }
      + global_secondary_index {
          + hash_key           = "product_id"
          + name               = "certificates_by_product_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + range_key          = "order_id"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)

          + warm_throughput (known after apply)
        }
      + global_secondary_index {
          + hash_key           = "success_flag"
          + name               = "certificates_by_success_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + range_key          = "order_id"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)

          + warm_throughput (known after apply)
        }

      ~ global_table_witness (known after apply)

      ~ point_in_time_recovery (known after apply)
      - point_in_time_recovery {
          - enabled                 = false -> null
          - recovery_period_in_days = 0 -> null
        }

      ~ server_side_encryption {
          ~ kms_key_arn = "arn:aws:kms:us-east-1:334318883918:key/bb0ff81e-9dac-43c3-998d-0abd7b149bec" -> (known after apply)
            # (1 unchanged attribute hidden)
        }

      ~ ttl (known after apply)
      - ttl {
          - enabled        = false -> null
            # (1 unchanged attribute hidden)
        }

      ~ warm_throughput (known after apply)

        # (2 unchanged blocks hidden)
    }

  # module.lambda.aws_iam_role_policy.lambda_custom_policy will be updated in-place
  ~ resource "aws_iam_role_policy" "lambda_custom_policy" {
        id          = "tech-floripa-certificates-lambda-role-dev:tech-floripa-certificates-lambda-policy-dev"
        name        = "tech-floripa-certificates-lambda-policy-dev"
      ~ policy      = jsonencode(
            {
              - Statement = [
                  - {
                      - Action   = [
                          - "dynamodb:GetItem",
                          - "dynamodb:PutItem",
                          - "dynamodb:UpdateItem",
                          - "dynamodb:DeleteItem",
                          - "dynamodb:Query",
                          - "dynamodb:Scan",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:dynamodb:us-east-1:334318883918:table/tech-floripa-certificates-certificates-dev",
                          - "arn:aws:dynamodb:us-east-1:334318883918:table/tech-floripa-certificates-orders-dev",
                          - "arn:aws:dynamodb:us-east-1:334318883918:table/tech-floripa-certificates-participants-dev",
                          - "arn:aws:dynamodb:us-east-1:334318883918:table/tech-floripa-certificates-products-dev",
                        ]
                    },
                  - {
                      - Action   = [
                          - "sqs:SendMessage",
                          - "sqs:ReceiveMessage",
                          - "sqs:DeleteMessage",
                          - "sqs:GetQueueAttributes",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:sqs:us-east-1:334318883918:tech-floripa-certificates-builder-queue",
                          - "arn:aws:sqs:us-east-1:334318883918:tech-floripa-certificates-notification-queue",
                        ]
                    },
                  - {
                      - Action   = [
                          - "s3:GetObject",
                          - "s3:GetObjectVersion",
                          - "s3:PutObject",
                          - "s3:DeleteObject",
                          - "s3:ListBucket",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:s3:::tech-floripa-certificates-dev-bucket",
                          - "arn:aws:s3:::tech-floripa-certificates-dev-bucket/*",
                        ]
                    },
                ]
              - Version   = "2012-10-17"
            }
        ) -> (known after apply)
        # (2 unchanged attributes hidden)
    }

  # module.lambda.aws_iam_role_policy.lambda_notification_custom_policy will be updated in-place
  ~ resource "aws_iam_role_policy" "lambda_notification_custom_policy" {
        id          = "tech-floripa-certificates-lambda-notification-role-dev:tech-floripa-certificates-lambda-notification-policy-dev"
        name        = "tech-floripa-certificates-lambda-notification-policy-dev"
      ~ policy      = jsonencode(
            {
              - Statement = [
                  - {
                      - Action   = [
                          - "dynamodb:GetItem",
                          - "dynamodb:PutItem",
                          - "dynamodb:UpdateItem",
                          - "dynamodb:DeleteItem",
                          - "dynamodb:Query",
                          - "dynamodb:Scan",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:dynamodb:us-east-1:334318883918:table/tech-floripa-certificates-certificates-dev",
                          - "arn:aws:dynamodb:us-east-1:334318883918:table/tech-floripa-certificates-orders-dev",
                          - "arn:aws:dynamodb:us-east-1:334318883918:table/tech-floripa-certificates-participants-dev",
                          - "arn:aws:dynamodb:us-east-1:334318883918:table/tech-floripa-certificates-products-dev",
                        ]
                    },
                  - {
                      - Action   = [
                          - "sqs:SendMessage",
                          - "sqs:ReceiveMessage",
                          - "sqs:DeleteMessage",
                          - "sqs:GetQueueAttributes",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:sqs:us-east-1:334318883918:tech-floripa-certificates-builder-queue",
                          - "arn:aws:sqs:us-east-1:334318883918:tech-floripa-certificates-notification-queue",
                        ]
                    },
                  - {
                      - Action   = [
                          - "s3:GetObject",
                          - "s3:PutObject",
                          - "s3:DeleteObject",
                          - "s3:ListBucket",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:s3:::tech-floripa-certificates-dev-bucket",
                          - "arn:aws:s3:::tech-floripa-certificates-dev-bucket/*",
                        ]
                    },
                ]
              - Version   = "2012-10-17"
            }
        ) -> (known after apply)
        # (2 unchanged attributes hidden)
    }

  # module.orders_table.aws_dynamodb_table.orders will be updated in-place
  ~ resource "aws_dynamodb_table" "orders" {
        id                          = "tech-floripa-certificates-orders-dev"
        name                        = "tech-floripa-certificates-orders-dev"
        tags                        = {
            "CostCenter"  = "low-cost"
            "Entity"      = "Order"
            "Environment" = "dev"
            "Name"        = "tech-floripa-certificates-orders-dev"
            "Project"     = "tech-floripa-certificates"
        }
        # (13 unchanged attributes hidden)

      + attribute {
          + name = "order_date_order_id"
          + type = "S"
        }
      + attribute {
          + name = "order_year_month"
          + type = "S"
        }
      + attribute {
          + name = "participant_email"
          + type = "S"
        }
      + attribute {
          + name = "product_id"
          + type = "N"
        }

      + global_secondary_index {
          + hash_key           = "order_year_month"
          + name               = "orders_by_month_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + range_key          = "order_date_order_id"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)

          + warm_throughput (known after apply)
        }
      + global_secondary_index {
          + hash_key           = "participant_email"
          + name               = "orders_by_email_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + range_key          = "order_id"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)

          + warm_throughput (known after apply)
        }
      + global_secondary_index {
          + hash_key           = "product_id"
          + name               = "orders_by_product_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + range_key          = "order_id"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)

          + warm_throughput (known after apply)
        }

        # (4 unchanged blocks hidden)
    }

  # module.participants_table.aws_dynamodb_table.participants will be updated in-place
  ~ resource "aws_dynamodb_table" "participants" {
        id                          = "tech-floripa-certificates-participants-dev"
        name                        = "tech-floripa-certificates-participants-dev"
        tags                        = {
            "CostCenter"  = "low-cost"
            "Entity"      = "Participant"
            "Environment" = "dev"
            "Name"        = "tech-floripa-certificates-participants-dev"
            "Project"     = "tech-floripa-certificates"
        }
        # (13 unchanged attributes hidden)

      + attribute {
          + name = "city"
          + type = "S"
        }
      + attribute {
          + name = "cpf"
          + type = "S"
        }
      + attribute {
          + name = "email"
          + type = "S"
        }

      + global_secondary_index {
          + hash_key           = "city"
          + name               = "participants_by_city_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + range_key          = "email"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)

          + warm_throughput (known after apply)
        }
      + global_secondary_index {
          + hash_key           = "cpf"
          + name               = "participants_by_cpf_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)
            # (1 unchanged attribute hidden)

          + warm_throughput (known after apply)
        }
      + global_secondary_index {
          + hash_key           = "email"
          + name               = "participants_by_email_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)
            # (1 unchanged attribute hidden)

          + warm_throughput (known after apply)
        }

        # (4 unchanged blocks hidden)
    }

  # module.products_table.aws_dynamodb_table.products will be updated in-place
  ~ resource "aws_dynamodb_table" "products" {
        id                          = "tech-floripa-certificates-products-dev"
        name                        = "tech-floripa-certificates-products-dev"
        tags                        = {
            "CostCenter"  = "low-cost"
            "Entity"      = "Product"
            "Environment" = "dev"
            "Name"        = "tech-floripa-certificates-products-dev"
            "Project"     = "tech-floripa-certificates"
        }
        # (13 unchanged attributes hidden)

      + attribute {
          + name = "has_certificate_background_flag"
          + type = "N"
        }
      + attribute {
          + name = "has_certificate_logo_flag"
          + type = "N"
        }
      + attribute {
          + name = "product_name"
          + type = "S"
        }

      + global_secondary_index {
          + hash_key           = "has_certificate_background_flag"
          + name               = "products_by_has_background_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + range_key          = "product_name"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)

          + warm_throughput (known after apply)
        }
      + global_secondary_index {
          + hash_key           = "has_certificate_logo_flag"
          + name               = "products_by_has_logo_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + range_key          = "product_name"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)

          + warm_throughput (known after apply)
        }
      + global_secondary_index {
          + hash_key           = "product_name"
          + name               = "products_by_name_idx"
          + non_key_attributes = []
          + projection_type    = "ALL"
          + read_capacity      = (known after apply)
          + write_capacity     = (known after apply)
            # (1 unchanged attribute hidden)

          + warm_throughput (known after apply)
        }

        # (4 unchanged blocks hidden)
    }

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

Changes to Outputs:
  ~ certificates_table_arn                    = "arn:aws:dynamodb:us-east-1:334318883918:table/tech-floripa-certificates-certificates-dev" -> (known after apply)

@maxsonferovante
maxsonferovante merged commit 6604280 into main Jun 26, 2026
2 checks passed
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.

1 participant