Error updating AWS Lambda Configuration in pipeline

Hi All

We’re receiving an error when trying to update the configuration of an AWS Lambda function.

The yaml config looks like this

version: 2.1

orbs:
  aws-cli: circleci/aws-cli@1.3.0
  aws-s3: circleci/aws-s3@2.0.0
  win: circleci/windows@2.2.0

jobs:
  build_and_package:
	executor: win/default
...
  upload_package:
	resource_class: small
	executor: aws-cli/default     
...
  publish_test:
	resource_class: small
	executor: aws-cli/default     
...
	  - run:
		  name: update_test_config
		  command: |
			NEW_REVISION_ID=$(aws lambda update-function-configuration \
			  --function-name << parameters.function_name >> \
			  --vpc-config SubnetIds=<< parameters.test_subnets >>,SecurityGroupIds=<< parameters.test_sec_groups >> \
			  --environment Variables={variable1=value1,variable2=value2,variable3=value3,variable4=value4,variable5=value5,variable6=value6,variable7=value7} \
			  --revision-id $REVISION_ID \
			  --output text \
			  --query '[RevisionId]')

The error output we’re seeing is,

#!/bin/bash -eo pipefail
aws lambda update-function-configuration \
  --function-name MyFunction \
  --vpc-config SubnetIds=subnet-1,subnet-2,SecurityGroupIds=sg-1,sg-2 \
  --environment Variables={variable1=value1,variable2=value2,variable3=value3,variable4=value4,variable5=value5,variable6=value6,variable7=value7} \
  --revision-id $REVISION_ID

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

Unknown options: Variables=variable2=value2, variable3=value3, variable4=value4, variable5=value5, variable6=value6, variable7=value7


Exited with code exit status 252
CircleCI received exit code 252

We’ve shuffled the variable order around, but it only seems to accept the first one, then lists the others as Unknown options.

This is the AWS CLI documentation for updating the Lambda configuration
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lambda/update-function-configuration.html

Hope someone is able to provide an insight as to what’s needed.

Cheers
Phil

Hi All

Just closing this off as resolved. We ended up putting the variables in JSON format as per below

--environment '{ "Variables": {"variable1": "value1","variable2": "value2","variable3": "value3","variable4": "value4","variable5": "value5","variable6": "value6","variable7": "value7"}}' \

Cheers
Phil

Thank you for updating, @phil.carter! Providing a solution for future folks is awesome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.