hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.78k stars 9.14k forks source link

[Bug]: │ This is a bug in the provider, which should be reported in the provider's own issue tracker. #38461

Closed chrisolido closed 2 months ago

chrisolido commented 2 months ago

Terraform Core Version

0.9.1

AWS Provider Version

5.59.0

Affected Resource(s)

Circle CI

Expected Behavior

Should run the release smoothly

Actual Behavior

│ │ This is a bug in the provider, which should be reported in the provider's own issue tracker. ╵

Exited with code exit status 1

Relevant Error/Panic Output Snippet

│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for module.crs.aws_ecs_task_definition.taskDefinition to include new values learned so far during apply

Terraform Configuration Files

│ │ This is a bug in the provider, which should be reported in the provider's own issue tracker. ╵ ╷ │ Error: Provider produced inconsistent final plan │ │ When expanding the plan for module.crs.aws_ecs_task_definition.taskDefinition to include new values learned so far during apply

Steps to Reproduce

│ │ This is a bug in the provider, which should be reported in the provider's own issue tracker. ╵ ╷ │ Error: Provider produced inconsistent final plan │ │ When expanding the plan for module.crs.aws_ecs_task_definition.taskDefinition to include new values learned so far during apply

Debug Output

│ │ This is a bug in the provider, which should be reported in the provider's own issue tracker. ╵ ╷ │ Error: Provider produced inconsistent final plan │ │ When expanding the plan for module.crs.aws_ecs_task_definition.taskDefinition to include new values learned so far during apply

Panic Output

│ │ This is a bug in the provider, which should be reported in the provider's own issue tracker. ╵ ╷ │ Error: Provider produced inconsistent final plan │ │ When expanding the plan for module.crs.aws_ecs_task_definition.taskDefinition to include new values learned so far during apply

Important Factoids

│ │ This is a bug in the provider, which should be reported in the provider's own issue tracker. ╵ ╷ │ Error: Provider produced inconsistent final plan │ │ When expanding the plan for module.crs.aws_ecs_task_definition.taskDefinition to include new values learned so far during apply

References

│ │ This is a bug in the provider, which should be reported in the provider's own issue tracker. ╵ ╷ │ Error: Provider produced inconsistent final plan │ │ When expanding the plan for module.crs.aws_ecs_task_definition.taskDefinition to include new values learned so far during apply

Would you like to implement a fix?

None

github-actions[bot] commented 2 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

jared-rowe commented 2 months ago

Same issue here with aws_ecs_task_definition

Terraform Core Version 1.9.2

AWS Provider Version 5.59.0

Error:

Error: Provider produced inconsistent final plan
When expanding the plan for aws_ecs_task_definition.<the_task> to include new
values learned so far during apply, provider
"registry.terraform.io/hashicorp/aws" produced an invalid new value for
.container_definitions: inconsistent values for sensitive attribute.
This is a bug in the provider, which should be reported in the provider's own
issue tracker.

Resolved by pinning AWS provider to 5.58.0

ewbankkit commented 2 months ago

Relates https://github.com/hashicorp/terraform-provider-aws/pull/38016.

ewbankkit commented 2 months ago

@chrisolido @jared-rowe Thanks for reporting this issue 👏. A couple of questions to help with a quick resolution:

cdsre commented 2 months ago

@ewbankkit We are seeing it on new deployments. during the apply it doesnt show a container task definition in the resource

  # module.container_ui[0].aws_ecs_task_definition.this will be created
  + resource "aws_ecs_task_definition" "this" {
      + arn                      = (known after apply)
      + arn_without_revision     = (known after apply)
      + cpu                      = "256"
      + execution_role_arn       = (known after apply)
      + family                   = "example"
      + id                       = (known after apply)
      + memory                   = "512"
      + network_mode             = "awsvpc"
      + requires_compatibilities = [
          + "FARGATE",
        ]
      + revision                 = (known after apply)
      + skip_destroy             = false
      + tags                     = {
          + "Name" = "example"
        }
      + tags_all                 = {
          + "Environment"     = "development"
          + "EnvironmentName" = "DW037"
          + "Name"            = "example"
          + "Owner"           = "example"
          + "Pipeline"        = "https://example.com/devops-terraform-modules/example/-/pipelines/130717"
          + "Terraform"       = "true"
        }
      + task_role_arn            = (known after apply)
      + track_latest             = false
    }

