Search in sources :

Example 6 with AWSSimpleSystemsManagement

use of com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement in project aws-doc-sdk-examples by awsdocs.

the class GetSimpleSystemsManagementParas method main.

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]
}
Also used : DescribeParametersResult(com.amazonaws.services.simplesystemsmanagement.model.DescribeParametersResult) DescribeParametersRequest(com.amazonaws.services.simplesystemsmanagement.model.DescribeParametersRequest) AmazonServiceException(com.amazonaws.AmazonServiceException) AWSSimpleSystemsManagement(com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement) ParameterMetadata(com.amazonaws.services.simplesystemsmanagement.model.ParameterMetadata)

Example 7 with AWSSimpleSystemsManagement

use of com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement in project Gatekeeper by FINRAOS.

the class AwsSessionServiceTest method testGetSsmSession.

@Test
public void testGetSsmSession() {
    AWSSimpleSystemsManagement client = awsSessionService.getSsmSession(awsEnvironment);
    Assert.assertNotNull("Verify Ssm Session is fetched", client);
    Mockito.verify(awsSessionFactory, times(1)).createSsmSession(anyObject(), eq(awsEnvironment.getRegion()));
}
Also used : AWSSimpleSystemsManagement(com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement) Test(org.junit.Test)

Example 8 with AWSSimpleSystemsManagement

use of com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement in project spring-cloud-aws by awspring.

the class AwsParamStorePropertySourceLocator method locate.

@Override
public PropertySource<?> locate(Environment environment) {
    if (!(environment instanceof ConfigurableEnvironment)) {
        return null;
    }
    ConfigurableEnvironment env = (ConfigurableEnvironment) environment;
    AwsParamStorePropertySources sources = new AwsParamStorePropertySources(this.properties);
    List<String> profiles = Arrays.asList(env.getActiveProfiles());
    List<String> contexts = sources.getAutomaticContexts(profiles);
    // contexts are initially loaded in ascending priority order (for the
    // compatibility with spring-config-import=)
    // here it must be reversed to load from the most specific property source first
    Collections.reverse(contexts);
    this.contexts.addAll(contexts);
    CompositePropertySource composite = new CompositePropertySource("aws-param-store");
    for (String propertySourceContext : this.contexts) {
        PropertySource<AWSSimpleSystemsManagement> propertySource = sources.createPropertySource(propertySourceContext, !this.properties.isFailFast(), this.ssmClient);
        if (propertySource != null) {
            composite.addPropertySource(propertySource);
        }
    }
    return composite;
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) CompositePropertySource(org.springframework.core.env.CompositePropertySource) AWSSimpleSystemsManagement(com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement)

Example 9 with AWSSimpleSystemsManagement

use of com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement in project spring-cloud-aws by awspring.

the class AwsParamStoreConfigDataLoader method load.

@Override
public ConfigData load(ConfigDataLoaderContext context, AwsParamStoreConfigDataResource resource) {
    try {
        AWSSimpleSystemsManagement ssm = context.getBootstrapContext().get(AWSSimpleSystemsManagement.class);
        AwsParamStorePropertySource propertySource = resource.getPropertySources().createPropertySource(resource.getContext(), resource.isOptional(), ssm);
        if (propertySource != null) {
            return new ConfigData(Collections.singletonList(propertySource));
        } else {
            return null;
        }
    } catch (Exception e) {
        throw new ConfigDataResourceNotFoundException(resource, e);
    }
}
Also used : AwsParamStorePropertySource(io.awspring.cloud.paramstore.AwsParamStorePropertySource) ConfigData(org.springframework.boot.context.config.ConfigData) ConfigDataResourceNotFoundException(org.springframework.boot.context.config.ConfigDataResourceNotFoundException) AWSSimpleSystemsManagement(com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement) ConfigDataResourceNotFoundException(org.springframework.boot.context.config.ConfigDataResourceNotFoundException)

Aggregations

AWSSimpleSystemsManagement (com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement)9 AmazonServiceException (com.amazonaws.AmazonServiceException)2 AWSSimpleSystemsManagementClientBuilder (com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClientBuilder)1 DescribeParametersRequest (com.amazonaws.services.simplesystemsmanagement.model.DescribeParametersRequest)1 DescribeParametersResult (com.amazonaws.services.simplesystemsmanagement.model.DescribeParametersResult)1 GetOpsItemRequest (com.amazonaws.services.simplesystemsmanagement.model.GetOpsItemRequest)1 GetOpsItemResult (com.amazonaws.services.simplesystemsmanagement.model.GetOpsItemResult)1 GetParameterRequest (com.amazonaws.services.simplesystemsmanagement.model.GetParameterRequest)1 GetParameterResult (com.amazonaws.services.simplesystemsmanagement.model.GetParameterResult)1 OpsItem (com.amazonaws.services.simplesystemsmanagement.model.OpsItem)1 ParameterMetadata (com.amazonaws.services.simplesystemsmanagement.model.ParameterMetadata)1 AwsParamStorePropertySource (io.awspring.cloud.paramstore.AwsParamStorePropertySource)1 Test (org.junit.Test)1 ConfigData (org.springframework.boot.context.config.ConfigData)1 ConfigDataResourceNotFoundException (org.springframework.boot.context.config.ConfigDataResourceNotFoundException)1 CompositePropertySource (org.springframework.core.env.CompositePropertySource)1 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)1