Example usage for com.amazonaws.services.ecs.model ContainerDefinition getPortMappings

List of usage examples for com.amazonaws.services.ecs.model ContainerDefinition getPortMappings

Introduction

In this page you can find the example usage for com.amazonaws.services.ecs.model ContainerDefinition getPortMappings.

Prototype


public java.util.List<PortMapping> getPortMappings() 

Source Link

Document

The list of port mappings for the container.

Usage

From source file:com.netflix.spinnaker.clouddriver.ecs.provider.view.EcsServerClusterProvider.java

License:Apache License

private TaskDefinition buildTaskDefinition(com.amazonaws.services.ecs.model.TaskDefinition taskDefinition) {
    String roleArn = taskDefinition.getTaskRoleArn();
    String iamRole = roleArn != null ? StringUtils.substringAfterLast(roleArn, "/") : "None";
    ContainerDefinition containerDefinition = taskDefinition.getContainerDefinitions().get(0);

    return new TaskDefinition().setContainerImage(containerDefinition.getImage())
            .setContainerPort(containerDefinition.getPortMappings().get(0).getContainerPort())
            .setCpuUnits(containerDefinition.getCpu())
            .setMemoryReservation(containerDefinition.getMemoryReservation()).setIamRole(iamRole)
            .setTaskName(StringUtils.substringAfterLast(taskDefinition.getTaskDefinitionArn(), "/"))
            .setEnvironmentVariables(containerDefinition.getEnvironment());
}