Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Fails to validate valid CloudFormation syntax #7881

Closed
scolebrook opened this issue Feb 11, 2025 · 3 comments
Closed

Bug: Fails to validate valid CloudFormation syntax #7881

scolebrook opened this issue Feb 11, 2025 · 3 comments
Labels
area/validate sam validate command type/bug

Comments

@scolebrook
Copy link

Description:

sam validate relies on cfn-lint. SAM currently uses 1.20.1. Current version with up to date CloudFormation schema is 1.22.4. Example use case is adding the new PointInTimeRecoverySpecification.RecoveryPeriodInDays property to a DynamoDB table resource. cfn-lint 1.22.4 validates the template. SAM 1.132.0 doesn't, giving the following error message (generated mostly by the out of date cfn-lint):

[[E3002: Resource properties are invalid] (Additional properties are not allowed ('RecoveryPeriodInDays' was unexpected)) matched 151]
Error: Linting failed. At least one linting rule was matched to the provided template.

#7827 Did not resolve the issue.

Steps to reproduce:

Add the following resource to an otherwise valid SAM template:

  table:
    Type: "AWS::DynamoDB::Table"
    Properties:
      TableName: "MyTable"
      AttributeDefinitions:
        - AttributeName: "pk"
          AttributeType: "S"
      KeySchema:
        - AttributeName: "pk"
          KeyType: "HASH"
      PointInTimeRecoverySpecification:
        PointInTimeRecoveryEnabled: true
        RecoveryPeriodInDays: 7

Run sam validate.

Observed result:

Error message.

Expected result:

Passing validation.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

{
  "version": "1.133.0",
  "system": {
    "python": "3.11.10",
    "os": "macOS-15.3-x86_64-i386-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "Not available",
    "aws_cdk": "2.26.0 (build a409d63)",
    "terraform": "1.10.5"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}
@scolebrook scolebrook added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Feb 11, 2025
@mbfreder
Copy link
Contributor

Hi, thanks for reporting this. This validation error is occurring because your SAM CLI (v1.133.0) is using an outdated CloudFormation specification that doesn't recognize the RecoveryPeriodInDays property, which is a valid and relatively recent addition to DynamoDB tables. The simplest solution is to update your SAM CLI to the latest version (v1.135.0).

After updating, please try running sam validate again. The latest version should include updated CloudFormation specifications that recognize the RecoveryPeriodInDays property.

@vicheey
Copy link
Contributor

vicheey commented Mar 28, 2025

I am able to run sam validate successfully for the following template using SAM

sam --version
SAM CLI, version 1.134.0
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31

Resources:
  table:
    Type: "AWS::DynamoDB::Table"
    Properties:
      TableName: "MyTable"
      AttributeDefinitions:
        - AttributeName: "pk"
          AttributeType: "S"
      KeySchema:
        - AttributeName: "pk"
          KeyType: "HASH"
      PointInTimeRecoverySpecification:
        PointInTimeRecoveryEnabled: true
        RecoveryPeriodInDays: 7

@vicheey vicheey added type/bug area/validate sam validate command and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Mar 28, 2025
@vicheey vicheey closed this as completed Mar 28, 2025
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/validate sam validate command type/bug
Projects
None yet
Development

No branches or pull requests

3 participants