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

Problem creating role since 6.3.0 #48

Open
1 task done
chrisyoungbrighte opened this issue May 7, 2024 · 0 comments
Open
1 task done

Problem creating role since 6.3.0 #48

chrisyoungbrighte opened this issue May 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@chrisyoungbrighte
Copy link

chrisyoungbrighte commented May 7, 2024

Contact Details (optional)

[email protected]

Description. What happened?

Since upgrading to v6.3.0 I am unable to deploy a brand new application. The error I receive is

 | Error: Invalid count argument
 │   on .terraform/modules/ecs-app/iam-ecs-task.tf line 2, in resource "aws_iam_role" "ecs_task":
 │    2:   count = var.task_role_arn != null ? 0 : 1
 │ 

I am providing the ARN of an IAM role. It seems like I would have to deploy that role first in order to avoid this problem?

Steps to reproduce

create a brand new stack with an IAM role and policy and the following configuration:

   new TerraformAwsEcsApp(this, "ecs-app", {
      vpcId: vpc.id,
      albListenerHttpsArn: albListener.arn,
      testTrafficRouteListenerArn: altAlbListener.arn,
      serviceRoleArn: serviceRole.arn,
      taskRoleArn: taskRole.arn,
      name: "service-name",
      image: "hello-world:latest",
      clusterName: cluster.clusterName,
      ecsServiceCapacityProviderStrategy: [],
      autoscalingMin: 1,
      autoscalingMax: 1,
      launchType: "EC2",
      containerPort: 4000,
      hostnameCreate: true,
      hostnames: ["hostname.domain"],
      hostedZone: "domain",
    });

Expected behavior

create the ECS service

Actual behavior

An error forming the plan

Occurrence

Frequently

Relevant log output

│ Error: Invalid count argument
                      │ 
terraform-typescript  │   on .terraform/modules/ecs-app/iam-ecs-task.tf line 2, in resource "aws_iam_role" "ecs_task":
                      │    2:   count = var.task_role_arn != null ? 0 : 1
                      │ 
                      │ The "count" value depends on resource attributes that cannot be determined
                      │ until apply, so Terraform cannot predict how many instances will be created.
                      │ To work around this, use the -target argument to first apply only the
                      │ resources that the count depends on.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@chrisyoungbrighte chrisyoungbrighte added the bug Something isn't working label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant