// // Function to print the details of a service's task definition, since it's got a lot of fiddly details. // func PrintTaskDefinition(awsConn *ecs.ECS, taskDefinition *string, verboseFlag bool) { // Fetch the details of the task definition. taskDef, err := awsConn.DescribeTaskDefinition(&ecs.DescribeTaskDefinitionInput{ TaskDefinition: taskDefinition, }) CheckError(fmt.Sprintf("fetching Task Definition for %s", *taskDefinition), err) fmt.Println(" - Task Definition:", *taskDefinition) fmt.Println(" - Family:", *taskDef.TaskDefinition.Family) for _, containerDef := range taskDef.TaskDefinition.ContainerDefinitions { fmt.Println(" - Container Definition:") fmt.Println(" - Image:", *containerDef.Image) if verboseFlag { fmt.Println(" - CPU:", *containerDef.Cpu) fmt.Println(" - Memory:", *containerDef.Memory) } for _, portMap := range containerDef.PortMappings { fmt.Println(" - Container Port", *portMap.ContainerPort, ": Host Port", *portMap.HostPort) } if len(containerDef.Command) > 0 { fmt.Printf(" - Command: %v\n", containerDef.Command) } if len(containerDef.EntryPoint) > 0 { fmt.Printf(" - Entry Point: %v\n", containerDef.EntryPoint) } if (len(containerDef.Environment) > 0) && (verboseFlag) { fmt.Println(" - Environment:") for _, envVariable := range containerDef.Environment { fmt.Println(" ", *envVariable.Name, "=", *envVariable.Value) } } } }
// setImage // Create a new Task Definition based on an existing // ARN, and a new image. // // Returns new task's ARN // func setImage(svc *ecs.ECS, taskArn string, image string) (string, error) { params := &ecs.DescribeTaskDefinitionInput{TaskDefinition: aws.String(taskArn)} resp, err := svc.DescribeTaskDefinition(params) if err != nil { return "", err } task := resp.TaskDefinition task.ContainerDefinitions[0].Image = &image regResp, err := svc.RegisterTaskDefinition(&ecs.RegisterTaskDefinitionInput{ Family: task.Family, ContainerDefinitions: task.ContainerDefinitions, Volumes: task.Volumes, }) return *regResp.TaskDefinition.TaskDefinitionArn, nil }