aws-cloudformation-github-deploy icon indicating copy to clipboard operation
aws-cloudformation-github-deploy copied to clipboard

ParameterOverrides with commas in them fail

Open damian-bisignano opened this issue 3 years ago • 10 comments

I've got a parameter that is a comma separated list. this doesn't work it instead splits on this value, expecting it to be another Key-Value pair

i've tried with all sorts of combinations of " and ' around the parameters and couldn't get it working.

env:
  SECURITY_GROUP_ID: sg-11111111
  SUBNET_ID: subnet-11111111,subnet-22222222

      - name: Deploy to AWS CloudFormation
        id: cloudformation
        uses: aws-actions/aws-cloudformation-github-deploy@v1
        with:
          name: MyStack
          template: ./infrastructure.json
          parameter-overrides: >-
            SecurityGroupId=${{ env.SECURITY_GROUP_ID }},
            SubnetId=${{ env.SUBNET_ID }}

the error i get is

Error: Invalid input for parameter key subnet-22222222". Need to specify either usePreviousValue as true or a value for the parameter

I imagine the update just needs to be update src/utils.ts line 52 to update to a regex that ignores if you have an escape character before the comma

Alternatively. update to use newline character for seperating. you won't have a newline character in your parameters from what i can think of in my use cases

damian-bisignano avatar Nov 19 '20 05:11 damian-bisignano

  • name: AWS CloudFormation "Deploy CloudFormation Stack" Action for GitHub Actions uses: aws-actions/[email protected]

Masumpatwary121 avatar Dec 09 '20 18:12 Masumpatwary121

I can confirm that this is an issue. It doesn't even honor quotes around the comma delimited list. Working on a fix. Will submit a pull request soon.

timharris777 avatar Jan 13 '21 17:01 timharris777

Hi @damian-bisignano , were you able to find a solution?

dror-weiss avatar Nov 24 '22 14:11 dror-weiss

Argh, this is a killer, any movement toward a fix here?

matthewmrichter avatar Feb 01 '23 21:02 matthewmrichter

@matthewmrichter , multi-value key is supported by using the very intuitive syntax:

parameter-overrides: >-
    SubnetId=subnet-11111111,
    SubnetId=subnet-22222222

dror-weiss avatar Feb 02 '23 08:02 dror-weiss

@dror-weiss This issue is talking about individual parameters that have commas within them:

parameter-overrides: >-
    SubnetIdList=subnet-11111111,subnet-22222222,subnet-333333,
    VPCId=vpc-abcdefg1234

There seems to be no syntax, very intuitive or not, to accomplish that

matthewmrichter avatar Feb 02 '23 13:02 matthewmrichter

@matthewmrichter As per: https://github.com/aws-actions/aws-cloudformation-github-deploy/blob/780e9430141a26b3bee5e0fa36aa3aa227a12ffd/tests/utils.test.ts#L70

Specifying multiple duplicate "ParameterKey" will concatenate them in one with comma separated ParameterValues.

So:

parameter-overrides: >-
    SubnetIdList=subnet-11111111,
    SubnetIdList=subnet-22222222,
    SubnetIdList=subnet-333333,
    VPCId=vpc-abcdefg1234

Will be passed to Cloudformation as

      {
        ParameterKey: 'SubnetIdList',
        ParameterValue: 'subnet-11111111,subnet-22222222,subnet-333333'
      },
      {
        ParameterKey: 'VPCId',
        ParameterValue: 'vpc-abcdefg1234'
      }

Thank you @dror-weiss for noticing this.

DimDroll avatar Feb 03 '23 19:02 DimDroll

Confirming that the issue still exists.

Specifying multiple duplicate keys is not necessarily feasible in all scenarios. I may not always know how many subnets I have in the action and that also limits me creating a generic action that can handle multiple subnets - could be 2/3/4. I can't get it to work w/o writing convoluted code in my action to generate the proper syntax and inject it into the call.

Handling commas in the value field is really a missing feature here.

monemihir avatar Feb 15 '23 02:02 monemihir

This is still an issue. Situations where the parameter contains a comma but is not an array cannot be addressed by the "duplicate parameter" workaround. For example a parameter with the value of a cronjob string - is not passable at the moment if it has a comma in it. Has anyone discovered out a workaround?

paulvav avatar Mar 02 '23 03:03 paulvav

@paulvav can you look at release v1.2.0 there is a fix in there for handling this. You should now be able to do

parameter-overrides: >-
    SubnetIdList="subnet-11111111,subnet-22222222,subnet-333333",
    VPCId=vpc-abcdefg1234

I'm also updating documentation in the README

kddejong avatar Mar 03 '23 19:03 kddejong