Skip to content

Commit 9d6f6df

Browse files
authored
Merge pull request #2 from silinternational/validate-name
Release 0.1.2 -- add validation for name variable to avoid length errors
2 parents 9c5f14f + 8cbd499 commit 9d6f6df

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ resource "random_id" "name_suffix" {
88
}
99

1010
resource "aws_iam_role" "this" {
11-
name = "ecs_events-${local.unique_name}"
11+
name = "events-${local.unique_name}"
1212

1313
assume_role_policy = jsonencode({
1414
Version = "2012-10-17"

test/main.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
module "minimal" {
33
source = "../"
44

5-
ecs_cluster_arn = ""
6-
task_definition_arn = ""
7-
name = ""
5+
ecs_cluster_arn = "arn:aws:ecs:us-east-1:000000000000:cluster/test-cluster"
6+
task_definition_arn = "arn:aws:ecs:us-east-1:000000000000:task-definition/test-td:1"
7+
name = "test-name"
88
}
99

1010
module "full" {
1111
source = "../"
1212

13-
ecs_cluster_arn = "a"
14-
task_definition_arn = "b"
15-
name = "c"
16-
event_schedule = "d"
13+
ecs_cluster_arn = "arn:aws:ecs:us-east-1:000000000000:cluster/test-cluster"
14+
task_definition_arn = "arn:aws:ecs:us-east-1:000000000000:task-definition/test-td:1"
15+
name = "0123456789abcdef0123456789abcdef0123456789abcdef"
16+
event_schedule = "cron(0 0 1 1 ? 1)"
1717
enable = true
18-
event_rule_description = "e"
19-
event_target_input = "f"
20-
tags = { g : "h" }
18+
event_rule_description = "a description"
19+
event_target_input = jsonencode({ "containerOverrides" : [{ "name" : "container_name", "command" : ["true"] }] })
20+
tags = { tag_name : "tag_value" }
2121
}
2222

2323
output "an_output" {

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ variable "task_definition_arn" {
1111
variable "name" {
1212
description = "name of event assigned to "
1313
type = string
14+
15+
validation {
16+
condition = length(var.name) <= 48
17+
error_message = "The variable 'name' must be at most 48 characters to avoid exceeding the aws_iam_role name limit of 64 characters."
18+
}
1419
}
1520

1621
variable "event_schedule" {

0 commit comments

Comments
 (0)