Step 2: Create the AppSpec file - Amazon CodeDeploy
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Step 2: Create the AppSpec file

In this section, you create your AppSpec file and upload it to the Amazon S3 bucket you created in the Prerequisites section. The AppSpec file for an Amazon ECS deployment specifies your task definition, container name, and container port. For more information, see AppSpec File example for an Amazon ECS deployment and AppSpec 'resources' section for Amazon ECS deployments.

To create your AppSpec file
  1. If you want to create your AppSpec file using YAML, create a file named appspec.yml. If you want to create your AppSpec file using JSON, create a file named appspec.json.

  2. Choose the appropriate tab, depending on if you use YAML or JSON for your AppSpec file, and copy its content into the AppSpec file you just created. For the TaskDefinition property, use the task definition ARN you noted in Step 1: Update your Amazon ECS application section.

    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": "your-container-name", "ContainerPort": your-container-port } } } } ] }
    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: "your-container-name" ContainerPort: your-container-port
    Note

    Your replacement task set inherits the subnet, security group, platform version, and assigned public IP values from your original task set. You can override these values for your replacement task set by setting their optional properties in your AppSpec file. For more information, see AppSpec 'resources' section for Amazon ECS deployments and AppSpec File example for an Amazon ECS deployment .

  3. Upload your AppSpec file to the S3 bucket you created as a prerequisite for this tutorial.