com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClientBuilder Java Examples
The following examples show how to use
com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClientBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EC2InventoryUtilTest.java From pacbot with Apache License 2.0 | 6 votes |
/** * Fetch SSM info test. * * @throws Exception the exception */ @SuppressWarnings("static-access") @Test public void fetchSSMInfoTest() throws Exception { mockStatic(AWSSimpleSystemsManagementClientBuilder.class); AWSSimpleSystemsManagement ssmClient = PowerMockito.mock(AWSSimpleSystemsManagement.class); AWSSimpleSystemsManagementClientBuilder simpleSystemsManagementClientBuilder = PowerMockito.mock(AWSSimpleSystemsManagementClientBuilder.class); AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class); PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider); when(simpleSystemsManagementClientBuilder.standard()).thenReturn(simpleSystemsManagementClientBuilder); when(simpleSystemsManagementClientBuilder.withCredentials(anyObject())).thenReturn(simpleSystemsManagementClientBuilder); when(simpleSystemsManagementClientBuilder.withRegion(anyString())).thenReturn(simpleSystemsManagementClientBuilder); when(simpleSystemsManagementClientBuilder.build()).thenReturn(ssmClient); DescribeInstanceInformationResult describeInstanceInfoRslt = new DescribeInstanceInformationResult(); List<InstanceInformation> ssmInstanceListTemp = new ArrayList<>(); ssmInstanceListTemp.add(new InstanceInformation()); describeInstanceInfoRslt.setInstanceInformationList(ssmInstanceListTemp); when(ssmClient.describeInstanceInformation(anyObject())).thenReturn(describeInstanceInfoRslt); assertThat(ec2InventoryUtil.fetchSSMInfo(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "skipRegions", "account","accountName").size(), is(1)); }
Example #2
Source File: SsmUtil.java From herd-mdl with Apache License 2.0 | 6 votes |
private static Parameter getParameter(String parameterKey, boolean isEncrypted) { LOGGER.info("get ssm parameter key:" + parameterKey); AWSCredentialsProvider credentials = InstanceProfileCredentialsProvider.getInstance(); AWSSimpleSystemsManagement simpleSystemsManagementClient = AWSSimpleSystemsManagementClientBuilder.standard().withCredentials(credentials) .withRegion(Regions.getCurrentRegion().getName()).build(); GetParameterRequest parameterRequest = new GetParameterRequest(); parameterRequest.withName(parameterKey).setWithDecryption(isEncrypted); GetParameterResult parameterResult = simpleSystemsManagementClient.getParameter(parameterRequest); return parameterResult.getParameter(); }
Example #3
Source File: AmazonAsyncDockerClientsHolder.java From spring-localstack with Apache License 2.0 | 5 votes |
@Override public AWSSimpleSystemsManagement awsSimpleSystemsManagement() { return decorateWithConfigsAndBuild( AWSSimpleSystemsManagementClientBuilder.standard(), LocalstackDocker::getEndpointSSM ); }
Example #4
Source File: AwsParamStoreBootstrapConfiguration.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean AWSSimpleSystemsManagement ssmClient( AwsParamStoreProperties awsParamStoreProperties) { return StringUtils.isNullOrEmpty(awsParamStoreProperties.getRegion()) ? AWSSimpleSystemsManagementClientBuilder.defaultClient() : AWSSimpleSystemsManagementClientBuilder.standard() .withRegion(awsParamStoreProperties.getRegion()).build(); }
Example #5
Source File: GetSimpleSystemsManagementParas.java From aws-doc-sdk-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) { // snippet-start:[ssm.Java1.get_params.main] AWSSimpleSystemsManagement ssm = AWSSimpleSystemsManagementClientBuilder.standard().withRegion(Regions.DEFAULT_REGION).build(); try { DescribeParametersRequest desRequest = new DescribeParametersRequest(); desRequest.setMaxResults(10); DescribeParametersResult results = ssm.describeParameters(desRequest); List<ParameterMetadata> params = results.getParameters(); //Iterate through the list Iterator<ParameterMetadata> tagIterator = params.iterator(); while(tagIterator.hasNext()) { ParameterMetadata paraMeta = (ParameterMetadata)tagIterator.next(); System.out.println(paraMeta.getName()); System.out.println(paraMeta.getDescription()); } } catch (AmazonServiceException e) { e.getStackTrace(); } // snippet-end:[ssm.Java1.get_params.main] }
Example #6
Source File: GetSimpleSystemsManagementOps.java From aws-doc-sdk-examples with Apache License 2.0 | 5 votes |
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] }
Example #7
Source File: AwsSessionFactory.java From Gatekeeper with Apache License 2.0 | 5 votes |
public AWSSimpleSystemsManagement createSsmSession(BasicSessionCredentials basicSessionCredentials, String region){ return AWSSimpleSystemsManagementClientBuilder .standard() .withRegion(Regions.fromName(region)) .withCredentials(setCredentials(basicSessionCredentials)) .build(); }
Example #8
Source File: DefaultParameterStorePropertySourceConfigurationStrategy.java From spring-boot-parameter-store-integration with MIT License | 5 votes |
private AWSSimpleSystemsManagement buildSSMClient(ConfigurableEnvironment environment) { if (hasCustomEndpoint(environment)) { return AWSSimpleSystemsManagementClientBuilder.standard() .withEndpointConfiguration(new EndpointConfiguration(getCustomEndpoint(environment), getSigningRegion(environment))) .build(); } return AWSSimpleSystemsManagementClientBuilder.defaultClient(); }
Example #9
Source File: SsmUtil.java From herd-mdl with Apache License 2.0 | 5 votes |
/** * Delete parameter from aws ssm * @param parameterKey ssm parameter key */ public static void deleteParameter(String parameterKey) { LOGGER.info(String.format("delete ssm parameter key %s", parameterKey)); AWSCredentialsProvider credentials = InstanceProfileCredentialsProvider.getInstance(); AWSSimpleSystemsManagement simpleSystemsManagementClient = AWSSimpleSystemsManagementClientBuilder.standard().withCredentials(credentials) .withRegion(Regions.getCurrentRegion().getName()).build(); DeleteParameterRequest parameterRequest = new DeleteParameterRequest().withName(parameterKey); simpleSystemsManagementClient.deleteParameter(parameterRequest); }
Example #10
Source File: SsmUtil.java From herd-mdl with Apache License 2.0 | 5 votes |
/** * Put string parameter to aws ssm * @param parameterKey ssm parameter key * @param parameterValue ssm parameter value */ public static void putParameter(String parameterKey, String parameterValue) { LOGGER.info(String.format("put ssm parameter key %s; with value: %s ", parameterKey, parameterValue)); AWSCredentialsProvider credentials = InstanceProfileCredentialsProvider.getInstance(); AWSSimpleSystemsManagement simpleSystemsManagementClient = AWSSimpleSystemsManagementClientBuilder.standard().withCredentials(credentials) .withRegion(Regions.getCurrentRegion().getName()).build(); PutParameterRequest parameterRequest = new PutParameterRequest().withName(parameterKey).withValue(parameterValue).withOverwrite(true).withType("String"); simpleSystemsManagementClient.putParameter(parameterRequest); }
Example #11
Source File: SsmUtil.java From herd-mdl with Apache License 2.0 | 5 votes |
/** * Get list of parameters with prefix * @param prefix parameter prefix * @return list of parameters */ public static List<Parameter> getParametersWithPrefix(String prefix){ AWSCredentialsProvider credentials = InstanceProfileCredentialsProvider.getInstance(); AWSSimpleSystemsManagement simpleSystemsManagementClient = AWSSimpleSystemsManagementClientBuilder.standard().withCredentials(credentials) .withRegion(Regions.getCurrentRegion().getName()).build(); GetParametersByPathRequest getParametersByPathRequest = new GetParametersByPathRequest() .withPath(prefix) .withRecursive(true); GetParametersByPathResult parameterResult = simpleSystemsManagementClient.getParametersByPath(getParametersByPathRequest); return parameterResult.getParameters(); }
Example #12
Source File: EC2InventoryUtil.java From pacbot with Apache License 2.0 | 5 votes |
/** * Fetch SSM info. * * @param temporaryCredentials the temporary credentials * @param skipRegions the skip regions * @param accountId the accountId * @return the map */ public static Map<String,List<InstanceInformation>> fetchSSMInfo(BasicSessionCredentials temporaryCredentials, String skipRegions, String accountId,String accountName) { Map<String,List<InstanceInformation>> ssmInstanceList = new LinkedHashMap<>(); AWSSimpleSystemsManagement ssmClient; String expPrefix = InventoryConstants.ERROR_PREFIX_CODE + accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"SSM\" , \"region\":\""; List<InstanceInformation> ssmInstanceListTemp ; for (Region region : RegionUtils.getRegions()) { try { if (!skipRegions.contains(region.getName())) { ssmInstanceListTemp = new ArrayList<>(); ssmClient = AWSSimpleSystemsManagementClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)) .withRegion(region.getName()).build(); String nextToken = null; DescribeInstanceInformationResult describeInstanceInfoRslt; do { describeInstanceInfoRslt = ssmClient.describeInstanceInformation( new DescribeInstanceInformationRequest().withNextToken(nextToken)); nextToken = describeInstanceInfoRslt.getNextToken(); ssmInstanceListTemp.addAll(describeInstanceInfoRslt .getInstanceInformationList()); } while (nextToken != null); if(! ssmInstanceListTemp.isEmpty() ) { log.debug(InventoryConstants.ACCOUNT + accountId + " Type : SSM "+region.getName() + " >> "+ssmInstanceListTemp.size()); ssmInstanceList.put(accountId+delimiter+accountName+delimiter+region.getName(), ssmInstanceListTemp); } } } catch (Exception e) { log.warn(expPrefix + region.getName() + InventoryConstants.ERROR_CAUSE + e.getMessage() + "\"}"); ErrorManageUtil.uploadError(accountId, region.getName(), "SSM", e.getMessage()); } } return ssmInstanceList; }
Example #13
Source File: AmazonDockerClientsHolder.java From spring-localstack with Apache License 2.0 | 5 votes |
@Override public AWSSimpleSystemsManagement awsSimpleSystemsManagement() { return decorateWithConfigsAndBuild( AWSSimpleSystemsManagementClientBuilder.standard(), LocalstackDocker::getEndpointSSM ); }
Example #14
Source File: AMQPClient.java From amazon-mq-workshop with Apache License 2.0 | 4 votes |
public static String getUserPassword(String key) { GetParameterResult parameterResult = AWSSimpleSystemsManagementClientBuilder.defaultClient().getParameter(new GetParameterRequest() .withName(key)); return parameterResult.getParameter().getValue(); }
Example #15
Source File: MQTTClient.java From amazon-mq-workshop with Apache License 2.0 | 4 votes |
public static String getUserPassword(String key) { GetParameterResult parameterResult = AWSSimpleSystemsManagementClientBuilder.defaultClient().getParameter(new GetParameterRequest() .withName(key)); return parameterResult.getParameter().getValue(); }
Example #16
Source File: AmazonMqClient.java From amazon-mq-workshop with Apache License 2.0 | 4 votes |
public static String getUserPassword(String key) { GetParameterResult parameterResult = AWSSimpleSystemsManagementClientBuilder.defaultClient().getParameter(new GetParameterRequest() .withName(key)); return parameterResult.getParameter().getValue(); }
Example #17
Source File: StompClient.java From amazon-mq-workshop with Apache License 2.0 | 4 votes |
public static String getUserPassword(String key) { GetParameterResult parameterResult = AWSSimpleSystemsManagementClientBuilder.defaultClient().getParameter(new GetParameterRequest() .withName(key)); return parameterResult.getParameter().getValue(); }
Example #18
Source File: MultiRegionParameterStorePropertySourceConfigurationStrategy.java From spring-boot-parameter-store-integration with MIT License | 4 votes |
private AWSSimpleSystemsManagement buildSSMClient(String region) { return AWSSimpleSystemsManagementClientBuilder.standard().withRegion(region).build(); }
Example #19
Source File: SsmFacade.java From aws-service-catalog-terraform-reference-architecture with Apache License 2.0 | 4 votes |
public SsmFacade() { this.ssm = AWSSimpleSystemsManagementClientBuilder.defaultClient(); }