0
votes

I am trying to apply my cloudformation template and I am getting the following cryptic error:

botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the CreateStack operation: Template error: Condition token can only be used in Conditions block

The stack trace is

  File "/Users/user/.env/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Users/user/.env/lib/python3.7/site-packages/botocore/client.py", line 661, in _make_api_call
    raise error_class(parsed_response, operation_name)

The code looks like

cf_client = session.client('cloudformation')
cf_client.create_stack(
        StackName=stack_name,
        TemplateBody=template_body,
        Parameters=aws_parameters,
        TimeoutInMinutes=10,
        OnFailure='DELETE',
        Tags=aws_tags,
        Capabilities=['CAPABILITY_IAM'],
    )

The cloudformation template is massive and not appropriate to paste here. It stands up an application with service discovery, app mesh, fargate, etc.

What is this Condition they're referring to and what is wrong?

1

1 Answers

0
votes

The error is rather cryptic and unhelpful but in my case, it was a typo in my ECS task definition.

My container has a depends on relationship and I had misconstructed the

      DependsOn:
      - ContainerName: envoy
      - Condition: HEALTHY

Depends on is a list of maps so there should not be a - in front of Condition.

This corrects my problem:

      DependsOn:
      - ContainerName: envoy
        Condition: HEALTHY