Search code examples
aws-cloudformationprometheus

AWS Cloudformation template validation error?


I'm learning to implement Prometheus by following this excellent tutorial Monitor and scale your Amazon ECS on AWS Fargate application using Prometheus metrics.

I got to the View Prometheus metrics in CloudWatch section and get a template validation error when I ran their prometheus-install.sh script, so I did the following just to validate the template.

$ aws cloudformation validate-template --template-body ./install-prometheus-collector.yaml

and just get

An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: unsupported structure.

Adding the --debug option gives a traceback of the Python function calls, which raises the following exception at the very end

2024-01-31 11:31:10,921 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
  File "/usr/local/Cellar/awscli/2.14.5/libexec/lib/python3.11/site-packages/awscli/clidriver.py", line 460, in main
    return command_table[parsed_args.command](remaining, parsed_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/awscli/2.14.5/libexec/lib/python3.11/site-packages/awscli/clidriver.py", line 595, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/awscli/2.14.5/libexec/lib/python3.11/site-packages/awscli/clidriver.py", line 798, in __call__
    return self._operation_caller.invoke(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/awscli/2.14.5/libexec/lib/python3.11/site-packages/awscli/clidriver.py", line 929, in invoke
    response = self._make_client_call(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/awscli/2.14.5/libexec/lib/python3.11/site-packages/awscli/clidriver.py", line 941, in _make_client_call
    response = getattr(client, xform_name(operation_name))(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/awscli/2.14.5/libexec/lib/python3.11/site-packages/awscli/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/awscli/2.14.5/libexec/lib/python3.11/site-packages/awscli/botocore/client.py", line 724, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: unsupported structure.

An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: unsupported structure.

But it doesn't tell me what the unsupported structure is. Has anyone done this exercise who can help me with the error?

I didn't include the install-prometheus-collector.yaml template in the post since it's long, but it's in the link/section I mentioned.

Thanks!


Solution

  • --template-body ./install-prometheus-collector.yaml
    

    This is trying to validate a template containing the literal string ./install-prometheus-collector.yaml.

    To pass your template from a file, use the file URI:

    --template-body file://./install-prometheus-collector.yaml