AWS/AWS Marketplace

AWS Marketplace API Region 확인하는 방법

행운개발자 2024. 1. 16. 23:29
728x90

AWS API를 사용할 때는 연동할 서비스가 있는 Region의 값을 지정해야합니다. 글로벌 리전을 사용하고 있는 경우, region 별로 aws.region 값을 다르게 지정해주어야 합니다.

https://docs.aws.amazon.com/marketplace/latest/buyerguide/supported-regions.html

 

이렇게 찾은 Region 정보는 AWS Marketplace Client를 생성할 때 사용됩니다.

 

private void setAwsRegionProps() {
    System.setProperty("aws.region", conf.aws_marketplace_region);
}

private void setAwsMarketplaceClientProps() {
    // @See com.amazonaws.services.marketplacemetering.AWSMarketplaceMeteringClientBuilder#defaultClient
    // @See com.amazonaws.auth.DefaultAWSCredentialsProviderChain
    System.setProperty("aws.accessKeyId", conf.aws_marketplace_access_key);
    System.setProperty("aws.secretKey", conf.aws_marketplace_secret_access_key);
}

public AWSMarketplaceMetering createAWSMarketplaceClient(){
	setAwsRegionProps();
    setAwsMarketplaceClientProps();
    AWSMarketplaceMeteringClientBuilder builder = AWSMarketplaceMeteringClientBuilder.standard();
    return builder.build();
}
@Service
public class AwsMarketplaceApiService {
    private AWSMarketplaceMetering client;

    @PostConstruct
    public void init(){
        AWSMarketplaceMeteringClientBuilder builder = AWSMarketplaceMeteringClientBuilder.standard();
        client = builder.build();
    }
}
728x90