Aws-toolkit-jetbrains: IDEA does not fully recognise SAM template not named template.yaml

Created on 18 Feb 2021  路  3Comments  路  Source: aws/aws-toolkit-jetbrains

Describe the bug
I would like to name my SAM template sam.yaml instead of the default template.yaml,
but then syntax highlighting fails for the Globals section.

To reproduce

  1. Create a trivial project with template.yaml as follows:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  Generated by sam init

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 20

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      CodeUri: HelloWorldFunction
      Handler: helloworld.App::handleRequest
      Runtime: java11
      MemorySize: 512
      Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
        Variables:
          PARAM1: VALUE
      Events:
        HelloWorld:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /hello
            Method: get

It will look fine in the editor.

  1. Rename it to sam.yaml.
    Syntax highlighting now fires up on the Globals section:

Schema validation: Property 'Globals' is not allowed

Expected behavior
IDEA should continue to recognise it as a SAM template (from its initial lines).
(This would also cover the case of other files named template.yaml that are not SAM templates.)

Your Environment
IntelliJ IDEA 2020.3.2 (Ultimate Edition)
Build #IU-203.7148.57, built on January 26, 2021
Licensed to Andreas Nyberg
You have a perpetual fallback license for this version.
Subscription is active until January 2, 2022.
Runtime version: 11.0.9.1+11-b1145.77 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 8192M
Cores: 8
Registry: debugger.watches.in.variables=false, scala.erase.compiler.process.jdk.once=false
Non-Bundled Plugins: Batch Scripts Support, main.kotlin.com.jimschubert.intellij.swaggercodegen, open-liberty.intellij, SpotProfiler, com.crownpartners.intellivault, com.thesamet.intellij.ScariformFormat, ru.artyushov, soapUI Plugin, org.jetbrains.plugins.hocon, Jetbrains TeamCity Plugin, org.jfrog.idea, com.intellij.plugin.adernov.powershell, com.dmarcotte.handlebars, aws.toolkit, org.jetbrains.kotlin, org.mapstruct.intellij, JProfiler, org.intellij.scala

guidance

Most helpful comment

I ran into this too, and opened a PR to schemastore that should fix it: https://github.com/SchemaStore/schemastore/pull/1536

All 3 comments

Syntax highlighting for SAM templates is actually done by Intellij itself:
Screen Shot 2021-02-18 at 8 25 40 AM
(down in the bottom left corner). If there is an issue with the schema, they seem to come from SchemaStore.org. We are planning on improving the plugin support to improve this experiences (See issue https://github.com/aws/aws-toolkit-jetbrains/issues/2183 for an example of things we want to improve), but we currently do not do anything with syntax highlighting or code completion.

Ran into this today, there looks to be a issue in the repo responsible for the schema that is used in the IDE.

https://github.com/awslabs/goformation/issues/305

I ran into this too, and opened a PR to schemastore that should fix it: https://github.com/SchemaStore/schemastore/pull/1536

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michaelschem picture michaelschem  路  3Comments

maranqz picture maranqz  路  4Comments

michaeljfazio picture michaeljfazio  路  6Comments

seans11 picture seans11  路  4Comments

AMcManigal picture AMcManigal  路  3Comments