If we replay this CI job, then it does go ahead and redeploy the resources successfully and the apply shows the container_defs on the second run

# module.container_ui[0].aws_ecs_task_definition.this will be created
  + resource "aws_ecs_task_definition" "this" {
      + arn                      = (known after apply)
      + arn_without_revision     = (known after apply)
      + container_definitions    = jsonencode(
            [
              + {
                  + Command                = null
                  + Cpu                    = 0
                  + CredentialSpecs        = null
                  + DependsOn              = null
                  + DisableNetworking      = null
...
...
...
                 + VolumesFrom            = null
                  + WorkingDirectory       = null
                },
            ]
        )
      + cpu                      = "256"
...

In our case the error was

╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for
│ module.container_ui[0].aws_ecs_task_definition.this to include new values
│ learned so far during apply, provider "registry.terraform.io/hashicorp/aws"
│ produced an invalid new value for .container_definitions: was
│ cty.StringVal(""), but now
│ cty.StringVal("[{\"Command\":null,\"Cpu\":0,\"CredentialSpecs\":null,\"DependsOn\":null,\"DisableNetworking\":null,\"DnsSearchDomains\":null,\"DnsServers\":null,\"DockerLabels\":null,\"DockerSecurityOptions\":null,\"EntryPoint\":null
...
...
\"StopTimeout\":null,\"SystemControls\":null,\"Ulimits\":null,\"User\":null,\"VolumesFrom\":null,\"WorkingDirectory\":null}]").
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵
jared-rowe commented 2 months ago

Hi

@chrisolido @jared-rowe Thanks for reporting this issue 👏. A couple of questions to help with a quick resolution:

  • Are you seeing these errors when creating completely new task definitions or when planning/applying updates to existing (pre-v5.59.0) resources?
  • Can you share the container_definitions configuration (as much as possible) that is causing the problem?

Hi @ewbankkit - thanks for jumping on this quickly.

Errors are occurring with new deployments creating new task definitions with v5.59.0. Task definition with container definition (resource names, env vars, etc. have been generalised) looks like:

resource "aws_ecs_task_definition" "this" {
  family                   = "example-family"
  network_mode             = "awsvpc"
  requires_compatibilities = ["FARGATE"]
  cpu                      = 1024
  memory                   = 4096
  execution_role_arn       = aws_iam_role.task_execution.arn

  container_definitions = jsonencode([
    {
      name  = local.container_name
      image = local.image
      portMappings = [
        {
          containerPort = 1234,
          hostPort      = 1234
        }
      ]
      environment = [
        {
          name  = "example1"
          value = "123"
        },
        {
          name  = "example2"
          value = "456"
        },
        {
          name  = "example3"
          value = "789"
        }
      ]
      secrets = [
        {
          name      = "example4"
          valueFrom = aws_ssm_parameter.secret_launch_code.arn
        }
      ]
      logConfiguration = {
        logDriver = "awslogs"
        options = {
          "awslogs-group"         = aws_cloudwatch_log_group.task_logs.name
          "awslogs-region"        = data.aws_region.current.name
          "awslogs-stream-prefix" = "ecs"
        }
      }
    }
  ])
}
aldenbe commented 2 months ago

@chrisolido @jared-rowe Thanks for reporting this issue 👏. A couple of questions to help with a quick resolution:

  • Are you seeing these errors when creating completely new task definitions or when planning/applying updates to existing (pre-v5.59.0) resources?
  • Can you share the container_definitions configuration (as much as possible) that is causing the problem?

See https://github.com/hashicorp/terraform-provider-aws/issues/38482 which I closed as duplicate, this issue was introduced in version v5.59.0 downgrading to v5.58.0 works as expected.

thomaszlow commented 2 months ago

@aldenbe You made my week! Downgrading to v5.58.0 also worked for my new task deployments.

I did a lot of debugging the last days to find out what is causing the issue but couldn't find anything. My first thought was that a line break in the healthCheck is the problem because it is marked in the Actions log as an error but removing all healtChecks didn't solve it.

image

ewbankkit commented 2 months ago

@jared-rowe Thanks for your example configuration -- we can reproduce the issue with it.

github-actions[bot] commented 2 months ago

[!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[bot] commented 2 months ago

This functionality has been released in v5.60.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!

github-actions[bot] commented 1 month ago

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.