Skip to content

Commit

Permalink
Update services lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie committed May 30, 2024
1 parent 9263a1b commit dd24116
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
terraform 1.5.6
ruby 3.2.2
ruby 3.3.1
golang 1.22.1
1 change: 0 additions & 1 deletion components/services/.tool-versions

This file was deleted.

8 changes: 5 additions & 3 deletions components/services/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG FUNCTION_DIR="/function"

FROM ruby:3.2-alpine as build-image
ARG RUBY_VERSION=3.3
FROM public.ecr.aws/docker/library/ruby:$RUBY_VERSION-alpine AS build-image

RUN apk update && \
apk upgrade && \
Expand Down Expand Up @@ -30,7 +30,7 @@ COPY lib/ ${FUNCTION_DIR}/lib/

#############################

FROM ruby:3.2-alpine
FROM public.ecr.aws/docker/library/ruby:$RUBY_VERSION-alpine

ARG FUNCTION_DIR
WORKDIR ${FUNCTION_DIR}
Expand All @@ -44,5 +44,7 @@ RUN apk update && \
gem install bundler && \
gem install aws_lambda_ric

ENV RUBY_YJIT_ENABLE=true

ENTRYPOINT [ "/usr/local/bundle/bin/aws_lambda_ric" ]
CMD [ "app.App::Handler.process" ]
26 changes: 14 additions & 12 deletions components/services/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,38 @@ GEM
remote: https://rubygems.org/
specs:
aws-eventstream (1.3.0)
aws-partitions (1.925.0)
aws-sdk-core (3.194.2)
aws-partitions (1.936.0)
aws-sdk-core (3.196.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-ec2 (1.456.0)
aws-sdk-ec2 (1.458.0)
aws-sdk-core (~> 3, >= 3.193.0)
aws-sigv4 (~> 1.1)
aws-sdk-ecs (1.146.0)
aws-sdk-ecs (1.147.0)
aws-sdk-core (~> 3, >= 3.193.0)
aws-sigv4 (~> 1.1)
aws-sdk-ssm (1.168.0)
aws-sdk-ssm (1.169.0)
aws-sdk-core (~> 3, >= 3.193.0)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.8.0)
aws-eventstream (~> 1, >= 1.0.2)
bigdecimal (3.1.7)
bigdecimal (3.1.8)
coderay (1.1.3)
concurrent-ruby (1.2.3)
concurrent-ruby (1.3.1)
diff-lcs (1.5.1)
docile (1.4.0)
jmespath (1.6.2)
method_source (1.0.0)
method_source (1.1.0)
ox (2.14.18)
pg (1.5.6)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
rake (13.2.1)
rexml (3.2.5)
rexml (3.2.8)
strscan (>= 3.0.9)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand All @@ -42,10 +43,10 @@ GEM
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.0)
rspec-support (3.13.1)
sentry-ruby (5.17.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
Expand All @@ -60,6 +61,7 @@ GEM
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
strscan (3.1.0)

PLATFORMS
ruby
Expand All @@ -79,4 +81,4 @@ DEPENDENCIES
simplecov-cobertura

BUNDLED WITH
2.4.12
2.5.11
41 changes: 0 additions & 41 deletions components/services/spec/support/aws.rb

This file was deleted.

54 changes: 27 additions & 27 deletions infrastructure/modules/somleng_switch/services.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ resource "docker_image" "services" {
}

resource "docker_registry_image" "services" {
name = docker_image.services.name
name = docker_image.services.name
keep_remotely = true
}

Expand All @@ -29,7 +29,7 @@ resource "aws_ssm_parameter" "services_application_master_key" {

# IAM
resource "aws_iam_role" "services" {
name = local.services_function_name
name = local.services_function_name
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
Expand Down Expand Up @@ -116,41 +116,41 @@ resource "aws_security_group_rule" "services_egress" {
protocol = "-1"
from_port = 0
security_group_id = aws_security_group.services.id
cidr_blocks = ["0.0.0.0/0"]
cidr_blocks = ["0.0.0.0/0"]
}

resource "aws_lambda_function" "services" {
function_name = local.services_function_name
role = aws_iam_role.services.arn
package_type = "Image"
role = aws_iam_role.services.arn
package_type = "Image"
architectures = ["arm64"]
image_uri = docker_registry_image.services.name
timeout = 300
memory_size = 512
image_uri = docker_registry_image.services.name
timeout = 300
memory_size = 512

vpc_config {
security_group_ids = [aws_security_group.services.id, var.db_security_group]
subnet_ids = var.vpc.private_subnets
subnet_ids = var.vpc.private_subnets
}

environment {
variables = {
SWITCH_GROUP = "service:${var.switch_identifier}"
MEDIA_PROXY_GROUP = "service:${aws_ecs_task_definition.media_proxy.family}"
CLIENT_GATEWAY_GROUP = "service:${aws_ecs_task_definition.client_gateway.family}"
SWITCH_GROUP = "service:${var.switch_identifier}"
MEDIA_PROXY_GROUP = "service:${aws_ecs_task_definition.media_proxy.family}"
CLIENT_GATEWAY_GROUP = "service:${aws_ecs_task_definition.client_gateway.family}"
FS_EVENT_SOCKET_PASSWORD_SSM_PARAMETER_NAME = aws_ssm_parameter.freeswitch_event_socket_password.name
FS_EVENT_SOCKET_PORT = var.freeswitch_event_socket_port
FS_SIP_PORT = var.sip_port
FS_SIP_ALTERNATIVE_PORT = var.sip_alternative_port
PUBLIC_GATEWAY_DB_NAME = var.public_gateway_db_name
CLIENT_GATEWAY_DB_NAME = var.client_gateway_db_name
MEDIA_PROXY_NG_PORT = var.media_proxy_ng_port
DB_PASSWORD_SSM_PARAMETER_NAME = data.aws_ssm_parameter.db_password.name
APP_MASTER_KEY_SSM_PARAMETER_NAME = aws_ssm_parameter.services_application_master_key.name
APP_ENV = var.app_environment
DB_HOST = var.db_host
DB_PORT = var.db_port
DB_USER = var.db_username
FS_EVENT_SOCKET_PORT = var.freeswitch_event_socket_port
FS_SIP_PORT = var.sip_port
FS_SIP_ALTERNATIVE_PORT = var.sip_alternative_port
PUBLIC_GATEWAY_DB_NAME = var.public_gateway_db_name
CLIENT_GATEWAY_DB_NAME = var.client_gateway_db_name
MEDIA_PROXY_NG_PORT = var.media_proxy_ng_port
DB_PASSWORD_SSM_PARAMETER_NAME = data.aws_ssm_parameter.db_password.name
APP_MASTER_KEY_SSM_PARAMETER_NAME = aws_ssm_parameter.services_application_master_key.name
APP_ENV = var.app_environment
DB_HOST = var.db_host
DB_PORT = var.db_port
DB_USER = var.db_username
}
}

Expand Down Expand Up @@ -178,7 +178,7 @@ resource "aws_lambda_permission" "services" {
}

resource "aws_cloudwatch_event_rule" "services" {
name = local.services_function_name
name = local.services_function_name

event_pattern = <<EOF
{
Expand Down Expand Up @@ -211,7 +211,7 @@ resource "aws_sqs_queue" "services" {
}

resource "aws_lambda_event_source_mapping" "services_sqs" {
event_source_arn = aws_sqs_queue.services.arn
function_name = aws_lambda_function.services.arn
event_source_arn = aws_sqs_queue.services.arn
function_name = aws_lambda_function.services.arn
maximum_batching_window_in_seconds = 0
}

0 comments on commit dd24116

Please sign in to comment.