Can we consul validate command to validate service intentions configuration entry kind?

consul validate command works fine for consul configuration.
But it throws error if i try to validate service-intentions, service defaults configuration entry kind.

service-intentions.hcl

Kind = "service-intentions"
Name = "*"
Sources = [
  {
    Name   = "*"
    Action = "deny"
  }
]
consul validate service-intentions.hcl
Config validation failed: failed to parse service-intentions.hcl: 3 errors occurred:
	* invalid config key Name
	* invalid config key Sources
	* invalid config key Kind

Is there anything missing.
Also is there any other way to validate service-intentions format.

Same problem here in 2024. Any luck on this @shweshi ?

The consul validate command can only be used to validate Consul agent configurations.

Unfortunately, there are no equivalent commands to validate config entries.

Ah, I guess you’re right Commands: Validate | Consul | HashiCorp Developer

This command cannot operate on partial configuration fragments since those won’t pass the full agent validation.

But at the same time, this is the very same error I get when create the intentions config file in my consul’s data dir. So the question still remains, what is the correct way to do this via configuration?

Hi @jean-simon-barry1,

I think you meant Consul’s config dir?

The right way to do this within the agent configuration is by using config_entries.bootstrap option.

Ref: Agents - Configuration File Reference | Consul | HashiCorp Developer

You can find examples in this KB article: How to Write Config Entries to the Agent Configuration file – HashiCorp Help Center

Please note that, even with this scenario, there is no real validation done to the config entries.

I hope this helps.