2

everyone I am new to AWS SDK. I am trying to create an EKS cluster from my java application.

I have used this eksctl create cluster command to create a cluster and I have also done this by using cluster templates.

I have tried to use AWS SDK to create clusters but that didn't work and have no idea how to go with it. If anyone of you has a good sample code or explanation of using AWS SDK for creating a cluster using cluster template or anything which can help me to reach there would be helpful.

1 Answers1

3

here i provide you a sample of Java code. i wish its serve your purpose on eks cluster creation:

    String accessKey = "your_aws_access_key";
    String secretKey = "your_aws_secret_key";

    AWSCredentials credentials = new BasicAWSCredentials (accessKey, secretKey);
    ClientConfiguration clientConfig = new ClientConfiguration ();
    clientConfig.setProtocol (Protocol.HTTPS);
    clientConfig.setMaxErrorRetry (DEFAULT_MAX_ERROR_RETRY);
    clientConfig.setRetryPolicy (new RetryPolicy (PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION,
            DEFAULT_BACKOFF_STRATEGY, DEFAULT_MAX_ERROR_RETRY, false));

    AmazonEKS amazonEKS = AmazonEKSClientBuilder.standard ()
            .withClientConfiguration (clientConfig)
            .withCredentials (new AWSStaticCredentialsProvider (credentials))
            .withRegion ("us-east-1") //replace your region name
            .build ();
    CreateClusterResult eksCluster = amazonEKS.createCluster (
            new CreateClusterRequest ().withName ("cluster-name") //with other param
    );
Jahadul Rakib
  • 476
  • 1
  • 5
  • 19