Skip to content

Instantly share code, notes, and snippets.

@archenroot
Last active November 6, 2019 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save archenroot/5b2f028e5b182d6f303fdeff48acaad1 to your computer and use it in GitHub Desktop.
Save archenroot/5b2f028e5b182d6f303fdeff48acaad1 to your computer and use it in GitHub Desktop.
Terraform AWS Provider Issue with ECS Service Tagging
resource "aws_ecs_service" "ignore_changes_task_definition" {
count = var.enabled && var.ignore_changes_task_definition ? 1 : 0
name = module.default_label.id
task_definition = "${join("", aws_ecs_task_definition.default.*.family)}:${join("", aws_ecs_task_definition.default.*.revision)}"
desired_count = var.desired_count
deployment_maximum_percent = var.deployment_maximum_percent
deployment_minimum_healthy_percent = var.deployment_minimum_healthy_percent
health_check_grace_period_seconds = var.health_check_grace_period_seconds
launch_type = var.launch_type
platform_version = var.launch_type == "FARGATE" ? var.platform_version : null
scheduling_strategy = var.launch_type == "FARGATE" ? "REPLICA" : var.scheduling_strategy
dynamic "service_registries" {
for_each = var.service_registries
content {
registry_arn = service_registries.value.registry_arn
port = lookup(service_registries.value, "port", null)
container_name = lookup(service_registries.value, "container_name", null)
container_port = lookup(service_registries.value, "container_port", null)
}
}
dynamic "ordered_placement_strategy" {
for_each = var.ordered_placement_strategy
content {
type = ordered_placement_strategy.value.type
field = lookup(ordered_placement_strategy.value, "field", null)
}
}
dynamic "placement_constraints" {
for_each = var.service_placement_constraints
content {
type = placement_constraints.value.type
expression = lookup(placement_constraints.value, "expression", null)
}
}
dynamic "load_balancer" {
for_each = var.ecs_load_balancers
content {
container_name = load_balancer.value.container_name
container_port = load_balancer.value.container_port
elb_name = lookup(load_balancer.value, "elb_name", null)
target_group_arn = lookup(load_balancer.value, "target_group_arn", null)
}
}
cluster = var.ecs_cluster_arn
propagate_tags = var.propagate_tags
tags = module.default_label.tags
deployment_controller {
type = var.deployment_controller_type
}
# https://www.terraform.io/docs/providers/aws/r/ecs_service.html#network_configuration
dynamic "network_configuration" {
for_each = var.network_mode == "awsvpc" ? ["true"] : []
content {
security_groups = compact(concat(var.security_group_ids, aws_security_group.ecs_service.*.id))
subnets = var.subnet_ids
assign_public_ip = var.assign_public_ip
}
}
lifecycle {
ignore_changes = [task_definition]
}
}
2019/11/06 11:41:10 [WARN] Provider "aws" produced an invalid plan for module.ecs_alb_service_task.aws_ecs_service.ignore_changes_task_definition[0], but we are tolerating it because it is using the legacy plugin SDK.
The following problems may be the cause of any confusing errors from downstream operations:
- .enable_ecs_managed_tags: planned value cty.False does not match config value cty.NullVal(cty.Bool)
- .placement_strategy: attribute representing nested block must not be unknown itself; set nested attribute values to unknown instead
2019/11/06 11:41:10 [DEBUG] module.ecs_alb_service_task.aws_ecs_service.ignore_changes_task_definition[0]: applying the planned Create change
2019-11-06T11:41:10.539+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: 2019/11/06 11:41:10 [DEBUG] setting computed for "placement_strategy" from ComputedKeys
2019-11-06T11:41:10.540+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: 2019/11/06 11:41:10 [DEBUG] Matching ^aws: with Stage
2019-11-06T11:41:10.540+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: 2019/11/06 11:41:10 [DEBUG] Matching ^aws: with Namespace
2019-11-06T11:41:10.540+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: 2019/11/06 11:41:10 [DEBUG] Matching ^aws: with Name
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: 2019/11/06 11:41:10 [DEBUG] Creating ECS service: {
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: ClientToken: "terraform-20191106104110540300000001",
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Cluster: "arn:aws:ecs:eu-west-1:387170473300:cluster/eg-dev-dip2admin-portalapi",
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: DeploymentConfiguration: {
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: MaximumPercent: 200,
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: MinimumHealthyPercent: 100
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: },
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: DeploymentController: {
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Type: "ECS"
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: },
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: DesiredCount: 1,
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: EnableECSManagedTags: false,
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: LaunchType: "FARGATE",
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: NetworkConfiguration: {
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: AwsvpcConfiguration: {
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: AssignPublicIp: "DISABLED",
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: SecurityGroups: ["sg-0628e82ea377bd126","sg-0cc84edf0f85b1338"],
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Subnets: ["subnet-0b1d7c83ae0a15608"]
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: }
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: },
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: PlatformVersion: "LATEST",
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: PropagateTags: "TASK_DEFINITION",
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: SchedulingStrategy: "REPLICA",
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: ServiceName: "eg-dev-dip2admin-portalapi",
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Tags: [{
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Key: "Stage",
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Value: "dev"
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: },{
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Key: "Namespace",
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Value: "eg"
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: },{
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Key: "Name",
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Value: "eg-dev-dip2admin-portalapi"
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: }],
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: TaskDefinition: "eg-dev-dip2admin-portalapi:3"
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: }
2019-11-06T11:41:10.542+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: 2019/11/06 11:41:10 [DEBUG] Waiting for state to become: [success]
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: 2019/11/06 11:41:10 [DEBUG] [aws-sdk-go] DEBUG: Request ecs/CreateService Details:
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: ---[ REQUEST POST-SIGN ]-----------------------------
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: POST / HTTP/1.1
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Host: ecs.eu-west-1.amazonaws.com
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: User-Agent: aws-sdk-go/1.25.22 (go1.13.3; windows; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.13 (+https://www.terraform.io)
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Content-Length: 808
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Authorization:
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Content-Type: application/x-amz-json-1.1
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: X-Amz-Date: 20191106T104110Z
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: X-Amz-Target: AmazonEC2ContainerServiceV20141113.CreateService
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Accept-Encoding: gzip
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe:
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: {"clientToken":"terraform-20191106104110540300000001","cluster":"arn:aws:ecs:eu-west-1:387170473300:cluster/eg-dev-dip2admin-portalapi","deploymentConfiguration":{"maximumPercent":200,"minimumHealthyPercent":100},"deploymentController":{"type":"ECS"},"desiredCount":1,"enableECSManagedTags":false,"launchType":"FARGATE","networkConfiguration":{"awsvpcConfiguration":{"assignPublicIp":"DISABLED","securityGroups":["sg-0628e82ea377bd126","sg-0cc84edf0f85b1338"],"subnets":["subnet-0b1d7c83ae0a15608"]}},"platformVersion":"LATEST","propagateTags":"TASK_DEFINITION","schedulingStrategy":"REPLICA","serviceName":"eg-dev-dip2admin-portalapi","tags":[{"key":"Stage","value":"dev"},{"key":"Namespace","value":"eg"},{"key":"Name","value":"eg-dev-dip2admin-portalapi"}],"taskDefinition":"eg-dev-dip2admin-portalapi:3"}
2019-11-06T11:41:10.544+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: -----------------------------------------------------
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: 2019/11/06 11:41:10 [DEBUG] [aws-sdk-go] DEBUG: Response ecs/CreateService Details:
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: ---[ RESPONSE ]--------------------------------------
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: HTTP/1.1 400 Bad Request
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Connection: close
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Content-Length: 160
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Content-Type: application/x-amz-json-1.1
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: Date: Wed, 06 Nov 2019 10:43:00 GMT
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: X-Amzn-Requestid: 05865e43-4b5d-43d4-b4e9-bc16ca492f2d
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe:
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe:
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: -----------------------------------------------------
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: 2019/11/06 11:41:10 [DEBUG] [aws-sdk-go] {"__type":"InvalidParameterException","message":"The new ARN and resource ID format must be enabled to propagate tags. Opt in to the new format and try again."}
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: 2019/11/06 11:41:10 [DEBUG] [aws-sdk-go] DEBUG: Validate Response ecs/CreateService failed, attempt 0/25, error InvalidParameterException: The new ARN and resource ID format must be enabled to propagate tags. Opt in to the new format and try again.
2019-11-06T11:41:10.901+0100 [DEBUG] plugin.terraform-provider-aws_v2.34.0_x4.exe: status code: 400, request id: 05865e43-4b5d-43d4-b4e9-bc16ca492f2d
2019/11/06 11:41:10 [DEBUG] module.ecs_alb_service_task.aws_ecs_service.ignore_changes_task_definition[0]: apply errored, but we're indicating that via the Error pointer rather than returning it: InvalidParameterException: The new ARN and resource ID format must be enabled to propagate tags. Opt in to the new format and try again.
status code: 400, request id: 05865e43-4b5d-43d4-b4e9-bc16ca492f2d "eg-dev-dip2admin-portalapi"
2019-11-06T11:41:10.921+0100 [DEBUG] plugin: plugin process exited: path=F:\proj\alpiq\dip2-environment-tf\environments\dev\dip2_admin_portal_be\.terraform\plugins\windows_amd64\terraform-provider-aws_v2.34.0_x4.exe pid=3092
2019-11-06T11:41:10.921+0100 [DEBUG] plugin: plugin exited
2019/11/06 11:47:50 [INFO] Terraform version: 0.12.13
2019/11/06 11:47:50 [INFO] Go runtime version: go1.12.9
2019/11/06 11:47:50 [INFO] CLI args: []string{"C:\\Users\\zangetsu\\devel\\terraform.exe", "-v"}
2019/11/06 11:47:50 [DEBUG] Attempting to open CLI config file: C:\Users\zangetsu\AppData\Roaming\terraform.rc
2019/11/06 11:47:50 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2019/11/06 11:47:50 [INFO] CLI command args: []string{"version", "-v"}
2019/11/06 11:47:50 [DEBUG] checking for provider in "."
2019/11/06 11:47:50 [DEBUG] checking for provider in "C:\\Users\\zangetsu\\devel"
2019/11/06 11:47:50 [DEBUG] checking for provider in ".terraform\\plugins\\windows_amd64"
2019/11/06 11:47:50 [DEBUG] found provider "terraform-provider-aws_v2.34.0_x4.exe"
2019/11/06 11:47:50 [DEBUG] found provider "terraform-provider-local_v1.4.0_x4.exe"
2019/11/06 11:47:50 [DEBUG] found provider "terraform-provider-null_v2.1.2_x4.exe"
2019/11/06 11:47:50 [DEBUG] found provider "terraform-provider-template_v2.1.2_x4.exe"
2019/11/06 11:47:50 [DEBUG] found valid plugin: "template", "2.1.2", "F:\\proj\\alpiq\\dip2-environment-tf\\environments\\dev\\dip2_admin_portal_be\\.terraform\\plugins\\windows_amd64\\terraform-provider-template_v2.1.2_x4.exe"
2019/11/06 11:47:50 [DEBUG] found valid plugin: "aws", "2.34.0", "F:\\proj\\alpiq\\dip2-environment-tf\\environments\\dev\\dip2_admin_portal_be\\.terraform\\plugins\\windows_amd64\\terraform-provider-aws_v2.34.0_x4.exe"
2019/11/06 11:47:50 [DEBUG] found valid plugin: "local", "1.4.0", "F:\\proj\\alpiq\\dip2-environment-tf\\environments\\dev\\dip2_admin_portal_be\\.terraform\\plugins\\windows_amd64\\terraform-provider-local_v1.4.0_x4.exe"
2019/11/06 11:47:50 [DEBUG] found valid plugin: "null", "2.1.2", "F:\\proj\\alpiq\\dip2-environment-tf\\environments\\dev\\dip2_admin_portal_be\\.terraform\\plugins\\windows_amd64\\terraform-provider-null_v2.1.2_x4.exe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment