Example usage for com.amazonaws.services.ecs.model Service getRoleArn

List of usage examples for com.amazonaws.services.ecs.model Service getRoleArn

Introduction

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

Prototype


public String getRoleArn() 

Source Link

Document

The ARN of the IAM role associated with the service that allows the Amazon ECS container agent to register container instances with an Elastic Load Balancing load balancer.

Usage

From source file:com.netflix.spinnaker.clouddriver.ecs.deploy.ops.ResizeServiceAtomicOperation.java

License:Apache License

private void resizeAutoScalingGroup(Service service) {
    AWSApplicationAutoScaling autoScalingClient = getAmazonApplicationAutoScalingClient();

    Integer desiredCount = description.getCapacity().getDesired();
    String ecsClusterName = containerInformationService.getClusterName(service.getServiceName(),
            description.getAccount(), description.getRegion());

    RegisterScalableTargetRequest request = new RegisterScalableTargetRequest()
            .withServiceNamespace(ServiceNamespace.Ecs)
            .withScalableDimension(ScalableDimension.EcsServiceDesiredCount)
            .withResourceId(String.format("service/%s/%s", ecsClusterName, service.getServiceName()))
            .withRoleARN(service.getRoleArn()).withMinCapacity(description.getCapacity().getMin())
            .withMaxCapacity(description.getCapacity().getMax());

    updateTaskStatus(String.format("Resizing Scalable Target of %s to %s instances", service.getServiceName(),
            desiredCount));//from   w w  w  .  j  a  v a 2s .  com
    autoScalingClient.registerScalableTarget(request);
    updateTaskStatus(String.format("Done resizing Scalable Target of %s to %s instances",
            service.getServiceName(), desiredCount));
}

From source file:com.netflix.spinnaker.clouddriver.ecs.provider.agent.ServiceCachingAgent.java

License:Apache License

public static Map<String, Object> convertServiceToAttributes(String accountName, String region,
        Service service) {
    Map<String, Object> attributes = new HashMap<>();
    String applicationName = service.getServiceName().contains("-")
            ? StringUtils.substringBefore(service.getServiceName(), "-")
            : service.getServiceName();/*  ww w  .j  a  v  a  2  s.  co m*/
    String clusterName = StringUtils.substringAfterLast(service.getClusterArn(), "/");

    attributes.put("account", accountName);
    attributes.put("region", region);
    attributes.put("applicationName", applicationName);
    attributes.put("serviceName", service.getServiceName());
    attributes.put("serviceArn", service.getServiceArn());
    attributes.put("clusterName", clusterName);
    attributes.put("clusterArn", service.getClusterArn());
    attributes.put("roleArn", service.getRoleArn());
    attributes.put("taskDefinition", service.getTaskDefinition());
    attributes.put("desiredCount", service.getDesiredCount());
    attributes.put("maximumPercent", service.getDeploymentConfiguration().getMaximumPercent());
    attributes.put("minimumHealthyPercent", service.getDeploymentConfiguration().getMinimumHealthyPercent());
    attributes.put("loadBalancers", service.getLoadBalancers());
    attributes.put("createdAt", service.getCreatedAt().getTime());

    return attributes;
}