Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Crash when creating aws_ecs_service resource #34166

Closed
PeterBocan opened this issue Oct 30, 2023 · 4 comments · Fixed by #38883
Closed

[Bug]: Crash when creating aws_ecs_service resource #34166

PeterBocan opened this issue Oct 30, 2023 · 4 comments · Fixed by #38883
Assignees
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ecs Issues and PRs that pertain to the ecs service.
Milestone

Comments

@PeterBocan
Copy link

Terraform Core Version

1.5.0

AWS Provider Version

5.22.0

Affected Resource(s)

resource "aws_ecs_service" "services" {
    count = length(var.services)
    name = var.services[count.index].name
    cluster = var.cluster
    task_definition = var.services[count.index].task_definition

    dynamic "service_registries" {
        for_each = [ var.services[count.index].service_registry ]
      content {
        registry_arn = service_registries != null ? service_registries.value : null
      }
   }
 
    desired_count = var.services[count.index].desired_count
    launch_type = "FARGATE"
    platform_version = "LATEST"
    
    deployment_controller {
      type = var.deployment_controller
    }

    enable_execute_command = true
    network_configuration {
      subnets = var.vpc_subnets
      security_groups = var.vpc_security_groups
    }

    dynamic "load_balancer" {
      for_each =  var.services[count.index].loadbalancer != null ? [ var.services[count.index].loadbalancer ] : []
      content {
        target_group_arn = load_balancer.value.targetgroup_arn
        container_name = load_balancer.value.container_name
        container_port = load_balancer.value.container_port
      }
    }

    lifecycle {
      ignore_changes = [ desired_count ]
    }
    tags = var.tags
}

Expected Behavior

The resource should have not crashed the plugin.

Actual Behavior

The terraform apply crashes with the following output:

│ Error: Plugin did not respond
│
│   with module.services.aws_ecs_service.services[2],
│   on ../../modules/platform/services/main.tf line 10, in resource "aws_ecs_service" "services":
│   10: resource "aws_ecs_service" "services" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-aws_v5.22.0_x5 plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 346 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/ecs.resourceServiceCreate({0x10e2df6e0, 0x140022092f0}, 0x140079d8f00, {0x10e131a80?, 0x1400024e4b0?})
	github.com/hashicorp/terraform-provider-aws/internal/service/ecs/service.go:581 +0x1a5c
github.com/hashicorp/terraform-provider-aws/internal/provider.interceptedHandler[...].func1(0x0?, {0x10e131a80?, 0x1400024e4b0?})
	github.com/hashicorp/terraform-provider-aws/internal/provider/intercept.go:111 +0x28c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x10e2df6e0?, {0x10e2df6e0?, 0x14007a6c4e0?}, 0xd?, {0x10e131a80?, 0x1400024e4b0?})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:773 +0x64
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x1400123d340, {0x10e2df6e0, 0x14007a6c4e0}, 0x14007a70dd0, 0x140079d8d80, {0x10e131a80, 0x1400024e4b0})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:909 +0x8a0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x14001e4daa0, {0x10e2df6e0?, 0x14007a6c3c0?}, 0x14003080dc0)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:1060 +0xb78
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).ApplyResourceChange(0x10e2df638?, {0x10e2df6e0?, 0x14007a6c090?}, 0x14003080dc0)
	github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf5muxserver/mux_server_ApplyResourceChange.go:36 +0x188
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x14001738d20, {0x10e2df6e0?, 0x14001a91860?}, 0x14005572af0)
	github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/tf5server/server.go:859 +0x3bc
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x10deb78e0?, 0x14001738d20}, {0x10e2df6e0, 0x14001a91860}, 0x14005572a80, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x14000830780, {0x10e2ece40, 0x1400071c680}, 0x14007a56480, 0x14001a6d3b0, 0x1146efcb8, 0x0)
	google.golang.org/grpc@v1.58.2/server.go:1376 +0xbe0
google.golang.org/grpc.(*Server).handleStream(0x14000830780, {0x10e2ece40, 0x1400071c680}, 0x14007a56480, 0x0)
	google.golang.org/grpc@v1.58.2/server.go:1753 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
	google.golang.org/grpc@v1.58.2/server.go:998 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.58.2/server.go:996 +0x16c

Error: The terraform-provider-aws_v5.22.0_x5 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Relevant Error/Panic Output Snippet

