By using AWS re:Post, you agree to the AWS re:Post Terms of Use

How do I resolve the "Resource specification is invalid" error when I use the CloudFormation CLI to run the cfn generate command?

2 minute read
0

When I use the AWS CloudFormation Command Line Interface (CloudFormation CLI) to run the cfn generate command in AWS CloudFormation, I receive the following error: "Resource specification is invalid."

Resolution

The cfn generate command generates code that's based on the project and resource type schema. You receive the "Resource specification is invalid" error when the resource type schema for your resource isn't valid. You might also receive a syntax or invalid namespace error.

To resolve the "Resource specification is invalid" error, complete the following steps:

  1. In the root directory of the project where you run the cfn init command, open the organization-service-resource.json resource type schema.
    Note: Replace organization-service-resource.json with the file name for your resource and service. For example, for an Amazon Elastic Cloud Compute (Amazon EC2) resource named Article::EC2::Subnet, the file name is article-ec2-subnet.json.
  2. Confirm that your organization-service-resource.json file uses the correct JSON syntax.
  3. Compare the namespaces of your resource with the namespaces in the resource type schema. Resolve any discrepancies that you find.

If the preceding steps don't resolve the issue, then use cfn init to create a new project. Incrementally update the organization-service-resource.json resource type schema until you find the change that causes the "Resource specification is invalid" error.

For other errors that are related to resource providers, see the following articles:

Related information

CloudFormation CLI on the GitHub website

AWS OFFICIAL
AWS OFFICIALUpdated 2 months ago