String authHeader(Map<String, String> attributes, Map<String, String> headers, String body,
                      AwsCredentials credentials, String timestamp, String httpMethod) {
        return buildAuthHeader(
            credentials.getAccessKey(),
            credentialScopeEcs(timestamp),
            signedHeaders(headers),
            sign(attributes, headers, body, credentials, timestamp, httpMethod)
        );
    }
@Test
    public void authHeaderEc2() {
        // given
        String timestamp = "20141106T111126Z";

        Map<String, String> attributes = new HashMap<>();
        attributes.put("Action", "DescribeInstances");
        attributes.put("Version", "2016-11-15");

        Map<String, String> headers = new HashMap<>();
        headers.put("X-Amz-Date", timestamp);
        headers.put("Host", "ec2.eu-central-1.amazonaws.com");

        String body = "";

        AwsCredentials credentials = AwsCredentials.builder()
            .setAccessKey("AKIDEXAMPLE")
            .setSecretKey("wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY")
            .build();

        AwsRequestSigner requestSigner = new AwsRequestSigner("eu-central-1", "ec2");

        // when
        String authHeader = requestSigner.authHeader(attributes, headers, body, credentials, timestamp, "POST");

        // then
        String expectedAuthHeader = "AWS4-HMAC-SHA256 "
            + "Credential=AKIDEXAMPLE/20141106/eu-central-1/ec2/aws4_request, "
            + "SignedHeaders=host;x-amz-date, "
            + "Signature=cedc903f54260b232ced76caf4a72f061565a51cc583a17da87b1132522f5893";
        assertEquals(expectedAuthHeader, authHeader);
    }