use of com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement in project aws-java-serverless by hermanlintvelt.
the class SecureParameterService method getParameterValue.
public static String getParameterValue(String name, boolean withDecryption) {
final AWSSimpleSystemsManagement client = AWSSimpleSystemsManagementClientBuilder.defaultClient();
GetParameterRequest request = new GetParameterRequest();
request.withName(name).setWithDecryption(withDecryption);
GetParameterResult result = client.getParameter(request);
LOG.debug("SSM result for param " + name + ": " + result);
if (result.getParameter() != null) {
return result.getParameter().getValue();
} else {
return null;
}
}
use of com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement in project Gatekeeper by FINRAOS.
the class SsmService method executeSsm.
private Map<String, String> executeSsm(AWSEnvironment environment, List<String> instanceIds, String platform, Map<String, ArrayList<String>> parameters, GatekeeperSsmProperties.SsmDocument documentProperties) {
AWSSimpleSystemsManagement ssmClient = awsSessionService.getSsmSession(environment);
SendCommandRequest scr = new SendCommandRequest().withInstanceIds(instanceIds).withDocumentName(documentProperties.getDocumentName());
for (String key : parameters.keySet()) {
scr.addParametersEntry(key, parameters.get(key));
}
return waitForSsmCommand(ssmClient, ssmClient.sendCommand(scr).getCommand().getCommandId(), instanceIds.size(), documentProperties.getTimeout(), documentProperties.getWaitInterval());
}
use of com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement in project Gatekeeper by FINRAOS.
the class SsmService method checkInstancesWithSsm.
public Map<String, String> checkInstancesWithSsm(AWSEnvironment environment, List<String> instanceIds) {
Map<String, String> instanceStatuses = new HashMap<>();
AWSSimpleSystemsManagement ssmClient = awsSessionService.getSsmSession(environment);
for (int i = 0; i < instanceIds.size(); i += 50) {
// since we're partitioning 50 at a time we need to make sure that we don't go over the index of the actual size of the set itself
// if we do then we will use the upper value of the set.
Integer upperBound = i + 50 < instanceIds.size() ? i + 50 : instanceIds.size();
List<String> partitionedList = instanceIds.subList(i, upperBound);
DescribeInstanceInformationRequest describeInstanceInformationRequest = new DescribeInstanceInformationRequest();
InstanceInformationFilter filter = new InstanceInformationFilter();
filter.setKey("InstanceIds");
filter.setValueSet(partitionedList);
List<InstanceInformationFilter> informationFilters = new ArrayList<>();
informationFilters.add(filter);
describeInstanceInformationRequest.setInstanceInformationFilterList(informationFilters);
describeInstanceInformationRequest.setMaxResults(50);
// make the initial call, SSM Chunks it up so we need to call it with tokens til the string returns empty.
DescribeInstanceInformationResult describeInstanceInformationResult = ssmClient.describeInstanceInformation(describeInstanceInformationRequest);
describeInstanceInformationResult.getInstanceInformationList().forEach(instance -> instanceStatuses.put(instance.getInstanceId(), instance.getPingStatus()));
while (describeInstanceInformationResult.getNextToken() != null) {
// get the next chunk of results
describeInstanceInformationResult = ssmClient.describeInstanceInformation(describeInstanceInformationRequest.withNextToken(describeInstanceInformationResult.getNextToken()));
describeInstanceInformationResult.getInstanceInformationList().forEach(instance -> instanceStatuses.put(instance.getInstanceId(), instance.getPingStatus()));
}
}
return instanceStatuses;
}
use of com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement in project spring-cloud-config by spring-cloud.
the class AwsParameterStoreEnvironmentRepositoryFactory method build.
@Override
public AwsParameterStoreEnvironmentRepository build(AwsParameterStoreEnvironmentProperties environmentProperties) {
AWSSimpleSystemsManagementClientBuilder clientBuilder = AWSSimpleSystemsManagementClientBuilder.standard();
configureClientBuilder(clientBuilder, environmentProperties.getRegion(), environmentProperties.getEndpoint());
AWSSimpleSystemsManagement client = clientBuilder.build();
return new AwsParameterStoreEnvironmentRepository(client, configServerProperties, environmentProperties);
}
use of com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement in project aws-doc-sdk-examples by awsdocs.
the class GetSimpleSystemsManagementOps method main.
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Please specify a SSM OpsItem ID value. You can obtain this value using the AWS Console.");
System.exit(1);
}
// snippet-start:[ssm.Java1.get_ops.main]
// Get the OpsItem ID value
String opsID = args[0];
// Create the AWSSimpleSystemsManagement client object
AWSSimpleSystemsManagement ssm = AWSSimpleSystemsManagementClientBuilder.standard().withRegion(Regions.DEFAULT_REGION).build();
try {
GetOpsItemRequest opsRequest = new GetOpsItemRequest();
opsRequest.setOpsItemId(opsID);
GetOpsItemResult opsResults = ssm.getOpsItem(opsRequest);
OpsItem item = opsResults.getOpsItem();
System.out.println(item.getTitle());
System.out.println(item.getDescription());
System.out.println(item.getSource());
} catch (AmazonServiceException e) {
e.getStackTrace();
}
// snippet-end:[ssm.Java1.get_ops.main]
}
Aggregations