Skip to content

Commit 815d103

Browse files
committed
feat: Add FIS param and remove inference accelerator from service module
1 parent eca0887 commit 815d103

File tree

5 files changed

+58
-61
lines changed

5 files changed

+58
-61
lines changed

main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ module "service" {
118118
cpu = try(each.value.cpu, 1024)
119119
ephemeral_storage = try(each.value.ephemeral_storage, {})
120120
family = try(each.value.family, null)
121-
inference_accelerator = try(each.value.inference_accelerator, {})
122121
ipc_mode = try(each.value.ipc_mode, null)
123122
memory = try(each.value.memory, 2048)
124123
network_mode = try(each.value.network_mode, "awsvpc")

modules/service/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ module "ecs_service" {
261261
| <a name="input_enable_autoscaling"></a> [enable\_autoscaling](#input\_enable\_autoscaling) | Determines whether to enable autoscaling for the service | `bool` | `true` | no |
262262
| <a name="input_enable_ecs_managed_tags"></a> [enable\_ecs\_managed\_tags](#input\_enable\_ecs\_managed\_tags) | Specifies whether to enable Amazon ECS managed tags for the tasks within the service | `bool` | `true` | no |
263263
| <a name="input_enable_execute_command"></a> [enable\_execute\_command](#input\_enable\_execute\_command) | Specifies whether to enable Amazon ECS Exec for the tasks within the service | `bool` | `false` | no |
264+
| <a name="input_enable_fault_injection"></a> [enable\_fault\_injection](#input\_enable\_fault\_injection) | Enables fault injection and allows for fault injection requests to be accepted from the task's containers. Default is `false` | `bool` | `null` | no |
264265
| <a name="input_ephemeral_storage"></a> [ephemeral\_storage](#input\_ephemeral\_storage) | The amount of ephemeral storage to allocate for the task. This parameter is used to expand the total amount of ephemeral storage available, beyond the default amount, for tasks hosted on AWS Fargate | <pre>object({<br/> size_in_gib = number<br/> })</pre> | `null` | no |
265266
| <a name="input_external_id"></a> [external\_id](#input\_external\_id) | The external ID associated with the task set | `string` | `null` | no |
266267
| <a name="input_family"></a> [family](#input\_family) | A unique name for your task definition | `string` | `null` | no |
@@ -276,7 +277,6 @@ module "ecs_service" {
276277
| <a name="input_iam_role_tags"></a> [iam\_role\_tags](#input\_iam\_role\_tags) | A map of additional tags to add to the IAM role created | `map(string)` | `{}` | no |
277278
| <a name="input_iam_role_use_name_prefix"></a> [iam\_role\_use\_name\_prefix](#input\_iam\_role\_use\_name\_prefix) | Determines whether the IAM role name (`iam_role_name`) is used as a prefix | `bool` | `true` | no |
278279
| <a name="input_ignore_task_definition_changes"></a> [ignore\_task\_definition\_changes](#input\_ignore\_task\_definition\_changes) | Whether changes to service `task_definition` changes should be ignored | `bool` | `false` | no |
279-
| <a name="input_inference_accelerator"></a> [inference\_accelerator](#input\_inference\_accelerator) | Configuration block(s) with Inference Accelerators settings | <pre>object({<br/> device_name = string<br/> device_type = string<br/> })</pre> | `null` | no |
280280
| <a name="input_infrastructure_iam_role_arn"></a> [infrastructure\_iam\_role\_arn](#input\_infrastructure\_iam\_role\_arn) | Existing IAM role ARN | `string` | `null` | no |
281281
| <a name="input_infrastructure_iam_role_description"></a> [infrastructure\_iam\_role\_description](#input\_infrastructure\_iam\_role\_description) | Description of the role | `string` | `null` | no |
282282
| <a name="input_infrastructure_iam_role_name"></a> [infrastructure\_iam\_role\_name](#input\_infrastructure\_iam\_role\_name) | Name to use on IAM role created | `string` | `null` | no |
@@ -307,7 +307,7 @@ module "ecs_service" {
307307
| <a name="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name) | Name to use on security group created | `string` | `null` | no |
308308
| <a name="input_security_group_tags"></a> [security\_group\_tags](#input\_security\_group\_tags) | A map of additional tags to add to the security group created | `map(string)` | `{}` | no |
309309
| <a name="input_security_group_use_name_prefix"></a> [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Determines whether the security group name (`security_group_name`) is used as a prefix | `bool` | `true` | no |
310-
| <a name="input_service_connect_configuration"></a> [service\_connect\_configuration](#input\_service\_connect\_configuration) | The ECS Service Connect configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace | <pre>object({<br/> enabled = optional(bool, true)<br/> log_configuration = optional(object({<br/> log_driver = string<br/> options = optional(map(string))<br/> secret_option = optional(object({<br/> name = string<br/> value_from = string<br/> }))<br/> }))<br/> namespace = optional(string)<br/> service = optional(list(object({<br/> client_alias = optional(object({<br/> dns_name = optional(string)<br/> port = number<br/> }))<br/> discovery_name = optional(string)<br/> ingress_port_override = optional(number)<br/> port_name = string<br/> timeout = optional(object({<br/> idle_timeout_seconds = optional(number)<br/> per_request_timeout_seconds = optional(number)<br/> }))<br/> tls = optional(object({<br/> issuer_cert_authority = optional(object({<br/> aws_pca_authority_arn = string<br/> }))<br/> kms_key = optional(string)<br/> role_arn = optional(string)<br/> }))<br/> })))<br/> })</pre> | `null` | no |
310+
| <a name="input_service_connect_configuration"></a> [service\_connect\_configuration](#input\_service\_connect\_configuration) | The ECS Service Connect configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace | <pre>object({<br/> enabled = optional(bool, true)<br/> log_configuration = optional(object({<br/> log_driver = string<br/> options = optional(map(string))<br/> secret_option = optional(list(object({<br/> name = string<br/> value_from = string<br/> })))<br/> }))<br/> namespace = optional(string)<br/> service = optional(list(object({<br/> client_alias = optional(object({<br/> dns_name = optional(string)<br/> port = number<br/> }))<br/> discovery_name = optional(string)<br/> ingress_port_override = optional(number)<br/> port_name = string<br/> timeout = optional(object({<br/> idle_timeout_seconds = optional(number)<br/> per_request_timeout_seconds = optional(number)<br/> }))<br/> tls = optional(object({<br/> issuer_cert_authority = object({<br/> aws_pca_authority_arn = string<br/> })<br/> kms_key = optional(string)<br/> role_arn = optional(string)<br/> }))<br/> })))<br/> })</pre> | `null` | no |
311311
| <a name="input_service_registries"></a> [service\_registries](#input\_service\_registries) | Service discovery registries for the service | <pre>object({<br/> container_name = optional(string)<br/> container_port = optional(number)<br/> port = optional(number)<br/> registry_arn = string<br/> })</pre> | `null` | no |
312312
| <a name="input_service_tags"></a> [service\_tags](#input\_service\_tags) | A map of additional tags to add to the service | `map(string)` | `{}` | no |
313313
| <a name="input_skip_destroy"></a> [skip\_destroy](#input\_skip\_destroy) | If true, the task is not deleted when the service is deleted | `bool` | `null` | no |
@@ -342,7 +342,7 @@ module "ecs_service" {
342342
| <a name="input_track_latest"></a> [track\_latest](#input\_track\_latest) | Whether should track latest `ACTIVE` task definition on AWS or the one created with the resource stored in state. Default is `false`. Useful in the event the task definition is modified outside of this resource | `bool` | `true` | no |
343343
| <a name="input_triggers"></a> [triggers](#input\_triggers) | Map of arbitrary keys and values that, when changed, will trigger an in-place update (redeployment). Useful with `timestamp()` | `map(string)` | `null` | no |
344344
| <a name="input_volume"></a> [volume](#input\_volume) | Configuration block for volumes that containers in your task may use | <pre>map(object({<br/> configure_at_launch = optional(bool)<br/> docker_volume_configuration = optional(object({<br/> autoprovision = optional(bool)<br/> driver = optional(string)<br/> driver_opts = optional(map(string))<br/> labels = optional(map(string))<br/> scope = optional(string)<br/> }))<br/> efs_volume_configuration = optional(object({<br/> authorization_config = optional(object({<br/> access_point_id = optional(string)<br/> iam = optional(string)<br/> }))<br/> file_system_id = string<br/> root_directory = optional(string)<br/> transit_encryption = optional(string)<br/> transit_encryption_port = optional(number)<br/> }))<br/> fsx_windows_file_server_volume_configuration = optional(object({<br/> authorization_config = optional(object({<br/> credentials_parameter = string<br/> domain = string<br/> }))<br/> file_system_id = string<br/> root_directory = string<br/> }))<br/> host_path = optional(string)<br/> name = optional(string)<br/> }))</pre> | `null` | no |
345-
| <a name="input_volume_configuration"></a> [volume\_configuration](#input\_volume\_configuration) | Configuration for a volume specified in the task definition as a volume that is configured at launch time | <pre>object({<br/> name = string<br/> managed_ebs_volume = list(object({<br/> encrypted = optional(bool)<br/> file_system_type = optional(string)<br/> iops = optional(number)<br/> kms_key_id = optional(string)<br/> size_in_gb = optional(number)<br/> snapshot_id = optional(string)<br/> throughput = optional(number)<br/> volume_type = optional(string)<br/> tag_specifications = optional(list(object({<br/> resource_type = string<br/> propagate_tags = optional(string, "TASK_DEFINITION")<br/> tags = optional(map(string))<br/> })))<br/> }))<br/> })</pre> | `null` | no |
345+
| <a name="input_volume_configuration"></a> [volume\_configuration](#input\_volume\_configuration) | Configuration for a volume specified in the task definition as a volume that is configured at launch time | <pre>object({<br/> name = string<br/> managed_ebs_volume = object({<br/> encrypted = optional(bool)<br/> file_system_type = optional(string)<br/> iops = optional(number)<br/> kms_key_id = optional(string)<br/> size_in_gb = optional(number)<br/> snapshot_id = optional(string)<br/> tag_specifications = optional(list(object({<br/> propagate_tags = optional(string, "TASK_DEFINITION")<br/> resource_type = string<br/> tags = optional(map(string))<br/> })))<br/> throughput = optional(number)<br/> volume_type = optional(string)<br/> })<br/> })</pre> | `null` | no |
346346
| <a name="input_vpc_lattice_configurations"></a> [vpc\_lattice\_configurations](#input\_vpc\_lattice\_configurations) | The VPC Lattice configuration for your service that allows Lattice to connect, secure, and monitor your service across multiple accounts and VPCs | <pre>object({<br/> role_arn = string<br/> target_group_arn = string<br/> port_name = string<br/> })</pre> | `null` | no |
347347
| <a name="input_wait_for_steady_state"></a> [wait\_for\_steady\_state](#input\_wait\_for\_steady\_state) | If true, Terraform will wait for the service to reach a steady state before continuing. Default is `false` | `bool` | `null` | no |
348348
| <a name="input_wait_until_stable"></a> [wait\_until\_stable](#input\_wait\_until\_stable) | Whether terraform should wait until the task set has reached `STEADY_STATE` | `bool` | `null` | no |

modules/service/main.tf

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
data "aws_region" "current" {}
2-
data "aws_partition" "current" {}
3-
data "aws_caller_identity" "current" {}
1+
data "aws_region" "current" {
2+
count = var.create ? 1 : 0
3+
}
4+
data "aws_partition" "current" {
5+
count = var.create ? 1 : 0
6+
}
7+
data "aws_caller_identity" "current" {
8+
count = var.create ? 1 : 0
9+
}
410

511
locals {
6-
account_id = data.aws_caller_identity.current.account_id
7-
partition = data.aws_partition.current.partition
8-
region = data.aws_region.current.name
12+
account_id = try(data.aws_caller_identity.current[0].account_id, "")
13+
partition = try(data.aws_partition.current[0].partition, "")
14+
region = try(data.aws_region.current[0].name, "")
915
}
1016

1117
################################################################################
@@ -146,7 +152,7 @@ resource "aws_ecs_service" "this" {
146152
options = log_configuration.value.options
147153

148154
dynamic "secret_option" {
149-
for_each = log_configuration.value.secret_option != null ? [log_configuration.value.secret_option] : []
155+
for_each = log_configuration.value.secret_option != null ? log_configuration.value.secret_option : []
150156

151157
content {
152158
name = secret_option.value.name
@@ -228,7 +234,7 @@ resource "aws_ecs_service" "this" {
228234
name = volume_configuration.value.name
229235

230236
dynamic "managed_ebs_volume" {
231-
for_each = volume_configuration.value.managed_ebs_volume
237+
for_each = [volume_configuration.value.managed_ebs_volume]
232238

233239
content {
234240
encrypted = managed_ebs_volume.value.encrypted
@@ -238,8 +244,6 @@ resource "aws_ecs_service" "this" {
238244
role_arn = local.infrastructure_iam_role_arn
239245
size_in_gb = managed_ebs_volume.value.size_in_gb
240246
snapshot_id = managed_ebs_volume.value.snapshot_id
241-
throughput = managed_ebs_volume.value.throughput
242-
volume_type = managed_ebs_volume.value.volume_type
243247

244248
dynamic "tag_specifications" {
245249
for_each = managed_ebs_volume.value.tag_specifications != null ? managed_ebs_volume.value.tag_specifications : []
@@ -250,6 +254,9 @@ resource "aws_ecs_service" "this" {
250254
tags = tag_specifications.value.tags
251255
}
252256
}
257+
258+
throughput = managed_ebs_volume.value.throughput
259+
volume_type = managed_ebs_volume.value.volume_type
253260
}
254261
}
255262
}
@@ -411,7 +418,7 @@ resource "aws_ecs_service" "ignore_task_definition" {
411418
options = log_configuration.value.options
412419

413420
dynamic "secret_option" {
414-
for_each = log_configuration.value.secret_option != null ? [log_configuration.value.secret_option] : []
421+
for_each = log_configuration.value.secret_option != null ? log_configuration.value.secret_option : []
415422

416423
content {
417424
name = secret_option.value.name
@@ -493,7 +500,7 @@ resource "aws_ecs_service" "ignore_task_definition" {
493500
name = volume_configuration.value.name
494501

495502
dynamic "managed_ebs_volume" {
496-
for_each = volume_configuration.value.managed_ebs_volume
503+
for_each = [volume_configuration.value.managed_ebs_volume]
497504

498505
content {
499506
encrypted = managed_ebs_volume.value.encrypted
@@ -503,8 +510,6 @@ resource "aws_ecs_service" "ignore_task_definition" {
503510
role_arn = local.infrastructure_iam_role_arn
504511
size_in_gb = managed_ebs_volume.value.size_in_gb
505512
snapshot_id = managed_ebs_volume.value.snapshot_id
506-
throughput = managed_ebs_volume.value.throughput
507-
volume_type = managed_ebs_volume.value.volume_type
508513

509514
dynamic "tag_specifications" {
510515
for_each = managed_ebs_volume.value.tag_specifications != null ? managed_ebs_volume.value.tag_specifications : []
@@ -515,6 +520,9 @@ resource "aws_ecs_service" "ignore_task_definition" {
515520
tags = tag_specifications.value.tags
516521
}
517522
}
523+
524+
throughput = managed_ebs_volume.value.throughput
525+
volume_type = managed_ebs_volume.value.volume_type
518526
}
519527
}
520528
}
@@ -755,8 +763,9 @@ resource "aws_ecs_task_definition" "this" {
755763
count = local.create_task_definition ? 1 : 0
756764

757765
# Convert map of maps to array of maps before JSON encoding
758-
container_definitions = jsonencode([for k, v in module.container_definition : v.container_definition])
759-
cpu = var.cpu
766+
container_definitions = jsonencode([for k, v in module.container_definition : v.container_definition])
767+
cpu = var.cpu
768+
enable_fault_injection = var.enable_fault_injection
760769

761770
dynamic "ephemeral_storage" {
762771
for_each = var.ephemeral_storage != null ? [var.ephemeral_storage] : []
@@ -769,15 +778,6 @@ resource "aws_ecs_task_definition" "this" {
769778
execution_role_arn = try(aws_iam_role.task_exec[0].arn, var.task_exec_iam_role_arn)
770779
family = coalesce(var.family, var.name)
771780

772-
dynamic "inference_accelerator" {
773-
for_each = var.inference_accelerator != null ? [var.inference_accelerator] : []
774-
775-
content {
776-
device_name = inference_accelerator.value.device_name
777-
device_type = inference_accelerator.value.device_type
778-
}
779-
}
780-
781781
ipc_mode = var.ipc_mode
782782
memory = var.memory
783783
network_mode = var.network_mode
@@ -821,6 +821,8 @@ resource "aws_ecs_task_definition" "this" {
821821
for_each = var.volume != null ? var.volume : {}
822822

823823
content {
824+
configure_at_launch = volume.value.configure_at_launch
825+
824826
dynamic "docker_volume_configuration" {
825827
for_each = volume.value.docker_volume_configuration != null ? [volume.value.docker_volume_configuration] : []
826828

@@ -871,9 +873,8 @@ resource "aws_ecs_task_definition" "this" {
871873
}
872874
}
873875

874-
host_path = volume.value.host_path
875-
configure_at_launch = volume.value.configure_at_launch
876-
name = coalesce(volume.value.name, volume.key)
876+
host_path = volume.value.host_path
877+
name = coalesce(volume.value.name, volume.key)
877878
}
878879
}
879880

@@ -1524,7 +1525,7 @@ resource "aws_security_group" "this" {
15241525
}
15251526

15261527
resource "aws_vpc_security_group_ingress_rule" "this" {
1527-
for_each = var.security_group_ingress_rules != null && local.create_security_group ? var.security_group_ingress_rules : {}
1528+
for_each = { for k, v in var.security_group_ingress_rules : k => v if var.security_group_ingress_rules != null && local.create_security_group }
15281529

15291530
cidr_ipv4 = each.value.cidr_ipv4
15301531
cidr_ipv6 = each.value.cidr_ipv6
@@ -1536,15 +1537,15 @@ resource "aws_vpc_security_group_ingress_rule" "this" {
15361537
security_group_id = aws_security_group.this[0].id
15371538
tags = merge(
15381539
var.tags,
1539-
{ "Name" = try(each.value.name, "${local.security_group_name}-${each.key}") },
15401540
var.security_group_tags,
1541+
{ "Name" = try(each.value.name, "${local.security_group_name}-${each.key}") },
15411542
each.value.tags
15421543
)
15431544
to_port = try(coalesce(each.value.to_port, each.value.from_port), null)
15441545
}
15451546

15461547
resource "aws_vpc_security_group_egress_rule" "this" {
1547-
for_each = var.security_group_egress_rules != null && local.create_security_group ? var.security_group_egress_rules : {}
1548+
for_each = { for k, v in var.security_group_egress_rules : k => v if var.security_group_egress_rules != null && local.create_security_group }
15481549

15491550
cidr_ipv4 = each.value.cidr_ipv4
15501551
cidr_ipv6 = each.value.cidr_ipv6
@@ -1556,8 +1557,8 @@ resource "aws_vpc_security_group_egress_rule" "this" {
15561557
security_group_id = aws_security_group.this[0].id
15571558
tags = merge(
15581559
var.tags,
1559-
{ "Name" = try(each.value.name, "${local.security_group_name}-${each.key}") },
15601560
var.security_group_tags,
1561+
{ "Name" = try(each.value.name, "${local.security_group_name}-${each.key}") },
15611562
each.value.tags
15621563
)
15631564
to_port = each.value.to_port

0 commit comments

Comments
 (0)