public IamInstanceProfileSpecification toIamInstanceProfileSpecification() { final IamInstanceProfileSpecification spec = new IamInstanceProfileSpecification(); spec.setName(name); spec.setArn(arn); return spec; }
req.setIamInstanceProfile(new IamInstanceProfileSpecification().withArn(config.getProperty("worker-iam-role")));
public IamInstanceProfileSpecification unmarshall(StaxUnmarshallerContext context) throws Exception { IamInstanceProfileSpecification iamInstanceProfileSpecification = new IamInstanceProfileSpecification(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return iamInstanceProfileSpecification; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("arn", targetDepth)) { iamInstanceProfileSpecification.setArn(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("name", targetDepth)) { iamInstanceProfileSpecification.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return iamInstanceProfileSpecification; } } } }
public IamInstanceProfileSpecification unmarshall(StaxUnmarshallerContext context) throws Exception { IamInstanceProfileSpecification iamInstanceProfileSpecification = new IamInstanceProfileSpecification(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) return iamInstanceProfileSpecification; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("arn", targetDepth)) { iamInstanceProfileSpecification.setArn(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("name", targetDepth)) { iamInstanceProfileSpecification.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { return iamInstanceProfileSpecification; } } } }
public IamInstanceProfileSpecification toIamInstanceProfileSpecification() { final IamInstanceProfileSpecification spec = new IamInstanceProfileSpecification(); spec.setName(name); spec.setArn(arn); return spec; }
public IamInstanceProfileSpecification toIamInstanceProfileSpecification() { final IamInstanceProfileSpecification spec = new IamInstanceProfileSpecification(); spec.setName(name); spec.setArn(arn); return spec; }
.withInstanceType(instanceType) .withSubnetId(subnetId) .withIamInstanceProfile(new IamInstanceProfileSpecification().withName(iamInstanceProfileName)); if (Strings.isNullOrEmpty(this.userData) == false) { request.setUserData(new String(Base64.getEncoder()
public IamInstanceProfileSpecification unmarshall(StaxUnmarshallerContext context) throws Exception { IamInstanceProfileSpecification iamInstanceProfileSpecification = new IamInstanceProfileSpecification(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return iamInstanceProfileSpecification; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("arn", targetDepth)) { iamInstanceProfileSpecification.setArn(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("name", targetDepth)) { iamInstanceProfileSpecification.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return iamInstanceProfileSpecification; } } } }
launchSpecification.setIamInstanceProfile(new IamInstanceProfileSpecification().withArn(getIamInstanceProfile()));
riRequest.setIamInstanceProfile(new IamInstanceProfileSpecification().withArn(getIamInstanceProfile()));
launchSpecification.setIamInstanceProfile(new IamInstanceProfileSpecification().withArn(getIamInstanceProfile()));
@Override public List<SpotInstanceRequest> call() { LaunchSpecification spec = new LaunchSpecification(); spec.withInstanceType(this.instanceTemplate.getInstanceType()); spec.withImageId(this.instanceTemplate.getAmiId()); InstanceNetworkInterfaceSpecification nic = new InstanceNetworkInterfaceSpecification(); nic.withDeviceIndex(0); // select a subnet at random nic.withSubnetId(randomSubnet()); nic.withAssociatePublicIpAddress(this.instanceTemplate.isAssignPublicIp()); nic.withGroups(this.instanceTemplate.getSecurityGroupIds()); spec.withNetworkInterfaces(nic); spec.withKeyName(this.instanceTemplate.getKeyPair()); spec.withIamInstanceProfile( new IamInstanceProfileSpecification().withArn(this.instanceTemplate.getIamInstanceProfileARN())); spec.withUserData(this.instanceTemplate.getEncodedUserData()); spec.withEbsOptimized(this.instanceTemplate.isEbsOptimized()); RequestSpotInstancesRequest spotRequest = new RequestSpotInstancesRequest().withInstanceCount(this.count) .withType(SpotInstanceType.Persistent).withSpotPrice(this.bidPrice).withLaunchSpecification(spec); RequestSpotInstancesResult result = getClient().getApi().requestSpotInstances(spotRequest); List<String> spotRequestIds = result.getSpotInstanceRequests().stream() .map(SpotInstanceRequest::getSpotInstanceRequestId).collect(Collectors.toList()); if (!this.instanceTemplate.getTags().isEmpty()) { tagRequests(spotRequestIds); } return awaitSpotRequests(spotRequestIds); }
/** * Retrieves an IAM profile spec for a given IAM role. Note that the role * needs to already exist. The IAM profile is created if it does not already exist. * * @param iamRole name of the IAM role to be retrieved in profile form * @return IAM instance profile or null if iamRole is null */ private IamInstanceProfileSpecification getIamProfileSpec(String iamRole) { if(null != iamRole) { InstanceProfile instanceProfile; try { GetInstanceProfileResult getProfileResult = iamClient.getInstanceProfile(new GetInstanceProfileRequest() .withInstanceProfileName(iamRole)); instanceProfile = getProfileResult.getInstanceProfile(); } catch (NoSuchEntityException e) { // No existing entity, create one CreateInstanceProfileResult createProfileResult = iamClient.createInstanceProfile(new CreateInstanceProfileRequest() .withInstanceProfileName( iamRole)); instanceProfile = createProfileResult.getInstanceProfile(); } if (null != instanceProfile) { return new IamInstanceProfileSpecification() .withName(instanceProfile.getInstanceProfileName()); } } return null; }
@Override public List<Instance> call() { RunInstancesRequest request = new RunInstancesRequest(); request.withInstanceType(this.instanceTemplate.getInstanceType()); request.withImageId(this.instanceTemplate.getAmiId()); InstanceNetworkInterfaceSpecification nic = new InstanceNetworkInterfaceSpecification(); nic.withDeviceIndex(0); // select a subnet at random nic.withSubnetId(randomSubnet()); nic.withAssociatePublicIpAddress(this.instanceTemplate.isAssignPublicIp()); nic.withGroups(this.instanceTemplate.getSecurityGroupIds()); request.withNetworkInterfaces(nic); request.withKeyName(this.instanceTemplate.getKeyPair()); request.withIamInstanceProfile( new IamInstanceProfileSpecification().withArn(this.instanceTemplate.getIamInstanceProfileARN())); request.withUserData(this.instanceTemplate.getEncodedUserData()); request.withEbsOptimized(this.instanceTemplate.isEbsOptimized()); request.withMinCount(this.count).withMaxCount(this.count); if (!this.instanceTemplate.getTags().isEmpty()) { TagSpecification tagSpecifications = new TagSpecification().withResourceType(ResourceType.Instance); tagSpecifications.withTags(tags()); request.withTagSpecifications(tagSpecifications); } RunInstancesResult result = getClient().getApi().runInstances(request); List<Instance> launchedInstances = result.getReservation().getInstances(); List<String> instanceIds = launchedInstances.stream().map(Instance::getInstanceId).collect(Collectors.toList()); return awaitInstances(instanceIds); }
riRequest.setIamInstanceProfile(new IamInstanceProfileSpecification().withArn(getIamInstanceProfile()));