static String resolveRegion(AwsConfig awsConfig, AwsMetadataApi metadataApi, Environment environment) {
        if (!isNullOrEmptyAfterTrim(awsConfig.getRegion())) {
            return awsConfig.getRegion();
        }

        if (environment.isRunningOnEcs()) {
            return regionFrom(metadataApi.availabilityZoneEcs());
        }

        return regionFrom(metadataApi.availabilityZoneEc2());
    }
@Test
    public void resolveRegionEcsMetadata() {
        // given
        AwsConfig awsConfig = AwsConfig.builder().build();
        AwsMetadataApi awsMetadataApi = mock(AwsMetadataApi.class);
        Environment environment = mock(Environment.class);
        given(environment.isRunningOnEcs()).willReturn(true);
        given(awsMetadataApi.availabilityZoneEcs()).willReturn("us-east-1a");

        // when
        String result = resolveRegion(awsConfig, awsMetadataApi, environment);
        // then
        assertEquals("us-east-1", result);
    }