String retrieveToken() {
        String response = createRestClient(ec2MetadataTokenEndpoint, awsConfig)
            .withHeader("X-aws-ec2-metadata-token-ttl-seconds", Long.toString(METADATA_TOKEN_TTL_SECONDS))
            .put()
            .getBody();
        // we want to refresh token before it expires
        metadataExpiry = Instant.now().plusSeconds(METADATA_TOKEN_TTL_SECONDS / 2);
        return response;
    }
@Test
    public void retrieveToken() {
        // given
        String token = "retrievetoken";
        stubFor(put(urlEqualTo(METADATA_TOKEN_URL))
            .willReturn(aResponse().withStatus(HttpURLConnection.HTTP_OK).withBody(token)));

        // when
        String result = awsMetadataApi.retrieveToken();

        // then
        assertEquals(token, result);
    }