Skip to content

Commit aa1e92f

Browse files
authored
feat: concat the global_parameter_path_prefix infront of all secret env vars (#5)
* feat: concat the global_parameter_path_prefix infront of all secret env vars * feat: code refactorization
1 parent 253b5bc commit aa1e92f

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

EXAMPLE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ module "ecs_task_definition" {
2727
TEST = "1"
2828
FOO = "BAR"
2929
}
30+
parameter_path_prefix = "/project/env"
3031
secret_environment_variables = {
31-
SECRET = "path/to/ssm/variable"
32+
SECRET = "remaining_path/to/ssm/variable"
3233
}
3334
cloudwatch_log_retention_in_days = 30
3435
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ No modules.
4141
| <a name="input_image"></a> [image](#input\_image) | ECR image | `string` | n/a | yes |
4242
| <a name="input_name"></a> [name](#input\_name) | ECS task definition name | `string` | n/a | yes |
4343
| <a name="input_network_mode"></a> [network\_mode](#input\_network\_mode) | Docker networking mode to use for the containers in the task. The valid values are none, bridge, awsvpc, and host. | `string` | `"awsvpc"` | no |
44+
| <a name="input_parameter_path_prefix"></a> [parameter\_path\_prefix](#input\_parameter\_path\_prefix) | Path prefix for SSM parameter | `string` | `""` | no |
4445
| <a name="input_port"></a> [port](#input\_port) | ECS container port | `number` | `0` | no |
4546
| <a name="input_requires_compatibilities"></a> [requires\_compatibilities](#input\_requires\_compatibilities) | A set of launch types required by the task. The valid values are EC2 and FARGATE. | `list(string)` | <pre>[<br> "FARGATE"<br>]</pre> | no |
4647
| <a name="input_secret_environment_variables"></a> [secret\_environment\_variables](#input\_secret\_environment\_variables) | ECS secrets environment variables | `map(string)` | `{}` | no |

data.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ locals {
2424
secret_environment_variables = flatten([
2525
for name, valueFrom in var.secret_environment_variables : {
2626
name = name
27-
valueFrom = valueFrom
27+
valueFrom = "${var.parameter_path_prefix}/${valueFrom}"
2828
}
2929
])
30-
}
30+
}

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ variable "command" {
1313
default = ""
1414
}
1515

16+
variable "parameter_path_prefix" {
17+
description = "Path prefix for SSM parameter"
18+
type = string
19+
default = ""
20+
}
21+
1622
variable "image" {
1723
description = "ECR image"
1824
type = string
@@ -73,4 +79,4 @@ variable "health_check" {
7379
description = "task definition health check"
7480
type = any
7581
default = null
76-
}
82+
}

0 commit comments

Comments
 (0)