CodePipeline step CodeDeploy using ECS blue/green fails at 'Rerouting production traffic to replacement task set'

0

Hi - I am encountering an error when running a CodePipeline that uses CodeDeploy to perform a blue/green deployment to ECS. It fails at step 3 'Rerouting production traffic to replacement task set' with an error 'The deployment failed because the specified Lambda function or alias does not satisfy constraints and cannot be validated. (1 validation error detected: Value ' ' at 'functionName' failed to satisfy constraint: Member must satisfy regular expression pattern: (arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-.]+)(:($LATEST|[a-zA-Z0-9-]+))?)'

This error seems odd because as I understand it this is a lifecycle event 'AfterAllowTestTraffic' that is within CodeDeploy when using the action 'Amazon ECS (blue/green)' that I am not in control of.

What am I missing?

asked 2 months ago96 views
1 Answer
1
Accepted Answer

The error you're encountering suggests that there's an issue with a Lambda function specified in your CodeDeploy configuration, specifically in the AppSpec file. This error typically occurs when a Lambda function is specified in the AppSpec file's Hooks section, but the function name or ARN is not correctly formatted or is empty.

For CodeDeploy blue/green deployments with ECS, you can specify Lambda functions to run at various lifecycle hooks, including the 'AfterAllowTestTraffic' hook. These functions are used for deployment validation and can control whether the deployment proceeds or rolls back.

To resolve this issue:

  1. Check your AppSpec file: Look for the 'Hooks' section and specifically the 'AfterAllowTestTraffic' hook. Ensure that the Lambda function specified here is correctly named and formatted.

  2. Verify Lambda function: Make sure the Lambda function you're referencing actually exists in your AWS account and is in the same region as your ECS deployment.

  3. Use proper ARN format: If you're using the Lambda function's ARN, make sure it follows the correct format: arn:aws:lambda:region:account-id:function:function-name

  4. Permissions: Ensure that CodeDeploy has the necessary permissions to invoke the Lambda function. The CodeDeploy service role should have the 'lambda:InvokeFunction' permission for the specified Lambda function.

  5. Remove if not needed: If you don't actually need a validation function at this stage, you can remove the 'AfterAllowTestTraffic' hook from your AppSpec file.

  6. Check for typos: Ensure there are no typographical errors in the function name or ARN.

If you've verified all of these and the issue persists, you may want to review the full deployment logs in CodeDeploy or CloudWatch for more detailed error messages that could provide additional insight into the problem.
Sources
Troubleshoot Amazon ECS deployment issues - AWS CodeDeploy
Tutorial: Deploy an application into Amazon ECS - AWS CodeDeploy
Listener requirements for CodeDeploy Blue/Green Deployments | AWS re:Post

profile picture
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
  • This was a very useful answer from AI, my AppSpec file was from a template and had an empty 'Hooks:' '- AfterAllowTestTraffic: " "' section...

    Leaving this here in case it is useful to others

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions