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: sam validate --lint does not catch plural error in scheduled events #6563

Closed
atacan opened this issue Jan 16, 2024 · 3 comments
Closed
Labels
area/validate sam validate command

Comments

@atacan
Copy link

atacan commented Jan 16, 2024

Description:

Steps to reproduce:

given the template with Schedule: rate(8 hour) instead of hours

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: SAM Template for Awesome

Globals:
  Function:
    Timeout: 60
    CodeUri: .
    Handler: swift.bootstrap
    Runtime: provided.al2
    MemorySize: 512
    Architectures:
      - arm64

Resources:
  # Lambda function
  MyAwesomeFunc:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        # run every 8 hour
        Schedule:
          Type: Schedule
          Properties:
            Schedule: rate(8 hour)
            Enabled: true
    Metadata:
      BuildMethod: makefile

# print API endpoint and name of database table
Outputs:
  MyAwesomeFunc:
    Description: "MyAwesomeFunc"
    Value: !GetAtt MyAwesomeFunc.Arn

run

sam validate --lint --profile Administrator_Access

Observed result:

./template.yml is a valid SAM Template.

Expected result:

  • validation should fail because the deployment fails with "Parameter ScheduleExpression is not valid. on CloudWatch

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

  1. AWS region: eu-central-1
{
  "version": "1.107.0",
  "system": {
    "python": "3.12.1",
    "os": "macOS-14.2.1-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "24.0.7",
    "aws_cdk": "2.117.0 (build 59d9b23)",
    "terraform": "Not available"
  },
  "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"
  ]
}

Add --debug flag to command you are running

