software.amazon.awssdk.services.ssm.SsmClient Java Examples

The following examples show how to use software.amazon.awssdk.services.ssm.SsmClient. 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: ApplicationModule.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Singleton
@Inject
@Provides
SsmParameterCachingClient ssmParameterCachingClient() {
  String path = String.format("/applications/apprepo/%s/", System.getProperty("integtests.stage"));
  return new SsmParameterCachingClient(SsmClient.builder()
      .httpClientBuilder(UrlConnectionHttpClient.builder())
      .build(),
      Duration.ofMinutes(5), path);
}
 
Example #2
Source File: ApplicationModule.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Singleton
@Inject
@Provides
SsmParameterCachingClient ssmParameterCachingClient() {
  String path = String.format("/applications/apprepo/%s/", System.getProperty("integtests.stage"));
  return new SsmParameterCachingClient(SsmClient.builder()
        .httpClientBuilder(UrlConnectionHttpClient.builder())
        .build(),
        Duration.ofMinutes(5), path);
}
 
Example #3
Source File: GetSimpleSystemsManagementOps.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
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.Java2.get_ops.main]
        // Get the OpsItem ID value
        String opsID = args[0];

        SsmClient ssmClient;
        GetOpsItemRequest opsRequest;

        try {

            Region region = Region.US_WEST_2;
            ssmClient = SsmClient.builder().region(region).build();

            // Create a DescribeParametersRequest object
            opsRequest = GetOpsItemRequest.builder()
                    .opsItemId(opsID)
                    .build();

            // Get SSM Parameters (you can define them in the AWS Console)
            GetOpsItemResponse opsItem = ssmClient.getOpsItem(opsRequest);
            OpsItem item = opsItem.opsItem();

            System.out.println(item.title());
            System.out.println(item.description());
            System.out.println(item.source());

        } catch (SsmException e) {
            e.getStackTrace();
        }
        // snippet-end:[ssm.Java2.get_ops.main]
    }
 
Example #4
Source File: GetSimpleSystemsManagementParas.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {

        // snippet-start:[ssm.Java2.get_params.main]
        SsmClient ssmClient;

        try {

            Region region = Region.US_WEST_2;
            ssmClient = SsmClient.builder().region(region).build();

            // Create a DescribeParametersRequest object
            DescribeParametersRequest desRequest = DescribeParametersRequest.builder()
                    .maxResults(10)
                    .build();

            // Get SSM Parameters (you can define them in the AWS Console)
            DescribeParametersResponse desResponse = ssmClient.describeParameters(desRequest);

            List<ParameterMetadata> params = desResponse.parameters();

            //Iterate through the list
            Iterator<ParameterMetadata> paramIterator = params.iterator();

            while(paramIterator.hasNext()) {

                ParameterMetadata paraMeta = (ParameterMetadata)paramIterator.next();

                System.out.println(paraMeta.name());
                System.out.println(paraMeta.description());
            }

        } catch (SsmException e) {
            e.getStackTrace();
        }
        // snippet-end:[ssm.Java2.get_params.main]
    }
 
Example #5
Source File: ParamStorePropertySourcePostProcessorTest.java    From edison-microservice with Apache License 2.0 5 votes vote down vote up
@Bean
public SsmClient ssmClient() {
    SsmClient mock = mock(SsmClient.class);
    when(mock.getParametersByPath(any(GetParametersByPathRequest.class))).thenReturn(
            GetParametersByPathResponse.builder()
                    .parameters(Parameter.builder().name("mongo/password").value("secret").build())
                    .build()
    );
    return mock;
}
 
Example #6
Source File: ParamStorePropertySourcePostProcessor.java    From edison-microservice with Apache License 2.0 4 votes vote down vote up
@Autowired
public ParamStorePropertySourcePostProcessor(final SsmClient ssmClient) {
    this.ssmClient = ssmClient;
}
 
Example #7
Source File: ParamStoreConfiguration.java    From edison-microservice with Apache License 2.0 4 votes vote down vote up
@Bean
public static ParamStorePropertySourcePostProcessor paramStorePropertySourcePostProcessor(final SsmClient ssmClient) {
    return new ParamStorePropertySourcePostProcessor(ssmClient);
}