values.add(fieldValue.asText()); conditions.add(new Condition().withType(conditionType) .withConditionKey(field.getKey()).withValues(values));
values.add(fieldValue.asText()); conditions.add(new Condition().withType(conditionType) .withConditionKey(field.getKey()).withValues(values));
/** * Generates a condition instance for each condition type under the * Condition JSON node. * * @param conditions the complete list of conditions * @param conditionType the condition type for the condition being created. * @param conditionNode each condition node to be parsed. * @throws IOException */ private void convertConditionRecord(List<Condition> conditions, String conditionType, AwsJsonReader reader) throws IOException { reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); List<String> values = new LinkedList<String>(); if (reader.isContainer()) { reader.beginArray(); while (reader.hasNext()) { values.add(reader.nextString()); } reader.endArray(); } else { values.add(reader.nextString()); } conditions.add(new Condition().withType(conditionType).withConditionKey(name) .withValues(values)); } reader.endObject(); }
values.add(fieldValue.asText()); conditions.add(new Condition().withType(conditionType) .withConditionKey(field.getKey()).withValues(values));
/** * This policy allows operators to choose whether or not to have lifecycle hooks to be sent via SNS for fanout, or * be sent directly to an SQS queue from the autoscaling group. */ private static Policy buildSQSPolicy(ARN queue, ARN topic, Set<String> terminatingRoleArns) { Statement snsStatement = new Statement(Effect.Allow).withActions(SQSActions.SendMessage); snsStatement.setPrincipals(Principal.All); snsStatement.setResources(Collections.singletonList(new Resource(queue.arn))); snsStatement.setConditions(Collections.singletonList( new Condition().withType("ArnEquals").withConditionKey("aws:SourceArn").withValues(topic.arn) )); Statement sqsStatement = new Statement(Effect.Allow).withActions(SQSActions.SendMessage, SQSActions.GetQueueUrl); sqsStatement.setPrincipals(terminatingRoleArns.stream().map(Principal::new).collect(Collectors.toList())); sqsStatement.setResources(Collections.singletonList(new Resource(queue.arn))); return new Policy("allow-sns-or-sqs-send", Arrays.asList(snsStatement, sqsStatement)); }
private static Policy buildSQSPolicy(ARN queue, ARN topic) { Statement statement = new Statement(Statement.Effect.Allow).withActions(SQSActions.SendMessage); statement.setPrincipals(Principal.All); statement.setResources(Collections.singletonList(new Resource(queue.arn))); statement.setConditions(Collections.singletonList( new Condition().withType("ArnEquals").withConditionKey("aws:SourceArn").withValues(topic.arn) )); return new Policy("allow-sns-topic-send", Collections.singletonList(statement)); }
/** * This policy allows messages to be sent from an SNS topic. */ public static Policy buildSQSPolicy(ARN queue, ARN topic) { Statement snsStatement = new Statement(Statement.Effect.Allow).withActions(SQSActions.SendMessage); snsStatement.setPrincipals(Principal.All); snsStatement.setResources(Collections.singletonList(new Resource(queue.getArn()))); snsStatement.setConditions(Collections.singletonList( new Condition().withType("ArnEquals").withConditionKey("aws:SourceArn").withValues(topic.getArn()) )); return new Policy("allow-sns-send", Collections.singletonList(snsStatement)); } }
/** * Generates a condition instance for each condition type under the * Condition JSON node. * * @param conditions the complete list of conditions * @param conditionType the condition type for the condition being created. * @param conditionNode each condition node to be parsed. * @throws IOException */ private void convertConditionRecord(List<Condition> conditions, String conditionType, AwsJsonReader reader) throws IOException { reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); List<String> values = new LinkedList<String>(); if (reader.isContainer()) { reader.beginArray(); while (reader.hasNext()) { values.add(reader.nextString()); } reader.endArray(); } else { values.add(reader.nextString()); } conditions.add(new Condition().withType(conditionType).withConditionKey(name) .withValues(values)); } reader.endObject(); }
/** * Generates a condition instance for each condition type under the * Condition JSON node. * * @param conditions the complete list of conditions * @param conditionType the condition type for the condition being created. * @param conditionNode each condition node to be parsed. * @throws IOException */ private void convertConditionRecord(List<Condition> conditions, String conditionType, AwsJsonReader reader) throws IOException { reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); List<String> values = new LinkedList<String>(); if (reader.isContainer()) { reader.beginArray(); while (reader.hasNext()) { values.add(reader.nextString()); } reader.endArray(); } else { values.add(reader.nextString()); } conditions.add(new Condition().withType(conditionType).withConditionKey(name) .withValues(values)); } reader.endObject(); }