2024-01-16 18:15:42,454 | Config file location: /Users/atacan/Repositories/myproject/samconfig.toml
2024-01-16 18:15:42,455 | Loading configuration values from [default.['validate'].parameters] (env.command_name.section) in config file at
'/Users/atacan/Repositories/myproject/samconfig.toml'...
2024-01-16 18:15:42,456 | Configuration values successfully loaded.
2024-01-16 18:15:42,456 | Configuration values are: {}
2024-01-16 18:15:42,458 | Using SAM Template at /Users/atacan/Repositories/myproject/template.yml
2024-01-16 18:15:42,472 | Using config file: samconfig.toml, config environment: default
2024-01-16 18:15:42,472 | Expand command line arguments to:
2024-01-16 18:15:42,473 | --template_file=/Users/atacan/Repositories/myproject/template.yml --lint
2024-01-16 18:15:42,972 - cfnlint - DEBUG - Looking for CFLINTRC before attempting to load
2024-01-16 18:15:42,972 - cfnlint - DEBUG - Validating User CFNLINTRC
2024-01-16 18:15:42,972 - cfnlint - DEBUG - Validating CFNLINTRC config with given JSONSchema
2024-01-16 18:15:42,972 - cfnlint - DEBUG - Schema used: {'$id': 'https://github.com/aws-cloudformation/cfn-python-lint/blob/main/src/cfnlint/data/CfnLintCli/config/schema.json', '$schema': 'http://json-schema.org/draft-07/schema#', 'additionalProperties': False, 'description': 'CFNLINTRC configuration schema', 'properties': {'append_rules': {'description': 'Location of directories to append rules from', 'items': {'type': 'string'}, 'type': 'array'}, 'configure_rules': {'additionalProperties': False, 'description': 'Configure rules', 'patternProperties': {'^.*$': {'patternProperties': {'^.*$': {'anyOf': [{'type': 'string'}, {'type': 'integer'}, {'type': 'boolean'}, {'items': {'type': 'string'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'boolean'}]}}, 'type': 'object'}}, 'type': 'object'}, 'custom_rules': {'description': 'custom rule file to use', 'type': 'string'}, 'ignore_checks': {'description': 'List of checks to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'ignore_templates': {'description': 'Templates to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'include_checks': {'description': 'List of checks to include', 'items': {'type': 'string'}, 'type': 'array'}, 'mandatory_checks': {'description': 'List of mandatory checks to enforce', 'items': {'type': 'string'}, 'type': 'array'}, 'merge_configs': {'description': 'Merges lists between configuration layers', 'type': 'boolean'}, 'output_file': {'description': 'Path to the file to write the main output to', 'type': 'string'}, 'override_spec': {'description': 'Path to spec file to override with', 'type': 'string'}, 'regions': {'description': 'Regions to test against', 'items': {'type': 'string'}, 'type': 'array'}, 'registry_schemas': {'description': 'One or more directories of CloudFormation Registry Resource Schemas', 'items': {'type': 'string'}, 'type': 'array'}, 'templates': {'description': 'Templates to lint', 'items': {'type': 'string'}, 'type': 'array'}}, 'title': 'CFNLINTRC JSON Schema', 'type': 'object'}
2024-01-16 18:15:42,972 - cfnlint - DEBUG - Config used: {}
2024-01-16 18:15:42,973 - cfnlint - DEBUG - CFNLINTRC looks valid!
2024-01-16 18:15:42,973 - cfnlint - DEBUG - Validating Project CFNLINTRC
2024-01-16 18:15:42,973 - cfnlint - DEBUG - Validating CFNLINTRC config with given JSONSchema
2024-01-16 18:15:42,973 - cfnlint - DEBUG - Schema used: {'$id': 'https://github.com/aws-cloudformation/cfn-python-lint/blob/main/src/cfnlint/data/CfnLintCli/config/schema.json', '$schema': 'http://json-schema.org/draft-07/schema#', 'additionalProperties': False, 'description': 'CFNLINTRC configuration schema', 'properties': {'append_rules': {'description': 'Location of directories to append rules from', 'items': {'type': 'string'}, 'type': 'array'}, 'configure_rules': {'additionalProperties': False, 'description': 'Configure rules', 'patternProperties': {'^.*$': {'patternProperties': {'^.*$': {'anyOf': [{'type': 'string'}, {'type': 'integer'}, {'type': 'boolean'}, {'items': {'type': 'string'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'boolean'}]}}, 'type': 'object'}}, 'type': 'object'}, 'custom_rules': {'description': 'custom rule file to use', 'type': 'string'}, 'ignore_checks': {'description': 'List of checks to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'ignore_templates': {'description': 'Templates to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'include_checks': {'description': 'List of checks to include', 'items': {'type': 'string'}, 'type': 'array'}, 'mandatory_checks': {'description': 'List of mandatory checks to enforce', 'items': {'type': 'string'}, 'type': 'array'}, 'merge_configs': {'description': 'Merges lists between configuration layers', 'type': 'boolean'}, 'output_file': {'description': 'Path to the file to write the main output to', 'type': 'string'}, 'override_spec': {'description': 'Path to spec file to override with', 'type': 'string'}, 'regions': {'description': 'Regions to test against', 'items': {'type': 'string'}, 'type': 'array'}, 'registry_schemas': {'description': 'One or more directories of CloudFormation Registry Resource Schemas', 'items': {'type': 'string'}, 'type': 'array'}, 'templates': {'description': 'Templates to lint', 'items': {'type': 'string'}, 'type': 'array'}}, 'title': 'CFNLINTRC JSON Schema', 'type': 'object'}
2024-01-16 18:15:42,973 - cfnlint - DEBUG - Config used: {}
2024-01-16 18:15:42,974 - cfnlint - DEBUG - CFNLINTRC looks valid!
2024-01-16 18:15:42,974 - cfnlint - DEBUG - User configuration loaded as
2024-01-16 18:15:42,974 - cfnlint - DEBUG - {}
2024-01-16 18:15:42,974 - cfnlint - DEBUG - Project configuration loaded as
2024-01-16 18:15:42,974 - cfnlint - DEBUG - {}
2024-01-16 18:15:42,974 - cfnlint - DEBUG - Merging configurations...
/Users/atacan/Repositories/myproject/template.yml is a valid SAM Template
2024-01-16 18:15:43,036 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2024-01-16 18:15:43,065 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2024-01-16 18:15:43,066 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '0ce87a22-e280-472a-bd1a-3a098d130c14', 'installationId':
'6be8a57f-70d8-47d6-9d1c-06dd248d020e', 'sessionId': 'c66e0e4c-791a-4365-9322-9723bb859f9f', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.12.1', 'samcliVersion':
'1.107.0', 'awsProfileProvided': True, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam validate', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None,
'projectName': '4e5371bf8bd659e39cc20bf10130c307e97e7b21cd2319c996c7b495ddd98c2d', 'initialCommit': None}, 'duration': 563, 'exitReason': 'success', 'exitCode': 0}}]}
2024-01-16 18:15:43,066 | Unable to find Click Context for getting session_id.
2024-01-16 18:15:43,068 | Sending Telemetry: {'metrics': [{'events': {'requestId': 'cea05018-57e1-435c-8f24-87f4c67c47e5', 'installationId': '6be8a57f-70d8-47d6-9d1c-06dd248d020e',
'sessionId': 'c66e0e4c-791a-4365-9322-9723bb859f9f', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.12.1', 'samcliVersion': '1.107.0', 'commandName': 'sam validate',
'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '3de3dc7cf98e4c53aad7bc936a77d92c', 'time_stamp': '2024-01-16
17:15:42.454', 'exception_name': None}, {'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '04800ef2dd8942f48fe8d2f63cbd43a7', 'time_stamp': '2024-01-16
17:15:42.472', 'exception_name': None}, {'event_name': 'UsedFeature', 'event_value': 'CFNLint', 'thread_id': '26df8789134040c5ba1ce386f3141e9e', 'time_stamp': '2024-01-16
17:15:42.971', 'exception_name': None}]}}}]}
2024-01-16 18:15:43,725 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
2024-01-16 18:15:43,727 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
@atacan atacan added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Jan 16, 2024
@hnnasit
Copy link
Contributor

hnnasit commented Jan 16, 2024

Hi @atacan, looking at the docs for valid rate expressions, your observation makes sense to me. sam validate --lint runs cfn-lint in background. Let me check with cfn-lint team regarding this.

@hnnasit hnnasit added 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 Jan 16, 2024
@hnnasit
Copy link
Contributor

hnnasit commented Jan 18, 2024

I checked with the cfn-lint team and this is an existing feature request on their repo. I am closing this issue as there is nothing to do on SAM CLI side. Please follow the issue for any updates.

@hnnasit hnnasit closed this as completed Jan 18, 2024
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
Projects
None yet
Development

No branches or pull requests

2 participants