Skip to content

Use naive yaml for parameters and tags in github actions! #151

@egut

Description

@egut

Its very confusing to use a mixed format when deploying cloudformations. I do understand that node is JSON and it totally make scens in other places to use JSON but GitHub Action are normally YAML and not JSON. Along that you also support some kind of string inline format.

I don't mind that you keep these formats for backwards compatibility. (Consider removing them though)

The issues

An example:

      - name: 'Deploy Cloudformation'
        uses: 'aws-actions/aws-cloudformation-github-deploy@v1'
        with:
          name: 'myCloudformation'
          template: './cloudformation/myApplication.yml'
          no-fail-on-empty-changeset: '1'
          parameter-overrides: >-
            AppParameter1=${{ env.APPLICATION_ARN }},
            ApplicationName=${{ env.APPLICATION_NAME }},
            VPC=vpcid_example
          tags: >-
            [
              {
              "Key"="Application",
              "Value"="myapp"},
              {
              "Key"="Owner",
              "Value"="egut"}
            ]
  • Using three different formats for configuration of the stacks.
  • The tag section is a bit of a guess as it do not work but seams to be the format from the documentation.

Solution

      - name: 'Deploy Cloudformation'
        uses: 'aws-actions/aws-cloudformation-github-deploy@v2'
        with:
          name: 'myCloudformation'
          template: './cloudformation/myApplication.yml'
          no-fail-on-empty-changeset: '1'
          parameter-overrides:
            - AppParameter1: '${{ env.APPLICATION_ARN }}'
            - ApplicationName: '${{ env.APPLICATION_NAME }}'
            - VPC: 'vpcid_example'
          tags: 
             - Key: 'Application'
               Value: 'myapp'
             - Key: 'Owner'
               Value: 'egut'

or even better:

      - name: 'Deploy Cloudformation'
        uses: 'aws-actions/aws-cloudformation-github-deploy@v2'
        with:
          name: 'myCloudformation'
          template: './cloudformation/myApplication.yml'
          no-fail-on-empty-changeset: true
          parameter-overrides:
            - AppParameter1: '${{ env.APPLICATION_ARN }}'
            - ApplicationName: '${{ env.APPLICATION_NAME }}'
            - VPC: 'vpcid_example'
          tags: 
             - Application: 'myapp'
             - Owner: 'egut'    

The improvements

  • First and foe most all parameters are in YAML and therefor Yamlint and other tools can easily identify issues.
  • The code is mush easier to read and it writing it becomes more obverse.
  • Parameters of String, CommaDelimitedString, Number and other are also easily handled on both the user side and implementation side.
  • In the second example the no-fail-on-empty-changeset is set to a boolean. Its supported in JSON too, but I haven't looked up the AWS_SDK for Node to verify it its realy need to be '1' or if boolean are allowed. Yes again, its easier to understand and easy to handle in code in the action.
  • Implementation: In the first example you should more or less be able to to a yaml2json and push it directly to CreateStackCommand. But!
  • Implementation: As you might want to be backwards compatible you should be able to check if the input is a string then use your current way, if its a list convert in a standard way to match whatever the API requires.
  • Time: gestimate 1 h together with Amazon Q

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions