Frodo
Frodo

Reputation: 583

AWS: passing parameters to Lambda from code deploy triggers

i have lambda function which creates new launch configuration by passing auto scale group name. it works and i have created code deploy and attached a trigger to execute Lambda function when deployment success. but i get this error

'targetASG': KeyError Traceback (most recent call last): File "/var/task/lambda_function.py", line 12, in lambda_handler ASG = asObj.describe_auto_scaling_groups(AutoScalingGroupNames=[event['targetASG']]) KeyError: 'targetASG'

targetASG is my parameter but i don't see anywhere that i can define that (triggers,SNS). how can i pass this parameter from code deploy?

Upvotes: 0

Views: 770

Answers (2)

Bangxi Yu
Bangxi Yu

Reputation: 191

Unfortunately, today CodeDeploy doesn't support a way for customers to pass the additional metadata/parameters when invoking the hook functions.

As a workaround, you will have to implement the logic in the hook function to pull up the target ASG name in this case.

Upvotes: 0

ThomasVdBerge
ThomasVdBerge

Reputation: 8140

You can define a Lambda endpoint for your SNS and the SNS page.

  1. Sign in to the AWS Management Console and open the Amazon SNS console at https://console.aws.amazon.com/sns/v2/home.

  2. In the left Navigation pane, click Topics, and then click the topic to which you want to subscribe a Lambda endpoint.

  3. Click Actions and then click Subscribe to topic.

  4. In the Protocol drop-down box, select AWS Lambda.

  5. In the Endpoint drop-down box, select the ARN for the Lambda function.

  6. In the Version or Alias drop-down box, select an available version or alias to use. You can also choose $LATEST to specify the latest version of the Lambda function. If you do not want to specify a version or alias, you can also choose default, which is functionally the same as $LATEST. For more information, see AWS Lambda Function Versioning and Aliases.

  7. Click Create subscription.

Upvotes: -1

Related Questions