Skip to content

Commit c496c91

Browse files
committed
Back to one resource provisioner
1 parent 2fece5a commit c496c91

File tree

14 files changed

+54
-103
lines changed

14 files changed

+54
-103
lines changed

hpc/main.tf

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ module "efs" {
9191
module "resource-provisioner" {
9292
source = "./resource-provisioner/"
9393

94-
suffix = "prod"
9594
hpc_resource_provisioner_role = module.security.resource_provisioner_iam_role_arn
9695
hpc_resource_provisioner_subnet_ids = [module.networking.lambda_subnet_id]
9796
hpc_resource_provisioner_sg_ids = [var.obp_vpc_default_sg_id, module.security.vpc_peering_security_group_id, module.security.resource_provisioner_security_group_id]
@@ -111,29 +110,6 @@ module "resource-provisioner" {
111110
pcluster_ami_id = var.pcluster_ami_id
112111
}
113112

114-
module "resource-provisioner-dev" {
115-
source = "./resource-provisioner/"
116-
117-
suffix = "dev"
118-
hpc_resource_provisioner_role = module.security.resource_provisioner_iam_role_arn
119-
hpc_resource_provisioner_subnet_ids = [module.networking.lambda_subnet_id]
120-
hpc_resource_provisioner_sg_ids = [var.obp_vpc_default_sg_id, module.security.vpc_peering_security_group_id, module.security.resource_provisioner_security_group_id]
121-
aws_region = var.aws_region
122-
account_id = var.account_id
123-
hpc_resource_provisioner_container_version = var.hpc_resource_provisioner_container_dev_version
124-
aws_security_group_efa_id = module.security.aws_security_group_efa_id
125-
126-
sbo_nexusdata_bucket = var.sbo_nexusdata_bucket
127-
containers_bucket = var.containers_bucket
128-
scratch_bucket = var.scratch_bucket
129-
scratch_bucket_arn = var.scratch_bucket_arn
130-
infra_assets_bucket = var.sboinfrastructureassets_bucket_name
131-
fsx_policy_arn = module.security.fsx_policy_arn
132-
fs_subnet_ids = module.networking.fs_subnet_ids
133-
fs_sg_id = module.security.compute_efs_sg_id
134-
pcluster_ami_id = var.pcluster_ami_id
135-
}
136-
137113
module "dynamodb" {
138114
source = "./dynamodb/"
139115
is_production = var.is_production

hpc/resource-provisioner/api_gateway.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_api_gateway_rest_api" "hpc_resource_provisioner_api" {
2-
name = "hpc_resource_provisioner-${var.suffix}"
2+
name = "hpc_resource_provisioner"
33
}
44

55
resource "aws_api_gateway_resource" "hpc_resource_provisioner_res_provisioner" {

hpc/resource-provisioner/dashboard.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
resource "aws_cloudwatch_dashboard" "resource_provisioner_dashboard" {
2-
count = var.suffix == "prod" ? 1 : 0
32
dashboard_name = "HPC-Resource-Provisioner"
43
dashboard_body = jsonencode({
54
"widgets" : [

hpc/resource-provisioner/eventbridge.tf

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# EventBridge, aka The Service Formerly Known As CloudWatch Events - hence the names of the resources
22

33
resource "aws_cloudwatch_event_rule" "dra_event" {
4-
count = var.suffix == "dev" ? 1 : 0
54
name = "dra-event"
65
description = "Whenever a DRA is ready, trigger resource provisioner"
76
event_pattern = jsonencode(
@@ -17,9 +16,8 @@ resource "aws_cloudwatch_event_rule" "dra_event" {
1716
}
1817

1918
resource "aws_cloudwatch_event_target" "resource_provisioner_dra" {
20-
count = var.suffix == "dev" ? 1 : 0
21-
arn = "${aws_api_gateway_stage.hpc_resource_provisioner_api_stage.execution_arn}/POST/hpc-provisioner/dra"
22-
rule = aws_cloudwatch_event_rule.dra_event[0].id
19+
arn = "${aws_api_gateway_stage.hpc_resource_provisioner_api_stage.execution_arn}/POST/hpc-provisioner/dra"
20+
rule = aws_cloudwatch_event_rule.dra_event.id
2321

2422
http_target {
2523
query_string_parameters = {

hpc/resource-provisioner/iam.tf

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
resource "aws_iam_role" "resource_provisioner_eventbridge" {
2-
count = var.suffix == "dev" ? 1 : 0
32
name = "hpc_resource_provisioner_eventbridge_role"
43
assume_role_policy = file("${path.module}/hpc_resource_provisioner_eventbridge_assume_role_policy.json")
54
}
65

76
resource "aws_iam_role_policy_attachment" "resource_provisioner_eventbridge" {
8-
count = var.suffix == "dev" ? 1 : 0
9-
role = aws_iam_role.resource_provisioner_eventbridge[0].name
10-
policy_arn = aws_iam_policy.resource_provisioner_eventbridge[0].arn
7+
role = aws_iam_role.resource_provisioner_eventbridge.name
8+
policy_arn = aws_iam_policy.resource_provisioner_eventbridge.arn
119
}
1210

1311
resource "aws_iam_policy" "resource_provisioner_eventbridge" {
14-
count = var.suffix == "dev" ? 1 : 0
1512
name = "eventbridge_fire_lambda_policy"
1613
policy = templatefile("${path.module}/hpc_resource_provisioner_eventbridge_policy.tftpl", { "account_id" = var.account_id, "aws_region" = var.aws_region, "api_deployment_id" = aws_api_gateway_deployment.hpc_resource_provisioner_api_deployment.id })
1714
}

hpc/resource-provisioner/lambda.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ resource "aws_lambda_permission" "hpc_resource_provisioner_permission_post" {
88

99
# tfsec:ignore:aws-lambda-enable-tracing
1010
resource "aws_lambda_function" "hpc_resource_provisioner_lambda" {
11-
function_name = "hpc-resource-provisioner-${var.suffix}"
11+
function_name = "hpc-resource-provisioner"
1212
role = var.hpc_resource_provisioner_role
1313
package_type = "Image"
1414
architectures = ["x86_64"]
@@ -30,10 +30,9 @@ resource "aws_lambda_function" "hpc_resource_provisioner_lambda" {
3030
FSX_POLICY_ARN = var.fsx_policy_arn
3131
FS_SUBNET_IDS = jsonencode(var.fs_subnet_ids)
3232
FS_SG_ID = var.fs_sg_id
33-
SUFFIX = var.suffix
3433
# API_GW_STAGE_ARN = aws_api_gateway_stage.hpc_resource_provisioner_api_stage.arn
3534
API_GW_STAGE_ARN = "arn:aws:execute-api:${var.aws_region}:${var.account_id}:kmlnf84csk/" # TODO: don't hardcode, find a way to do this without a cycle
36-
EVENTBRIDGE_ROLE_ARN = var.suffix == "dev" ? aws_iam_role.resource_provisioner_eventbridge[0].arn : "NOT SET"
35+
EVENTBRIDGE_ROLE_ARN = aws_iam_role.resource_provisioner_eventbridge.arn
3736
}
3837
}
3938
}
@@ -45,7 +44,7 @@ data "aws_ecr_image" "hpc_resource_provisioner_image" {
4544

4645
# tfsec:ignore:aws-lambda-enable-tracing
4746
resource "aws_lambda_function" "hpc_resource_provisioner_async_lambda" {
48-
function_name = "hpc-resource-provisioner-creator-${var.suffix}"
47+
function_name = "hpc-resource-provisioner-creator"
4948
role = var.hpc_resource_provisioner_role
5049
package_type = "Image"
5150
architectures = ["x86_64"]

hpc/resource-provisioner/variables.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ variable "fs_sg_id" {
5858
type = string
5959
}
6060

61-
variable "suffix" {
62-
type = string
63-
}
64-
6561
variable "pcluster_ami_id" {
6662
type = string
6763
}

hpc/variables.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ variable "hpc_resource_provisioner_container_version" {
9090
type = string
9191
}
9292

93-
variable "hpc_resource_provisioner_container_dev_version" {
94-
type = string
95-
}
96-
9793
variable "sbo_nexusdata_bucket" {
9894
type = string
9995
}

main.tf

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -324,36 +324,35 @@ module "github_notebook_service_ecs_redeploy_role" {
324324
module "hpc" {
325325
source = "./hpc"
326326

327-
aws_region = local.aws_region
328-
account_id = local.account_id
329-
obp_vpc_id = local.vpc_id
330-
obp_vpc_default_sg_id = local.vpc_default_sg_id
331-
sbo_billing = "hpc"
332-
slurm_mysql_admin_username = "slurm_admin"
333-
create_compute_instances = false
334-
num_compute_instances = 0
335-
create_slurmdb = false # TODO-SLURMDB: re-enable when redeploying the cluster
336-
compute_instance_type = "m7g.medium"
337-
create_jumphost = false
338-
compute_nat_access = false
339-
compute_subnet_count = 16
340-
av_zone_suffixes = ["a"]
341-
peering_route_tables = [local.route_table_private_subnets_id, local.route_table_public_id]
342-
lambda_subnet_cidr = "10.0.16.0/24"
343-
is_production = var.is_production
344-
aws_endpoints_subnet_cidr = module.networking.endpoints_subnet_cidr
345-
endpoints_route_table_id = local.route_table_private_subnets_id
346-
hpc_slurm_secrets_arn = local.hpc_slurm_secrets_arn
347-
hpc_resource_provisioner_container_version = var.hpc_resource_provisioner_container_version
348-
hpc_resource_provisioner_container_dev_version = var.hpc_resource_provisioner_container_dev_version
349-
sbo_nexusdata_bucket = var.hpc_resource_provisioner_sbo_nexusdata_bucket
350-
containers_bucket = var.hpc_resource_provisioner_containers_bucket
351-
scratch_bucket = var.hpc_resource_provisioner_scratch_bucket
352-
scratch_bucket_arn = var.hpc_resource_provisioner_scratch_bucket_arn
353-
private_alb_https_listener_arn = local.private_alb_https_listener_arn
354-
is_hpc_dev = true
355-
sboinfrastructureassets_bucket_name = var.sbo_infrastructureassets_bucket
356-
pcluster_ami_id = var.pcluster_ami_id
327+
aws_region = local.aws_region
328+
account_id = local.account_id
329+
obp_vpc_id = local.vpc_id
330+
obp_vpc_default_sg_id = local.vpc_default_sg_id
331+
sbo_billing = "hpc"
332+
slurm_mysql_admin_username = "slurm_admin"
333+
create_compute_instances = false
334+
num_compute_instances = 0
335+
create_slurmdb = false # TODO-SLURMDB: re-enable when redeploying the cluster
336+
compute_instance_type = "m7g.medium"
337+
create_jumphost = false
338+
compute_nat_access = false
339+
compute_subnet_count = 16
340+
av_zone_suffixes = ["a"]
341+
peering_route_tables = [local.route_table_private_subnets_id, local.route_table_public_id]
342+
lambda_subnet_cidr = "10.0.16.0/24"
343+
is_production = var.is_production
344+
aws_endpoints_subnet_cidr = module.networking.endpoints_subnet_cidr
345+
endpoints_route_table_id = local.route_table_private_subnets_id
346+
hpc_slurm_secrets_arn = local.hpc_slurm_secrets_arn
347+
hpc_resource_provisioner_container_version = var.hpc_resource_provisioner_container_version
348+
sbo_nexusdata_bucket = var.hpc_resource_provisioner_sbo_nexusdata_bucket
349+
containers_bucket = var.hpc_resource_provisioner_containers_bucket
350+
scratch_bucket = var.hpc_resource_provisioner_scratch_bucket
351+
scratch_bucket_arn = var.hpc_resource_provisioner_scratch_bucket_arn
352+
private_alb_https_listener_arn = local.private_alb_https_listener_arn
353+
is_hpc_dev = true
354+
sboinfrastructureassets_bucket_name = var.sbo_infrastructureassets_bucket
355+
pcluster_ami_id = var.pcluster_ami_id
357356
}
358357

359358
module "static-server" {

production.tfvars

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ keycloak_task_size = {
3636
cpu = 2048
3737
memory = 4096
3838
}
39-
coreservices_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDO8QAh2WZ/WcZnNeojPNhadeodMO2l3PssaUFJWfvEFNzkuo5ci7nxb39M2FH6RyFAfqykV/v89KfDIg9K2ebJQZS+x6Enrqm7+ROmZjCdpYkFm7l2NCoKLus92DaPX6k1Tv5hcI76BqWN4nOKQxzb7ziJxFl5wzLgTwnXZvY33dA3Pu6aimksv071KnQ3hJKk6Omx/l7Hv/D7c0tU8vRCUefzHT3TkRpRgTTq+Wd8S0pGSmMB4drk5PiUzEVczxuIfmYGCWV2va6aT34yuMOw/6y2Cr9guCkyR2FkFm7q0MPw0aKGFBwTT05eiEWBWKQQbqi1qMtSwd6tp4qv6crN SSH key for AWS SBO POC"
40-
hpc_resource_provisioner_container_version = "latest"
41-
hpc_resource_provisioner_container_dev_version = "latest-dev"
42-
core_web_app_deployment_env = "production"
43-
core_web_app_next_public_matomo_site_id = "1"
39+
coreservices_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDO8QAh2WZ/WcZnNeojPNhadeodMO2l3PssaUFJWfvEFNzkuo5ci7nxb39M2FH6RyFAfqykV/v89KfDIg9K2ebJQZS+x6Enrqm7+ROmZjCdpYkFm7l2NCoKLus92DaPX6k1Tv5hcI76BqWN4nOKQxzb7ziJxFl5wzLgTwnXZvY33dA3Pu6aimksv071KnQ3hJKk6Omx/l7Hv/D7c0tU8vRCUefzHT3TkRpRgTTq+Wd8S0pGSmMB4drk5PiUzEVczxuIfmYGCWV2va6aT34yuMOw/6y2Cr9guCkyR2FkFm7q0MPw0aKGFBwTT05eiEWBWKQQbqi1qMtSwd6tp4qv6crN SSH key for AWS SBO POC"
40+
hpc_resource_provisioner_container_version = "latest"
41+
core_web_app_deployment_env = "production"
42+
core_web_app_next_public_matomo_site_id = "1"
4443

4544
hpc_resource_provisioner_sbo_nexusdata_bucket = ""
4645
sbo_infrastructureassets_bucket = "s3://sboinfrastructureassets"

0 commit comments

Comments
 (0)