Step 4: Update your AppSpec file (original) (raw)

In this section, you update your AppSpec file with a Hooks section. In the Hooks section, you specify a Lambda function for theAfterAllowTestTraffic lifecycle hook.

To update your AppSpec file
  1. Open the AppSpec file file you created in Step 2: Create the AppSpec file of the Tutorial: Deploy an application into Amazon ECS.
  2. Update the TaskDefinition property with the task definition ARN you noted in Step 2: Update your Amazon ECS application.
  3. Copy and paste the Hooks section into your AppSpec file file. Update the ARN after AfterAllowTestTraffic with the ARN of the Lambda function that you noted in Step 3: Create a lifecycle hook Lambda function.
    JSON AppSpec
{  
  "version": 0.0,  
  "Resources": [  
    {  
      "TargetService": {  
        "Type": "AWS::ECS::Service",  
        "Properties": {  
          "TaskDefinition": "arn:aws:ecs:aws-region-id:aws-account-id::task-definition/ecs-demo-task-definition:revision-number",  
          "LoadBalancerInfo": {  
            "ContainerName": "sample-website",  
            "ContainerPort": 80  
          }  
        }  
      }  
    }  
  ],  
  "Hooks": [  
    {  
      "AfterAllowTestTraffic": "arn:aws:lambda:aws-region-id:aws-account-id:function:AfterAllowTestTraffic"  
    }  
  ]  
}  

YAML AppSpec

version: 0.0  
Resources:  
  - TargetService:  
      Type: AWS::ECS::Service  
      Properties:  
        TaskDefinition: "arn:aws:ecs:aws-region-id:aws-account-id::task-definition/ecs-demo-task-definition:revision-number"  
        LoadBalancerInfo:  
          ContainerName: "sample-website"  
          ContainerPort: 80  
Hooks:  
  - AfterAllowTestTraffic: "arn:aws:lambda:aws-region-id:aws-account-id:function:AfterAllowTestTraffic"  
  1. Save your AppSpec file and upload to its S3 bucket.

Step 3: Create a lifecycle hook Lambda function

Step 5: Use the CodeDeploy console to deploy your Amazon ECS service

Did this page help you? - Yes

Thanks for letting us know we're doing a good job!

If you've got a moment, please tell us what we did right so we can do more of it.

Did this page help you? - No

Thanks for letting us know this page needs work. We're sorry we let you down.

If you've got a moment, please tell us how we can make the documentation better.