-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ci: lambda subscriber * ci: lambda subscriber * chore: bump chain abstraction * fix: update tf config for sequncer cname * fix: sequencer http queue config update * fix: add auto scaling to seq publisher * fix: typo and seq health port config change * ci: prover --------- Co-authored-by: Rahul Sethuram <rahul.eth@icloud.com> Co-authored-by: just-a-node <eye1717@gmail.com> Co-authored-by: preethamr <preethamr@users.noreply.github.com>
- Loading branch information
1 parent
d9d85fa
commit ccff694
Showing
5 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
data "aws_caller_identity" "current" {} | ||
data "aws_region" "current" {} | ||
|
||
locals { | ||
account_id = data.aws_caller_identity.current.account_id | ||
repository_url = "${local.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/${var.ecr_repository_name}" | ||
} | ||
|
||
resource "aws_iam_role" "lambda" { | ||
name = "${var.container_family}-${var.environment}-${var.stage}-lambda-mq-subscriber-role" | ||
|
||
assume_role_policy = jsonencode({ | ||
"Version" : "2012-10-17", | ||
"Statement" : [ | ||
{ | ||
"Action" : "sts:AssumeRole", | ||
"Principal" : { | ||
"Service" : "lambda.amazonaws.com" | ||
}, | ||
"Effect" : "Allow" | ||
} | ||
] | ||
}) | ||
|
||
inline_policy { | ||
name = "${var.container_family}-${var.environment}-${var.stage}-lambda-mq-subscriber-policies" | ||
policy = jsonencode({ | ||
"Version" : "2012-10-17", | ||
"Statement" : [ | ||
{ | ||
"Effect" : "Allow", | ||
"Action" : [ | ||
"mq:DescribeBroker", | ||
"secretsmanager:GetSecretValue", | ||
"ec2:CreateNetworkInterface", | ||
"ec2:DescribeNetworkInterfaces", | ||
"ec2:DescribeVpcs", | ||
"ec2:DeleteNetworkInterface", | ||
"ec2:DescribeSubnets", | ||
"ec2:DescribeSecurityGroups", | ||
"logs:CreateLogGroup", | ||
"logs:CreateLogStream", | ||
"logs:PutLogEvents" | ||
], | ||
"Resource" : ["*"] | ||
} | ||
] | ||
}) | ||
} | ||
} | ||
resource "aws_lambda_function" "executable" { | ||
function_name = "${var.container_family}-${var.environment}-${var.stage}-mq-subscriber" | ||
image_uri = "${local.repository_url}:${var.docker_image_tag}" | ||
package_type = "Image" | ||
role = aws_iam_role.lambda.arn | ||
architectures = ["x86_64"] | ||
timeout = var.timeout | ||
memory_size = var.memory_size | ||
environment { | ||
variables = merge(var.container_env_vars, { DD_SERVICE = var.container_family }) | ||
} | ||
} | ||
|
||
|
||
resource "aws_lambda_event_source_mapping" "prover_x" { | ||
batch_size = 10 | ||
event_source_arn = var.aws_mq_broker_arn | ||
enabled = true | ||
function_name = aws_lambda_function.executable.arn | ||
queues = ["proverX"] | ||
|
||
source_access_configuration { | ||
type = "BASIC_AUTH" | ||
uri = aws_secretsmanager_secret_version.rmq_uri.arn | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
resource "aws_secretsmanager_secret" "rmq_secret" { | ||
name = "rmq-pw-${var.environment}-${var.stage}" | ||
} | ||
|
||
resource "aws_secretsmanager_secret_version" "rmq_uri" { | ||
secret_id = aws_secretsmanager_secret.rmq_secret.id | ||
secret_string = jsonencode({ | ||
username = var.rmq_mgt_user | ||
password = var.rmq_mgt_password | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
|
||
variable "docker_image_tag" { | ||
description = "Docker image tag" | ||
type = string | ||
default = "latest" | ||
} | ||
variable "ecr_repository_name" { | ||
description = "ECR repository name" | ||
type = string | ||
} | ||
|
||
|
||
variable "container_family" { | ||
description = "Container family" | ||
type = string | ||
} | ||
|
||
variable "container_env_vars" { | ||
description = "env vars for running container" | ||
} | ||
|
||
variable "timeout" { | ||
description = "timeout for lambda" | ||
default = 500 | ||
} | ||
|
||
variable "memory_size" { | ||
description = "memory size for lambda" | ||
default = 10240 | ||
} | ||
|
||
|
||
variable "stage" { | ||
description = "stage of deployment" | ||
} | ||
|
||
variable "environment" {} | ||
|
||
variable "rmq_mgt_password" { | ||
type = string | ||
description = "RabbitMQ management password" | ||
} | ||
|
||
variable "rmq_mgt_user" { | ||
type = string | ||
default = "connext" | ||
description = "RabbitMQ management user" | ||
} | ||
|
||
variable "host_instance_type" { | ||
type = string | ||
description = "The broker's instance type. e.g. mq.t2.micro or mq.m4.large" | ||
default = "mq.m5.large" | ||
} | ||
|
||
variable "publicly_accessible" { | ||
type = bool | ||
description = "Whether to enable connections from applications outside of the VPC that hosts the broker's subnets" | ||
default = false | ||
} | ||
|
||
variable "vpc_id" { | ||
type = string | ||
description = "The ID of the VPC to create the broker in" | ||
} | ||
|
||
variable "zone_id" { | ||
description = "hosted zone id" | ||
} | ||
|
||
variable "base_domain" { | ||
description = "base domain of the application" | ||
default = "connext.ninja" | ||
} | ||
|
||
variable "subnet_ids" { | ||
type = list(string) | ||
description = "List of VPC subnet IDs" | ||
} | ||
|
||
variable "sg_id" { | ||
type = string | ||
description = "security group id of worker node sg" | ||
} | ||
|
||
variable "deployment_mode" { | ||
type = string | ||
description = "Deployment mode of cluster" | ||
default = "CLUSTER_MULTI_AZ" | ||
} | ||
|
||
variable "aws_mq_amqp_endpoint" { | ||
type = string | ||
description = "The AMQP endpoint of the broker" | ||
} | ||
|
||
variable "aws_mq_broker_arn" { | ||
type = string | ||
description = "The ARN of the broker" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters