Skip to content

Commit 7ad5510

Browse files
committed
feature/PI-407-immutable_backups Move shared api_worker module and account wide only modules
1 parent acfe685 commit 7ad5510

File tree

32 files changed

+111
-9
lines changed

32 files changed

+111
-9
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module "lambda_function" {
2+
source = "terraform-aws-modules/lambda/aws"
3+
version = "6.0.0"
4+
5+
function_name = var.lambda_name
6+
description = "${replace(var.name, "_", "-")} lambda function"
7+
handler = "api.${var.name}.index.handler"
8+
runtime = var.python_version
9+
timeout = 10
10+
memory_size = var.memory_size
11+
12+
timeouts = {
13+
create = "5m"
14+
update = "5m"
15+
delete = "5m"
16+
}
17+
18+
create_current_version_allowed_triggers = false
19+
allowed_triggers = var.allowed_triggers
20+
environment_variables = var.environment_variables
21+
22+
create_package = false
23+
local_existing_package = var.source_path
24+
25+
tags = {
26+
Name = replace(var.name, "_", "-")
27+
}
28+
29+
layers = var.layers
30+
31+
trusted_entities = var.trusted_entities
32+
attach_policy_json = var.attach_policy_json
33+
policy_json = var.policy_json
34+
35+
attach_policy_statements = var.attach_policy_statements
36+
policy_statements = var.policy_statements
37+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
output "lambda_arn" {
2+
value = module.lambda_function.lambda_function_arn
3+
}
4+
5+
output "lambda_role_arn" {
6+
value = module.lambda_function.lambda_role_arn
7+
}
8+
9+
output "lambda_role_name" {
10+
value = module.lambda_function.lambda_role_name
11+
}
12+
13+
output "metadata" {
14+
value = {
15+
lambda_invoke_arn = module.lambda_function.lambda_function_invoke_arn
16+
authoriser_iam_role = module.lambda_function.lambda_role_arn
17+
authoriser_name = var.lambda_name
18+
}
19+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
variable "name" {}
2+
3+
variable "python_version" {
4+
}
5+
6+
variable "lambda_name" {
7+
default = ""
8+
}
9+
10+
variable "layers" {
11+
type = list(string)
12+
}
13+
14+
variable "source_path" {}
15+
16+
variable "attach_policy_json" {
17+
default = false
18+
}
19+
20+
variable "policy_json" {
21+
default = ""
22+
}
23+
24+
variable "trusted_entities" {
25+
default = []
26+
}
27+
28+
variable "allowed_triggers" {
29+
default = {}
30+
}
31+
32+
variable "environment_variables" {
33+
default = {}
34+
}
35+
36+
variable "attach_policy_statements" {
37+
default = false
38+
}
39+
40+
variable "policy_statements" {
41+
default = {}
42+
}
43+
44+
variable "memory_size" {
45+
default = 128
46+
}

infrastructure/terraform/per_account/modules/api_worker/api_layer/layer.tf renamed to infrastructure/terraform/modules/api_worker/api_layer/layer.tf

File renamed without changes.

infrastructure/terraform/per_account/modules/api_worker/api_layer/outputs.tf renamed to infrastructure/terraform/modules/api_worker/api_layer/outputs.tf

File renamed without changes.

infrastructure/terraform/per_account/modules/api_worker/api_layer/vars.tf renamed to infrastructure/terraform/modules/api_worker/api_layer/vars.tf

File renamed without changes.

infrastructure/terraform/per_account/backups/aws-backups.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resource "aws_kms_key" "destination_backup_key" {
1616
}
1717

1818
module "destination" {
19-
source = "../../modules/aws-backup-destination"
19+
source = "../modules/aws-backup-destination"
2020

2121
source_account_name = "test" # please note that the assigned value would be the prefix in aws_backup_vault.vault.name - change to dev/prod
2222
account_id = var.assume_account

infrastructure/terraform/per_account/dev/aws-backups.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ resource "aws_kms_alias" "backup_notifications" {
109109
# Now we can deploy the source and destination modules, referencing the resources we've created above.
110110

111111
module "source" {
112-
source = "../../modules/aws-backup-source"
112+
source = "../modules/aws-backup-source"
113113

114114
backup_copy_vault_account_id = data.aws_secretsmanager_secret_version.destination_account_id.secret_string
115115
backup_copy_vault_arn = data.aws_secretsmanager_secret_version.destination_vault_arn.secret_string
@@ -144,7 +144,7 @@ module "source" {
144144

145145

146146
module "notify" {
147-
source = "../../modules/notify/"
147+
source = "../modules/notify/"
148148

149149
assume_account = var.assume_account
150150
project_name = local.project

infrastructure/terraform/per_account/dev/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ resource "aws_route53_zone" "dev-ns" {
9898

9999
module "layers" {
100100
for_each = toset(var.layers)
101-
source = "../modules/api_worker/api_layer"
101+
source = "../../modules/api_worker/api_layer"
102102
name = each.key
103103
python_version = var.python_version
104104
layer_name = "${local.project}--${replace(terraform.workspace, "_", "-")}--${replace(each.key, "_", "-")}"
@@ -107,7 +107,7 @@ module "layers" {
107107

108108
module "third_party_layers" {
109109
for_each = toset(var.third_party_layers)
110-
source = "../modules/api_worker/api_layer"
110+
source = "../../modules/api_worker/api_layer"
111111
name = each.key
112112
python_version = var.python_version
113113
layer_name = "${local.project}--${replace(terraform.workspace, "_", "-")}--${replace(each.key, "_", "-")}"

infrastructure/terraform/modules/aws-backup-destination/README.md renamed to infrastructure/terraform/per_account/modules/aws-backup-destination/README.md

File renamed without changes.

0 commit comments

Comments
 (0)