Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Commit

Permalink
Increase Lambda Function Timeout to 10 seconds for first time starts (#…
Browse files Browse the repository at this point in the history
…625)

* Increase Lambda Function Timeout to 10 seconds for first time starts

* Bump Ruby Version to 3.3

* Update Hashicorp version to allow upgrade to ruby3.3

* Don't bundle money-rails (which installs like half of rails)
  • Loading branch information
FinnIckler authored Jul 17, 2024
1 parent 0f5cbee commit fea979c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
4 changes: 1 addition & 3 deletions app/models/registration.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'time'
require 'money-rails'

class Registration
include Dynamoid::Document
Expand Down Expand Up @@ -105,8 +104,7 @@ def payment_amount
def payment_amount_human_readable
payment_details = payment_lane&.lane_details
unless payment_details.nil?
money = Money.from_cents(payment_details['amount_lowest_denominator'], payment_details['currency_code'])
"#{money.format} (#{money.currency.name})"
MoneyFormat.format_human_readable(payment_details['amount_lowest_denominator'], payment_details['currency_code'])
end
end

Expand Down
3 changes: 1 addition & 2 deletions infra/lambda/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

source 'https://rubygems.org'

ruby '3.2.2'
ruby '3.3.0'

gem 'dynamoid', '3.8.0'
gem 'aws-sdk-dynamodb'
gem 'aws-sdk-sqs'
gem 'money-rails'
gem 'superconfig'
gem 'zeitwerk'
2 changes: 1 addition & 1 deletion infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.11"
version = "~> 5.58"
}
}

Expand Down
3 changes: 2 additions & 1 deletion infra/staging/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ resource "aws_lambda_function" "registration_status_lambda" {
function_name = "${var.name_prefix}-poller-lambda-staging"
role = aws_iam_role.lambda_role.arn
handler = "registration_status.lambda_handler"
runtime = "ruby3.2"
runtime = "ruby3.3"
source_code_hash = filebase64sha256("./lambda/registration_status.zip")
timeout = 10
environment {
variables = {
QUEUE_URL = aws_sqs_queue.this.url
Expand Down
3 changes: 2 additions & 1 deletion infra/worker/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ resource "aws_lambda_function" "registration_status_lambda" {
function_name = "${var.name_prefix}-poller-lambda-prod"
role = aws_iam_role.lambda_role.arn
handler = "registration_status.lambda_handler"
runtime = "ruby3.2"
runtime = "ruby3.3"
source_code_hash = filebase64sha256("./lambda/registration_status.zip")
timeout = 10
environment {
variables = {
QUEUE_URL = var.shared_resources.queue.url
Expand Down
10 changes: 10 additions & 0 deletions lib/money_format.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

require 'money-rails'

module MoneyFormat
def self.format_human_readable(amount_lowest_denominator, currency_code)
money = Money.from_cents(amount_lowest_denominator, currency_code)
"#{money.format} (#{money.currency.name})"
end
end

0 comments on commit fea979c

Please sign in to comment.