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

resources.Rules property is unregonized #12182

Open
4 tasks done
Itamaram opened this issue Sep 25, 2023 · 3 comments · May be fixed by #12188
Open
4 tasks done

resources.Rules property is unregonized #12182

Itamaram opened this issue Sep 25, 2023 · 3 comments · May be fixed by #12188

Comments

@Itamaram
Copy link

Are you certain it's a bug?

  • Yes, it looks like a bug

Is the issue caused by a plugin?

  • It is not a plugin issue

Are you using the latest v3 release?

  • Yes, I'm using the latest v3 release

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Issue description

Adding a Rules property to the resources section in a serverless yml file eg

resources:
  Rules:
    ValidateStage:
      Assertions:
        - Assert:
            'Fn::Contains':
              - - dev
                - int
              - ${self:provider.stage}
          AssertDescription: Stack must only be deployed in lower envs

Yields the following warning:

Invalid configuration encountered at 'resources': unrecognized property 'Rules'

Despite it yielding the correct json:

  "Rules": {
    "ValidateStage": {
      "Assertions": [
        {
          "Assert": {
            "Fn::Contains": [
              [
                "dev",
                "int"
              ],
              "dev"
            ]
          },
          "AssertDescription": "Stack must only be deployed in lower envs"
        }
      ]
    }
  }

(Which behaves correctly)

It appears this issue is just the validation of the serverless.yml file is incorrect, and the Rule property should be regonized.

Service configuration (serverless.yml) content

service: sample-service
configValidationMode: error

provider:
  name: aws
  stage: dev
  region: us-east-1

resources:
  Rules:
    ValidateStage:
      Assertions:
        - Assert:
            'Fn::Contains':
              - - dev
                - int
              - ${self:provider.stage}
          AssertDescription: Stack must only be deployed in lower envs

Command name and used flags

serverless deploy

Command output

Environment: win32, node 18.7.0, framework 3.35.2 (local), plugin 7.0.3, SDK 4.4.0
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Configuration error at 'resources': unrecognized property 'Rules'

Environment information

Framework Core: 3.35.2 (local)
Plugin: 7.0.3
SDK: 4.4.0
@Itamaram Itamaram linked a pull request Sep 27, 2023 that will close this issue
@Itamaram
Copy link
Author

I've created a PR to add the Rules section to the schema used based on the schema found here: https://github.com/lalcebo/json-schema/blob/master/serverless/reference.json

@ricardomorita42
Copy link

I've noticed that the rules are using Pascal case instead of the usual Camel case. Wouldn't it be better to have it using camel case too? I've never used rules though so I'm not sure what's what in this case.

@Itamaram
Copy link
Author

What do you mean by "the usual Camel case"?

As far as I can see, according to the schema all child properties of resources are using Pascal case (which makes sense if they're simply passed as is into CloudFormation script).

Rules will be added next to Condition, Outputs, Resources and other similarly cased properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants