简体   繁体   中英

aws ecs run ecs task with container overrides

Looking for help on a java app to run ECS scheduled task. the program works fine and invokes the task without the overrides. when we pass overrides it gives an error? is there some issue?

   ListTaskDefinitionFamiliesRequest request = new ListTaskDefinitionFamiliesRequest();
        ListTaskDefinitionFamiliesResult response = client.listTaskDefinitionFamilies(request);
        List<String> ls = response.getFamilies();
            String cmd[] ={"arg1","arg2"};
            List<String> command = Arrays.asList(cmd);
            TaskOverride overrides = new TaskOverride();
            ContainerOverride containerOverrides = new ContainerOverride();
            containerOverrides.setCommand(command);
            overrides.withContainerOverrides(containerOverrides);
            String subnets[] ={"subnet-bbb","subnet-ccc"};
            List<String> subnetList = Arrays.asList(subnets);
            String securityGrp[] ={"sg-xxx"};
            List<String> securityGrpList = Arrays.asList(securityGrp    );
            AwsVpcConfiguration awsvpcConfiguration = new AwsVpcConfiguration();
            awsvpcConfiguration.setSubnets(subnetList);
            awsvpcConfiguration.setSecurityGroups(securityGrpList);
            NetworkConfiguration networkConfiguration = new NetworkConfiguration();
            networkConfiguration.setAwsvpcConfiguration(awsvpcConfiguration);
        RunTaskRequest request = new RunTaskRequest()
                .withCluster("cluster-ecs")
                .withTaskDefinition("task:1")
                .withCount(1)
                .withLaunchType("FARGATE")              
                .withNetworkConfiguration(networkConfiguration);
                .withOverrides(overrides);
        RunTaskResult response = client.runTask(request);   

container name is required field in overrides. all set now.

            containerOverrides.setName("blabla");
        containerOverrides.setCommand(command);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM