joinConfig.getAwsConfig().setEnabled(false); joinConfig.getMulticastConfig().setEnabled(false); joinConfig.getTcpIpConfig().setEnabled(true);
@Override public IdentifiedDataSerializable createNew(Integer arg) { return new AwsConfig(); } };
public String createFormattedCredential() { return config.getAccessKey() + "/" + timestamp.substring(0, LAST_INDEX) + "/" + config.getRegion() + "/" + "ec2/aws4_request"; } }
protected static void configureAWS(SploutConfiguration buConf, JoinConfig join) throws HazelcastConfigBuilderException { log.info("Configuring Splout for AWS auto-discovery Hazelcast join (http://www.hazelcast.com/docs/1.9.4/manual/multi_html/ch11s02.html)."); join.getAwsConfig().setEnabled(true); String key = buConf.getString(HazelcastProperties.AWS_KEY); if (key == null) { throw new HazelcastConfigBuilderException("Missing AWS Key property (" + HazelcastProperties.AWS_KEY + ")"); } String secretKey = buConf.getString(HazelcastProperties.AWS_SECRET); if (secretKey == null) { throw new HazelcastConfigBuilderException("Missing AWS Secret Key property (" + HazelcastProperties.AWS_SECRET + ")"); } join.getAwsConfig().setAccessKey(key); join.getAwsConfig().setSecretKey(secretKey); // Optionally add the security group String securityGroup = buConf.getString(HazelcastProperties.AWS_SECURITY_GROUP); if (securityGroup != null) { log.info("-- Using security group: " + securityGroup); join.getAwsConfig().setSecurityGroupName(securityGroup); } }
static AwsConfig fromDeprecatedAwsConfig(com.hazelcast.config.AwsConfig awsConfig) { return AwsConfig.builder().setAccessKey(awsConfig.getAccessKey()).setSecretKey(awsConfig.getSecretKey()) .setRegion(awsConfig.getRegion()).setSecurityGroupName(awsConfig.getSecurityGroupName()) .setTagKey(awsConfig.getTagKey()).setTagValue(awsConfig.getTagValue()) .setHostHeader(awsConfig.getHostHeader()).setIamRole(awsConfig.getIamRole()) .setConnectionTimeoutSeconds(awsConfig.getConnectionTimeoutSeconds()).build(); }
log.info("Setting up Joiner with this being " + (isAws ? "AWS" : "Multicast")); join.getAwsConfig().setEnabled(isAws); if(isAws) { join.getAwsConfig().setAccessKey(System.getProperty("hazelcast.access-key")); join.getAwsConfig().setSecretKey(System.getProperty("hazelcast.access-secret"));
public AWSClient(AwsConfig awsConfig) { if (awsConfig == null) { throw new IllegalArgumentException("AwsConfig is required!"); } if (awsConfig.getAccessKey() == null && awsConfig.getIamRole() == null) { throw new IllegalArgumentException("AWS access key or IAM Role is required!"); } if (awsConfig.getSecretKey() == null && awsConfig.getIamRole() == null) { throw new IllegalArgumentException("AWS secret key or Iam Role is required!"); } this.awsConfig = awsConfig; endpoint = awsConfig.getHostHeader(); if (awsConfig.getRegion() != null && awsConfig.getRegion().length() > 0) { if (!awsConfig.getHostHeader().startsWith("ec2.")) { throw new InvalidConfigurationException("HostHeader should start with \"ec2.\" prefix"); } setEndpoint(awsConfig.getHostHeader().replace("ec2.", "ec2." + awsConfig.getRegion() + ".")); } }
private void getKeysFromIamRole() { try { String query = "latest/meta-data/iam/security-credentials/" + awsConfig.getIamRole(); URL url = new URL("http", IAM_ROLE_ENDPOINT, query); InputStreamReader is = new InputStreamReader(url.openStream(), "UTF-8"); BufferedReader reader = new BufferedReader(is); Map<String, String> map = parseIamRole(reader); awsConfig.setAccessKey(map.get("AccessKeyId")); awsConfig.setSecretKey(map.get("SecretAccessKey")); attributes.put("X-Amz-Security-Token", map.get("Token")); } catch (IOException io) { throw new InvalidConfigurationException("Invalid Aws Configuration"); } }
@Bean public Config hazelcastConfig() { Config config = new Config(); config.getNetworkConfig().getInterfaces().setEnabled(true).addInterface("10.0.*.*"); JoinConfig joinConfig = config.getNetworkConfig().getJoin(); joinConfig.getMulticastConfig().setEnabled(false); joinConfig.getAwsConfig() .setEnabled(true) .setProperty("region", "eu-central-1") .setProperty("tag-key", "aws:cloudformation:stack-name") .setProperty("tag-value", "EC2ContainerService-test-cluster"); return config; }
joinConfig.setTcpIpConfig(tcpIpConfig); final AwsConfig awsConfig = new AwsConfig(); awsConfig.setEnabled(false); joinConfig.setAwsConfig(awsConfig);
public DescribeInstances(AwsConfig awsConfig, String endpoint) throws IOException { if (awsConfig == null) { throw new IllegalArgumentException("AwsConfig is required!"); } if (awsConfig.getAccessKey() == null && awsConfig.getIamRole() == null) { throw new IllegalArgumentException("AWS access key or IAM Role is required!"); } this.awsConfig = awsConfig; this.endpoint = endpoint; if (awsConfig.getIamRole() != null) { tryGetDefaultIamRole(); getKeysFromIamRole(); } rs = new EC2RequestSigner(awsConfig, timeStamp, endpoint); attributes.put("Action", this.getClass().getSimpleName()); attributes.put("Version", DOC_VERSION); attributes.put("X-Amz-Algorithm", SIGNATURE_METHOD_V4); attributes.put("X-Amz-Credential", rs.createFormattedCredential()); attributes.put("X-Amz-Date", timeStamp); attributes.put("X-Amz-SignedHeaders", "host"); attributes.put("X-Amz-Expires", "30"); }
private void tryGetDefaultIamRole() throws IOException { InputStreamReader is = null; BufferedReader reader = null; if (!awsConfig.getIamRole().equals("DEFAULT")) { return; } try { String query = "latest/meta-data/iam/security-credentials/"; URL url; url = new URL("http", IAM_ROLE_ENDPOINT, query); is = new InputStreamReader(url.openStream(), "UTF-8"); reader = new BufferedReader(is); awsConfig.setIamRole(reader.readLine()); } catch (IOException e) { throw new InvalidConfigurationException("Invalid Aws Configuration"); } finally { if (is != null) { is.close(); } if (reader != null) { reader.close(); } } }
@Override protected int getConnTimeoutSeconds() { AwsConfig awsConfig = node.getConfig().getNetworkConfig().getJoin().getAwsConfig(); return awsConfig.getConnectionTimeoutSeconds(); }
setMulticastConfig(new MulticastConfig().setEnabled(false)). setTcpIpConfig(new TcpIpConfig().setEnabled(false)). setAwsConfig(new AwsConfig().setEnabled(true). setAccessKey(Config.AWS_ACCESSKEY). setSecretKey(Config.AWS_SECRETKEY). setRegion(Config.AWS_REGION). setSecurityGroupName(Config.APP_NAME_NS))));
static AwsConfig fromDeprecatedAwsConfig(com.hazelcast.config.AwsConfig awsConfig) { return AwsConfig.builder().setAccessKey(awsConfig.getAccessKey()).setSecretKey(awsConfig.getSecretKey()) .setRegion(awsConfig.getRegion()).setSecurityGroupName(awsConfig.getSecurityGroupName()) .setTagKey(awsConfig.getTagKey()).setTagValue(awsConfig.getTagValue()) .setHostHeader(awsConfig.getHostHeader()).setIamRole(awsConfig.getIamRole()) .setConnectionTimeoutSeconds(awsConfig.getConnectionTimeoutSeconds()).build(); }
tcpIpConfig.setEnabled(false); AwsConfig awsConfig = joinConfig.getAwsConfig(); awsConfig.setEnabled(true); awsConfig.setAccessKey(connectOptions.getAwsAccessKeyId()); awsConfig.setSecretKey(connectOptions.getAwsSecretKey()); awsConfig.setRegion(AwsUtils.getRegion()); awsConfig.setSecurityGroupName(groupName);
private Properties getConfigProperties() { Config config = new Config(); config.setClassLoader( getClass().getClassLoader() ); config.setInstanceName( "ecdr-jcache-config-instance" ); NetworkConfig networkConfig = config.getNetworkConfig(); JoinConfig join = networkConfig.getJoin(); join.getMulticastConfig().setEnabled( false ); join.getTcpIpConfig().setEnabled( false ); join.getAwsConfig().setEnabled( false ); // This actually creates the config so it will be available to the CacheManager Hazelcast.newHazelcastInstance( config ); Properties props = new Properties(); props.setProperty( HazelcastCachingProvider.HAZELCAST_INSTANCE_NAME, config.getInstanceName() ); return props; }
/** * Creates new {@link AliasedDiscoveryConfig} by the given {@code tag}. */ public static AliasedDiscoveryConfig newConfigFor(String tag) { if ("aws".equals(tag)) { return new AwsConfig(); } else if ("gcp".equals(tag)) { return new GcpConfig(); } else if ("azure".equals(tag)) { return new AzureConfig(); } else if ("kubernetes".equals(tag)) { return new KubernetesConfig(); } else if ("eureka".equals(tag)) { return new EurekaConfig(); } else { throw new IllegalArgumentException(String.format("Invalid tag: '%s'", tag)); } } }
protected Config createConfig() { Config config = new Config(); JoinConfig joinConfig = config.getNetworkConfig().getJoin(); joinConfig.getAwsConfig().setEnabled(false); joinConfig.getMulticastConfig().setEnabled(false); joinConfig.getTcpIpConfig().setEnabled(false); return config; }
/** * Creates new {@link AliasedDiscoveryConfig} by the given {@code tag}. */ @SuppressWarnings("unchecked") public static AliasedDiscoveryConfig newConfigFor(String tag) { if ("aws".equals(tag)) { return new AwsConfig(); } else if ("gcp".equals(tag)) { return new GcpConfig(); } else if ("azure".equals(tag)) { return new AzureConfig(); } else if ("kubernetes".equals(tag)) { return new KubernetesConfig(); } else if ("eureka".equals(tag)) { return new EurekaConfig(); } else { throw new IllegalArgumentException(String.format("Invalid tag: '%s'", tag)); } } }