│ Error: Plugin did not respond
│
│   with module.services.aws_ecs_service.services[2],
│   on ../../modules/platform/services/main.tf line 10, in resource "aws_ecs_service" "services":
│   10: resource "aws_ecs_service" "services" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-aws_v5.22.0_x5 plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 346 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/ecs.resourceServiceCreate({0x10e2df6e0, 0x140022092f0}, 0x140079d8f00, {0x10e131a80?, 0x1400024e4b0?})
	github.com/hashicorp/terraform-provider-aws/internal/service/ecs/service.go:581 +0x1a5c
github.com/hashicorp/terraform-provider-aws/internal/provider.interceptedHandler[...].func1(0x0?, {0x10e131a80?, 0x1400024e4b0?})
	github.com/hashicorp/terraform-provider-aws/internal/provider/intercept.go:111 +0x28c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x10e2df6e0?, {0x10e2df6e0?, 0x14007a6c4e0?}, 0xd?, {0x10e131a80?, 0x1400024e4b0?})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:773 +0x64
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x1400123d340, {0x10e2df6e0, 0x14007a6c4e0}, 0x14007a70dd0, 0x140079d8d80, {0x10e131a80, 0x1400024e4b0})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:909 +0x8a0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x14001e4daa0, {0x10e2df6e0?, 0x14007a6c3c0?}, 0x14003080dc0)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:1060 +0xb78
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).ApplyResourceChange(0x10e2df638?, {0x10e2df6e0?, 0x14007a6c090?}, 0x14003080dc0)
	github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf5muxserver/mux_server_ApplyResourceChange.go:36 +0x188
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x14001738d20, {0x10e2df6e0?, 0x14001a91860?}, 0x14005572af0)
	github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/tf5server/server.go:859 +0x3bc
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x10deb78e0?, 0x14001738d20}, {0x10e2df6e0, 0x14001a91860}, 0x14005572a80, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x14000830780, {0x10e2ece40, 0x1400071c680}, 0x14007a56480, 0x14001a6d3b0, 0x1146efcb8, 0x0)
	google.golang.org/grpc@v1.58.2/server.go:1376 +0xbe0
google.golang.org/grpc.(*Server).handleStream(0x14000830780, {0x10e2ece40, 0x1400071c680}, 0x14007a56480, 0x0)
	google.golang.org/grpc@v1.58.2/server.go:1753 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
	google.golang.org/grpc@v1.58.2/server.go:998 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.58.2/server.go:996 +0x16c

Error: The terraform-provider-aws_v5.22.0_x5 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Terraform Configuration Files

Here is the .terraform.locl.hcl

# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.

provider "registry.terraform.io/hashicorp/aws" {
  version     = "5.22.0"
  constraints = "~> 5.0"
  hashes = [
    "h1:XuU3tsGzElMt4Ti8SsM05pFllNMwSC4ScUxcfsOS140=",
    "zh:09b8475cd519c945423b1e1183b71a4209dd2927e0d289a88c5abeecb53c1753",
    "zh:2448e0c3ce9b991a5dd70f6a42d842366a6a2460cf63b31fb9bc5d2cc92ced19",
    "zh:3b9fc2bf6714a9a9ab25eae3e56cead3d3917bc1b6d8b9fb3111c4198a790c72",
    "zh:4fbd28ad5380529a36c54d7a96c9768df1288c625d28b8fa3a50d4fc2176ef0f",
    "zh:54d550f190702a7edc2d459952d025e259a8c0b0ff7df3f15bbcc148539214bf",
    "zh:638f406d084ac96f3a0b0a5ce8aa71a5a2a781a56ba96e3a235d3982b89eef0d",
    "zh:69d4c175b13b6916b5c9398172cc384e7af46cb737b45870ab9907f12e82a28a",
    "zh:81edec181a67255d25caf5e7ffe6d5e8f9373849b9e8f5e0705f277640abb18e",
    "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
    "zh:a66efb2b3cf7be8116728ae5782d7550f23f3719da2ed3c10228d29c44b7dc84",
    "zh:ae754478d0bfa42195d16cf46091fab7c1c075ebc965d919338e36aed45add78",
    "zh:e0603ad0061c43aa1cb52740b1e700b8afb55667d7ee01c1cc1ceb6f983d4c9d",
    "zh:e4cb701d0185884eed0492a66eff17251f5b4971d30e81acd5e0a55627059fc8",
    "zh:f7db2fcf69679925dde1ae326526242fd61ba1f83f614b1f6d9d68c925417e51",
    "zh:fef331b9b62bc26d900ae937cc662281ff30794edf48aebfe8997d0e16835f6d",
  ]
}

