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

Random ordered_placement_strategy #5387

Closed
ghost opened this issue Jul 30, 2018 · 4 comments · Fixed by #6176
Closed

Random ordered_placement_strategy #5387

ghost opened this issue Jul 30, 2018 · 4 comments · Fixed by #6176
Labels
service/ecs Issues and PRs that pertain to the ecs service.
Milestone

Comments

@ghost
Copy link

ghost commented Jul 30, 2018

This issue was originally opened by @Scherkan as hashicorp/terraform#18565. It was migrated here as a result of the provider split. The original body of the issue is below.


I can't attach random placement strategy to aws_ecs_service, according to:
https://www.terraform.io/docs/providers/aws/r/ecs_service.html#ordered_placement_strategy

Terraform Version

Terraform v0.11.7

  • provider.aws v1.29.0
  • provider.template v1.0.0
...

Terraform Configuration Files


resource "aws_ecs_service" "service" {
  name = "service"
  task_definition = "...."
  health_check_grace_period_seconds = 300
  cluster = "..."
  desired_count = 0
  launch_type = "EC2"

  load_balancer {
    target_group_arn = "..."
    container_name = "..."
    container_port = 8888
  }

  ordered_placement_strategy {
    type  = "spread"
    field = "attribute:ecs.availability-zone"
  }
  ordered_placement_strategy {
    type  = "spread"
    field = "instanceId"
  }

  ordered_placement_strategy {
    type = "random"
  }
  depends_on = ["aws_lb.internal"]
}
...

Debug Output

Crash Output

aws_ecs_service.config-server-service: Creating...
cluster: "" => "arn:aws:ecs:eu-west-2::cluster/cluster"
deployment_maximum_percent: "" => "200"
deployment_minimum_healthy_percent: "" => "100"
desired_count: "" => "0"
health_check_grace_period_seconds: "" => "300"
iam_role: "" => ""
launch_type: "" => "EC2"
load_balancer.#: "" => "1"
load_balancer.
.container_name: "" => "docker"
load_balancer.
.container_port: "" => "8888"
load_balancer.
.elb_name: "" => ""
load_balancer..target_group_arn: "" => "arn*..."
name: "" => "service"
ordered_placement_strategy.#: "" => "3"
ordered_placement_strategy.0.field: "" => "attribute:ecs.availability-zone"
ordered_placement_strategy.0.type: "" => "spread"
ordered_placement_strategy.1.field: "" => "instanceId"
ordered_placement_strategy.1.type: "" => "spread"
ordered_placement_strategy.2.type: "" => "random"
scheduling_strategy: "" => "REPLICA"
task_definition: "" => "arn:aws:
****"

Error: Error applying plan:

1 error(s) occurred:

  • aws_ecs_service.config-server-service: 1 error(s) occurred:

  • aws_ecs_service.config-server-service: InvalidParameterException: random field should not be specified.
    status code: 400, request id: 5fb108e7........................ "service"

Expected Behavior

Created ECS service, with correct placement strategy:

  • first AZ
  • second instanceID
  • random

Actual Behavior

Fail during apply script.

Steps to Reproduce

  1. terraform init
  2. terraform apply

Additional Context

@bflad bflad added question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. service/ecs Issues and PRs that pertain to the ecs service. and removed question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. labels Jul 30, 2018
@jnjackins
Copy link
Contributor

The problem is that the provider is sending the field parameter as an empty string, instead of omitting it.

2018-10-16T17:32:48.450Z [DEBUG] plugin.terraform-provider-aws_v1.36.0_x4: 2018/10/16 17:32:48 [DEBUG] Creating ECS service: {
...
2018-10-16T17:32:48.450Z [DEBUG] plugin.terraform-provider-aws_v1.36.0_x4:   PlacementStrategy: [{
2018-10-16T17:32:48.450Z [DEBUG] plugin.terraform-provider-aws_v1.36.0_x4:       Field: "",
2018-10-16T17:32:48.450Z [DEBUG] plugin.terraform-provider-aws_v1.36.0_x4:       Type: "random"
2018-10-16T17:32:48.450Z [DEBUG] plugin.terraform-provider-aws_v1.36.0_x4:     }],
...
2018/10/16 17:32:48 [DEBUG] [aws-sdk-go] {"__type":"InvalidParameterException","message":"random field should not be specified."}

Relevant tf code:

ordered_placement_strategy = [
    {
        type = "random"
    }
]

@bflad
Copy link
Contributor

bflad commented Oct 18, 2018

The fix for this has been merged and will release with version 1.41.0 of the AWS provider, later today. 👍

@bflad
Copy link
Contributor

bflad commented Oct 18, 2018

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

@ghost
Copy link
Author

ghost commented Apr 2, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/ecs Issues and PRs that pertain to the ecs service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants