skip to Main Content

I want to invoke an aws lambda function through java code using the aws lamdba sdk while specifying a proxy above the client. How can I achieve such scenario? I did not manage to locate any documentation on aws docs.

I am using

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>lambda</artifactId>
    <version>2.21.10</version>
</dependency>

I have something like this, and i want to specify a proxy here. Any idea?

@PostConstruct
public void init() {
    lambdaClient = LambdaClient.builder()
            // specify a proxy here maybe or a custom httpclient ?
            .region(Region.EU_SOUTH_1)
            .build();
}

2

Answers


  1. You can easily build your own custom http client for the AWS SDK:

    @PostConstruct
    public void init() {
      final SdkHttpClient httpClient = ApacheHttpClient.builder()
                .proxyConfiguration(ProxyConfiguration.builder()
                .useSystemPropertyValues(true)
                .build())
           .build();
    
      lambdaClient = LambdaClient.builder().httpClient(httpClient).build();
    }
    
    Login or Signup to reply.
  2. This is documented in the AWS SDK Jave V2 Developer Guide. This topic contains information on how to configure the Apache-based HTTP client. See this topic:

    Configure the Apache-based HTTP client

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search