private boolean isEnvironmentValid(@NonNull final Environment environment)
      throws InternalServiceException {
    try {
      final Environment retrievedEnvironment = getEnvironment(environment.getEnvironmentId());
      if (retrievedEnvironment.isValidEnvironment()) {
        log.info(
            String.format(
                "Environment %s exists and is valid. Cannot recreate.",
                environment.getEnvironmentId().toString()));
        return true;
      }
    } catch (final ResourceNotFoundException e) {
      log.info(
          String.format(
              "Environment %s does not exist. Skipping valid environment check.",
              environment.getEnvironmentId().toString()),
          e);
    }

    return false;
  }
Create respecting optimistic locking. If an environment with specified keys exists or the item
has been updated after being retrieved, a conditional check exception will be thrown.
data-service/src/main/java/com/amazonaws/blox/dataservice/repository/EnvironmentRepositoryDDB.java