com.amazonaws.services.simplesystemsmanagement.model.Parameter Java Examples

The following examples show how to use com.amazonaws.services.simplesystemsmanagement.model.Parameter. 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: SsmUtil.java    From herd-mdl with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: AwsParamStorePropertySourceTest.java    From spring-cloud-aws with Apache License 2.0 6 votes vote down vote up
@Test
void followsNextToken() {
	GetParametersByPathResult firstResult = new GetParametersByPathResult()
			.withNextToken("next").withParameters(
					new Parameter().withName("/config/myservice/key1")
							.withValue("value1"),
					new Parameter().withName("/config/myservice/key2")
							.withValue("value2"));

	GetParametersByPathResult nextResult = new GetParametersByPathResult()
			.withParameters(
					new Parameter().withName("/config/myservice/key3")
							.withValue("value3"),
					new Parameter().withName("/config/myservice/key4")
							.withValue("value4"));

	when(ssmClient.getParametersByPath(any(GetParametersByPathRequest.class)))
			.thenReturn(firstResult, nextResult);

	propertySource.init();

	assertThat(propertySource.getPropertyNames()).containsExactly("key1", "key2",
			"key3", "key4");
	assertThat(propertySource.getProperty("key3")).isEqualTo("value3");
}
 
Example #3
Source File: SsmUtil.java    From herd-mdl with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #4
Source File: ParameterStoreSourceTest.java    From spring-boot-parameter-store-integration with MIT License 5 votes vote down vote up
@Test
public void testGetProperty()
{
    when(ssmClientMock.getParameter(getParameterRequest(VALID_PROPERTY_NAME))).thenReturn(getGetParameterResult().withParameter(new Parameter().withValue(VALID_PROPERTY_VALUE)));

    Object value = parameterStoreSource.getProperty(VALID_PROPERTY_NAME);

    assertThat(value, is(VALID_PROPERTY_VALUE));
}
 
Example #5
Source File: ParameterStoreSourceTest.java    From spring-boot-parameter-store-integration with MIT License 5 votes vote down vote up
@Test(expected = ParameterStoreError.class)
public void shouldThrowWhenParameterValueIsNull()
{
    when(ssmClientMock.getParameter(getParameterRequest(VALID_PROPERTY_NAME))).thenReturn(getGetParameterResult().withParameter(new Parameter()));
    ParameterStoreSource parameterStoreSourceHaltingBoot = new ParameterStoreSource(ssmClientMock, true);

    parameterStoreSourceHaltingBoot.getProperty(VALID_PROPERTY_NAME);
}
 
Example #6
Source File: AwsParamStorePropertySource.java    From spring-cloud-aws with Apache License 2.0 5 votes vote down vote up
private void getParameters(GetParametersByPathRequest paramsRequest) {
	GetParametersByPathResult paramsResult = source
			.getParametersByPath(paramsRequest);
	for (Parameter parameter : paramsResult.getParameters()) {
		String key = parameter.getName().replace(context, "").replace('/', '.');
		LOGGER.debug("Populating property retrieved from AWS Parameter Store: {}",
				key);
		properties.put(key, parameter.getValue());
	}
	if (paramsResult.getNextToken() != null) {
		getParameters(paramsRequest.withNextToken(paramsResult.getNextToken()));
	}
}
 
Example #7
Source File: SsmUtil.java    From herd-mdl with Apache License 2.0 4 votes vote down vote up
public static Parameter getPlainTextParameter(String parameterKey) {
    return getParameter(parameterKey, false);
}
 
Example #8
Source File: SsmUtil.java    From herd-mdl with Apache License 2.0 4 votes vote down vote up
public static Parameter getSecureParameter(String parameterKey) {
    return getParameter(parameterKey, true);
}
 
Example #9
Source File: SsmUtil.java    From herd-mdl with Apache License 2.0 4 votes vote down vote up
private static Parameter getSsmParameter(SsmParameterKeyEnum parameterKey, boolean isEncrypted) {
    return getParameter(parameterKey.getParameterKey(), isEncrypted);
}
 
Example #10
Source File: AwsParamStorePropertySourceLocatorTest.java    From spring-cloud-aws with Apache License 2.0 4 votes vote down vote up
private static GetParametersByPathResult getNextResult() {
	return new GetParametersByPathResult().withParameters(
			new Parameter().withName("/config/myservice/key3").withValue("value3"),
			new Parameter().withName("/config/myservice/key4").withValue("value4"));
}
 
Example #11
Source File: AwsParamStorePropertySourceLocatorTest.java    From spring-cloud-aws with Apache License 2.0 4 votes vote down vote up
private static GetParametersByPathResult getFirstResult() {
	return new GetParametersByPathResult().withParameters(
			new Parameter().withName("/config/myservice/key3").withValue("value3"),
			new Parameter().withName("/config/myservice/key4").withValue("value4"));
}
 
Example #12
Source File: HerdRollingUpgradeTest.java    From herd-mdl with Apache License 2.0 3 votes vote down vote up
/**
 * Fetches the most recent deployment id from parameter-store, populated by the Herd upgrade utility.
 *
 * @param instanceName the specified MDL instance name
 * @param environment the specified environment
 * @return String. The most recent deployment id
 */
private String getMostRecentDeploymentId(String instanceName, String environment) {

  final String mostRecentDeploymendIdFormat = "/app/MDL/%s/%s/HERD/MostRecentDeploymentId";

  Parameter parameter = SsmUtil
      .getPlainTextParameter(String.format(mostRecentDeploymendIdFormat, instanceName, environment));

  return parameter.getValue();
}
 
Example #13
Source File: SsmUtil.java    From herd-mdl with Apache License 2.0 2 votes vote down vote up
/**
 * Get parameter using parameter key
 *
 * @param parameterKey parameter key
 * @return Parameter
 */
public static Parameter getPlainLdapParameter(SsmParameterKeyEnum parameterKey) {
    return getSsmParameter(parameterKey, false);
}
 
Example #14
Source File: SsmUtil.java    From herd-mdl with Apache License 2.0 2 votes vote down vote up
/**
 * Get parameter using parameter key
 *
 * @param parameterKey parameter key
 * @return Parameter
 */
public static Parameter getPlainVpcParameter(SsmParameterKeyEnum parameterKey) {
    return getSsmParameter(parameterKey, false);
}
 
Example #15
Source File: SsmUtil.java    From herd-mdl with Apache License 2.0 2 votes vote down vote up
/**
 * Get parameter with decrypted value using parameter key
 *
 * @param parameterKey parameter key
 * @return Parameter
 */
public static Parameter getDecryptedLdapParameter(SsmParameterKeyEnum parameterKey) {
    return getSsmParameter(parameterKey, true);
}