public String createService ( AWSServiceDiscovery serviceDiscovery , String name , String description , String namespaceId , Long ttl ) { if ( serviceDiscovery == null ) { serviceDiscovery = AWSServiceDiscoveryClient . builder ( ) . withClientConfiguration ( clientConfiguration . getClientConfiguration ( ) ) . build ( ) ; } DnsRecord dnsRecord = new DnsRecord ( ) . withType ( RecordType . A ) . withTTL ( ttl ) ; DnsConfig dnsConfig = new DnsConfig ( ) . withDnsRecords ( dnsRecord ) . withNamespaceId ( namespaceId ) . withRoutingPolicy ( RoutingPolicy . WEIGHTED ) ; CreateServiceRequest createServiceRequest = new CreateServiceRequest ( ) . withDnsConfig ( dnsConfig ) . withDescription ( description ) . withName ( name ) ; CreateServiceResult servicerResult = serviceDiscovery . createService ( createServiceRequest ) ; Service createdService = servicerResult . getService ( ) ; return createdService . getId ( ) ; }
Create service helper for integration tests .