Skip to content

adds anchor & alias support for yaml parser - #566

Closed
shortjared wants to merge 1 commit into
aws:developfrom
shortjared:feature/yaml-anchors-and-aliases
Closed

shortjared wants to merge 1 commit into
aws:developfrom
shortjared:feature/yaml-anchors-and-aliases

Conversation

@shortjared

Copy link
Copy Markdown
Contributor

Issue #, if available:

No issue number specifically, but this has been mentioned before in several cases and a feature I wanted natively in CloudFormation but we aren't going to get anytime soon. (ex: aws/serverless-application-model#228)

Description of changes:

This simply enhances the yaml parser in exactly the same way I propose the aws-cli does (aws/aws-cli#3462). Mostly just making sure we maintain consistency across the platform.

Important to note, this is doing nothing that nearly all other yaml libs can't do. Take the below template for example and plug it in to http://yaml-online-parser.appspot.com and you'll get perfectly valid json outputs with no additional logic. Of course, you would still need aws cloudformation package to populate the CodeUri but that is a different process.

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: A starter AWS Lambda function.

Metadata:
  Templates:
    Resources:
      Properties: &Props
        Handler: lambda_function.lambda_handler
        Runtime: python3.6
        CodeUri: .
        Description: A starter AWS Lambda function.
        MemorySize: 128
        Timeout: 3

Resources:
  helloworldpython3:
    Type: 'AWS::Serverless::Function'
    Properties:
      <<: *Props

  helloworldnode:
    Type: 'AWS::Serverless::Function'
    Properties:
      <<: *Props
      Runtime: nodejs8.10

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jfuss

jfuss commented Aug 2, 2018

Copy link
Copy Markdown
Contributor

@shortjared Thanks for the PR but not sure if this should be added.

Templates that use this would not be deployable directly through CloudFormation and must require this yaml conversion. A SAM template should be deployable through by using aws cloudformation create-change-set and aws cloudformation execute-change-set, which this will break. I do not think we should deviate from this right now, as it is not clear why one would pass or fail other than using this tool over that.

The example you provided looks reasonable but we already provide a Globals section in SAM for this reason. They look like they are solving the same problem and would encourage the use of Globals for this instead.

@timoschilling

Copy link
Copy Markdown
Contributor

@jfuss I see your point but @shortjared has opened the same PR on aws/aws-cli#3462. His example is solvable with globals but there are even use cases which are not.
For example I have a CF Distribution with many Behaviors which are have mostly all the same setting.

@jfuss

jfuss commented Aug 13, 2018

Copy link
Copy Markdown
Contributor

@timoschilling Yes the same PR is opened there but my point still holds true. These templates are now not deployable through regular CloudFormation commands. To this point, templates can be used either way and this to SAM and the AWS CLI cloudformation package and cloudformation deploy commands adds a confusing layer to the already confusing abstraction.

My view is not to accept this change until we work on getting our own package and deploy commands (not shell out to the aws cli).

@jfuss

jfuss commented Sep 27, 2018

Copy link
Copy Markdown
Contributor

After discussing with the team, we will not be accepting this change in. The requirement we have is that a template with the Transform of AWS::Serverless-2016-10-31 needs to be deployable through CloudFormation. This change will break that requirement.

We do hear the community on the need for this in general. Adding this directly to the Serverless Application Model or using AWS CloudFormation Macros might provide a better generic solution for this.

@shortjared

Copy link
Copy Markdown
Contributor Author

So it looks like AWS CLI has merged YAML anchor unrolling to the CLI in the develop branch. It would be good to make sure that sam cli reflects a similar change. aws/aws-cli#3827

@cscetbon

cscetbon commented Aug 22, 2023 •

Copy link
Copy Markdown

@shortjared I don't think it's working correctly. We had many issues with anchors. Also it doesn't seem it's supported in samconfig.yaml 😕

hawflau pushed a commit to hawflau/aws-sam-cli that referenced this pull request Nov 14, 2023
github-merge-queue Bot pushed a commit that referenced this pull request Nov 16, 2023
* feat: Add java21 runtime support (#553)

* Add java21 runtime

* Add test_data for java21 and update gh action to use java21

* Update tests/integration/testdata/buildcmd/Java/gradlew/21/gradle/wrapper/gradle-wrapper.properties

Co-authored-by: Wing Fung Lau <[email protected]>

* Update tests/integration/testdata/buildcmd/Java/maven/21/pom.xml

Co-authored-by: Wing Fung Lau <[email protected]>

* Update tests/integration/testdata/buildcmd/Java/maven/21/pom.xml

Co-authored-by: Wing Fung Lau <[email protected]>

---------

Co-authored-by: Wing Fung Lau <[email protected]>

* Revert "feat: Add java21 runtime support (#553)" (#558)

This reverts commit 10f670e.

* Sam cli java21 runtime (#559)

* Add java21 runtime

* Add test_data for java21 and update gh action to use java21

* Update tests/integration/testdata/buildcmd/Java/gradlew/21/gradle/wrapper/gradle-wrapper.properties

Co-authored-by: Wing Fung Lau <[email protected]>

* Update tests/integration/testdata/buildcmd/Java/maven/21/pom.xml

Co-authored-by: Wing Fung Lau <[email protected]>

* Update tests/integration/testdata/buildcmd/Java/maven/21/pom.xml

Co-authored-by: Wing Fung Lau <[email protected]>

* attempt to fix gradle build test failure

* attempt to fix gradle build test failure

* upgrade gradle wrapper

* upgrading gradle wrapper

---------

Co-authored-by: Haresh Nasit <[email protected]>
Co-authored-by: Haresh Nasit <[email protected]>

* fix: fix the runtime to schema code binding mapping (#566)

* update build.yml to setup multiple java versions

* Update build.yml

* revert java8 gradlew testdata

* revert java8 gradlew testdata

* Revert "revert java8 gradlew testdata"

This reverts commit a9337db.

* Revert "revert java8 gradlew testdata"

This reverts commit def09bd.

* setup multiple versions of jdk

---------

Co-authored-by: Haresh Nasit <[email protected]>
Co-authored-by: Haresh Nasit <[email protected]>
Co-authored-by: Mohamed ElAsmar <[email protected]>
Co-authored-by: Mohamed Elasmar <[email protected]>
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 this pull request may close these issues.

4 participants