provider "registry.terraform.io/hashicorp/random" {
  version     = "3.5.1"
  constraints = ">= 3.1.0"
  hashes = [
    "h1:IL9mSatmwov+e0+++YX2V6uel+dV6bn+fC/cnGDK3Ck=",
    "zh:04e3fbd610cb52c1017d282531364b9c53ef72b6bc533acb2a90671957324a64",
    "zh:119197103301ebaf7efb91df8f0b6e0dd31e6ff943d231af35ee1831c599188d",
    "zh:4d2b219d09abf3b1bb4df93d399ed156cadd61f44ad3baf5cf2954df2fba0831",
    "zh:6130bdde527587bbe2dcaa7150363e96dbc5250ea20154176d82bc69df5d4ce3",
    "zh:6cc326cd4000f724d3086ee05587e7710f032f94fc9af35e96a386a1c6f2214f",
    "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
    "zh:b6d88e1d28cf2dfa24e9fdcc3efc77adcdc1c3c3b5c7ce503a423efbdd6de57b",
    "zh:ba74c592622ecbcef9dc2a4d81ed321c4e44cddf7da799faa324da9bf52a22b2",
    "zh:c7c5cde98fe4ef1143bd1b3ec5dc04baf0d4cc3ca2c5c7d40d17c0e9b2076865",
    "zh:dac4bad52c940cd0dfc27893507c1e92393846b024c5a9db159a93c534a3da03",
    "zh:de8febe2a2acd9ac454b844a4106ed295ae9520ef54dc8ed2faf29f12716b602",
    "zh:eab0d0495e7e711cca367f7d4df6e322e6c562fc52151ec931176115b83ed014",
  ]
}

Steps to Reproduce

  1. Create a module with the resource outlined above.
  2. Instantiate the module
module "services" {
  source = "../../modules/platform/services"

  cluster = module.ecs.cluster_id

  services = [ 
    {
    name = "..."
    task_definition = "..."
    service_registry = module.dns_registry.service_arns["..."]
    desired_count = 2
    },
    {
    name = "..."
    task_definition = "..."
    service_registry = module.dns_registry.service_arns["..."]
    desired_count = 2
    },
    {
    name = "..."
    task_definition = "..."
    service_registry = module.dns_registry.service_arns["..."]
    desired_count = 2
    },
    {
    name = "..."
    task_definition = "..."
    service_registry = module.dns_registry.service_arns["..."]
    desired_count = 2
    },
    {
    name = "..."
    task_definition = "..."
    service_registry = module.dns_registry.service_arns["..."]
    desired_count = 2
    },
    {
    name = "account-receivable"
    task_definition = "..."
    service_registry = "..."
    desired_count = 2
    },
    {
    name = "..."
    task_definition = "..."
    desired_count = 2
    loadbalancer = {
      targetgroup_arn = module.loadbalancer.api_alb_arn,
      container_name = "main"
      container_port = 8999
    }
    },
    {
    name = "..."
    task_definition = "..."
    desired_count = 2
    loadbalancer = {
      targetgroup_arn = module.loadbalancer.portal_alb_arn,
      container_name = "main"
      container_port = 80
    }
    },
   ]

  vpc_subnets = module.vpc.private_subnets
  vpc_security_groups = [ module.ecs.ecs_task_security_group ]

  tags = local.tags
}

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@PeterBocan PeterBocan added the bug Addresses a defect in current functionality. label Oct 30, 2023
@github-actions github-actions bot added crash Results from or addresses a Terraform crash or kernel panic. service/ecs Issues and PRs that pertain to the ecs service. labels Oct 30, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 30, 2023
@justinretzolk justinretzolk changed the title [Bug]: [Bug]: Crash when creating aws_ecs_service resource Nov 7, 2023
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Nov 7, 2023
@jar-b jar-b self-assigned this Aug 15, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Aug 15, 2024
Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.63.0 milestone Aug 15, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Aug 15, 2024
Copy link

This functionality has been released in v5.63.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ecs Issues and PRs that pertain to the ecs service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants