@Test public void testConfigureNatEmptyMap() { Interface iface = Interface.builder().setName("iface").build(); configureNat(iface, ImmutableMap.of()); assertThat(iface.getIncomingTransformation(), nullValue()); assertThat(iface.getOutgoingTransformation(), nullValue()); }
@VisibleForTesting static void configureNat(Interface bbInterface, Map<Ip, Ip> privatePublicMap) { ImmutableList.Builder<Transformation.Builder> outgoingNatRules = ImmutableList.builder(); ImmutableList.Builder<Transformation.Builder> incomingNatRules = ImmutableList.builder(); privatePublicMap.forEach( (pvtIp, pubIp) -> { outgoingNatRules.add( Transformation.when(AclLineMatchExprs.matchSrc(pvtIp)) .apply(TransformationStep.shiftSourceIp(pubIp.toPrefix()))); incomingNatRules.add( Transformation.when(AclLineMatchExprs.matchDst(pubIp)) .apply(TransformationStep.shiftDestinationIp(pvtIp.toPrefix()))); }); bbInterface.setOutgoingTransformation(chain(outgoingNatRules.build())); bbInterface.setIncomingTransformation(chain(incomingNatRules.build())); }
InternetGateway implements AwsVpcEntity, Serializable { @VisibleForTesting static void configureNat(Interface bbInterface, Map<Ip, Ip> privatePublicMap) { ImmutableList.Builder<Transformation.Builder> outgoingNatRules = ImmutableList.builder(); ImmutableList.Builder<Transformation.Builder> incomingNatRules = ImmutableList.builder(); privatePublicMap.forEach( (pvtIp, pubIp) -> { outgoingNatRules.add( Transformation.when(AclLineMatchExprs.matchSrc(pvtIp)) .apply(TransformationStep.shiftSourceIp(pubIp.toPrefix()))); incomingNatRules.add( Transformation.when(AclLineMatchExprs.matchDst(pubIp)) .apply(TransformationStep.shiftDestinationIp(pvtIp.toPrefix()))); }); bbInterface.setOutgoingTransformation(chain(outgoingNatRules.build())); bbInterface.setIncomingTransformation(chain(incomingNatRules.build())); } }
InternetGateway implements AwsVpcEntity, Serializable { @VisibleForTesting static void configureNat(Interface bbInterface, Map<Ip, Ip> privatePublicMap) { ImmutableList.Builder<Transformation.Builder> outgoingNatRules = ImmutableList.builder(); ImmutableList.Builder<Transformation.Builder> incomingNatRules = ImmutableList.builder(); privatePublicMap.forEach( (pvtIp, pubIp) -> { outgoingNatRules.add( Transformation.when(AclLineMatchExprs.matchSrc(pvtIp)) .apply(TransformationStep.shiftSourceIp(pubIp.toPrefix()))); incomingNatRules.add( Transformation.when(AclLineMatchExprs.matchDst(pubIp)) .apply(TransformationStep.shiftDestinationIp(pvtIp.toPrefix()))); }); bbInterface.setOutgoingTransformation(chain(outgoingNatRules.build())); bbInterface.setIncomingTransformation(chain(incomingNatRules.build())); } InternetGateway(
      String internetGatewayId, List<String> attachmentVpcIds, Map<String, String> tags); }
InternetGateway implements AwsVpcEntity, Serializable { @VisibleForTesting static void configureNat(Interface bbInterface, Map<Ip, Ip> privatePublicMap) { ImmutableList.Builder<Transformation.Builder> outgoingNatRules = ImmutableList.builder(); ImmutableList.Builder<Transformation.Builder> incomingNatRules = ImmutableList.builder(); privatePublicMap.forEach( (pvtIp, pubIp) -> { outgoingNatRules.add( Transformation.when(AclLineMatchExprs.matchSrc(pvtIp)) .apply(TransformationStep.shiftSourceIp(pubIp.toPrefix()))); incomingNatRules.add( Transformation.when(AclLineMatchExprs.matchDst(pubIp)) .apply(TransformationStep.shiftDestinationIp(pvtIp.toPrefix()))); }); bbInterface.setOutgoingTransformation(chain(outgoingNatRules.build())); bbInterface.setIncomingTransformation(chain(incomingNatRules.build())); } InternetGateway(
      String internetGatewayId, List<String> attachmentVpcIds, Map<String, String> tags); @Override String getId(); @Nonnull List<String> getAttachmentVpcIds(); @Override boolean equals(Object o); @Override int hashCode(); }
InternetGateway implements AwsVpcEntity, Serializable { @VisibleForTesting static void configureNat(Interface bbInterface, Map<Ip, Ip> privatePublicMap) { ImmutableList.Builder<Transformation.Builder> outgoingNatRules = ImmutableList.builder(); ImmutableList.Builder<Transformation.Builder> incomingNatRules = ImmutableList.builder(); privatePublicMap.forEach( (pvtIp, pubIp) -> { outgoingNatRules.add( Transformation.when(AclLineMatchExprs.matchSrc(pvtIp)) .apply(TransformationStep.shiftSourceIp(pubIp.toPrefix()))); incomingNatRules.add( Transformation.when(AclLineMatchExprs.matchDst(pubIp)) .apply(TransformationStep.shiftDestinationIp(pvtIp.toPrefix()))); }); bbInterface.setOutgoingTransformation(chain(outgoingNatRules.build())); bbInterface.setIncomingTransformation(chain(incomingNatRules.build())); } InternetGateway(
      String internetGatewayId, List<String> attachmentVpcIds, Map<String, String> tags); @Override String getId(); @Nonnull List<String> getAttachmentVpcIds(); @Override boolean equals(Object o); @Override int hashCode();  }