Search code examples
aws-samtoml

samconfig.toml - What is the meaning of version?


What is the meaning of version=0.1 (or indeed, version=x.x for some other version) at the top of the AWS SAM CLI configuration file?

I've looked through a couple of AWS docs and can't seem to find an explanation for what the version means/does: Optimizing serverless development with samconfig and AWS SAM CLI configuration file

I've also sifted through all SO posts containing "samconfig.toml" & searched Google but cannot find anything explaining what the version is or why it's needed.

I can see that it is indeed needed because if I don't have it I get this error:

Error: Error reading configuration: 'version' key is not present or is in unrecognized format.

I'm not stuck. I've popped in version=0.1 at the top of my file and it got me past the above error. But I'd rather learn what this thing is vs. blindly copy over the boilerplate and fall into the habit of cargo cult programming.


Solution

  • I tried deleting the version line from the samconfig.toml and got the same error as you:

    Error: Error reading configuration: 'version' key is not present or is in unrecognized format.
    

    Regarding the error, what I found first was this same Stack Overflow question, but searching a bit more I found the following in one of the files of aws-sam-cli repo:

    The configuration file: samconfig.toml will come with a top level version key that specifies the version of the configuration file based on the spec of the file

    The version line in the samconfig.toml is used by SAM to determine if a given config file works together with a SAM CLI version.

    This version can then be used to determine if a given configuration file works with a given version of SAM CLI

    And unless you need a new feature of a future higher version, you can stick using version=0.1

    SAM CLI will remain backward compatible with reading older configuration file versions.