public TagsUtils validateTags ( ) { final List < String > instanceTags = getInstanceTags ( ) . stream ( ) . map ( Tag :: getKey ) . collect ( Collectors . toList ( ) ) ; final List < String > missingTags = getAwsTagNames ( ) . map ( List :: stream ) . orElse ( Stream . empty ( ) ) . filter ( configuredTag -> ! instanceTags . contains ( configuredTag ) ) . collect ( Collectors . toList ( ) ) ; if ( ! missingTags . isEmpty ( ) ) { throw new IllegalStateException ( "expected instance tag(s) missing: " + missingTags . stream ( ) . collect ( Collectors . joining ( ", " ) ) ) ; } return this ; }
Configured tags will be validated against the instance tags . If one or more tags are missing on the instance an exception will be thrown .