I have been working with AWS toolkit for some time in last week. I prepared some tools to automate our infra team tasks and for our internal development and testing purpose.
Here I will show you how to register/de-register EC2 instances with Elastic Load Balancer programmatically using AWS .NET toolkit.
First get your awsSecretAccessKey and awsAccessKey,
Note: The user account you use here for Secret Key and Access Key must have full access to EC2 service of AWS
Create EC2 Client,
Make sure you specify correct RegionEndPoint where your EC2 instances exist. Here I have used USWest2 region end point.
Here I will show you how to register/de-register EC2 instances with Elastic Load Balancer programmatically using AWS .NET toolkit.
First get your awsSecretAccessKey and awsAccessKey,
1 2 | string awsSecretAccessKey = ConfigurationManager.AppSettings["awsSecretAccessKey"]; string awsAccessKey = ConfigurationManager.AppSettings["awsAccessKey"]; |
Note: The user account you use here for Secret Key and Access Key must have full access to EC2 service of AWS
Create EC2 Client,
1 | var client = AWSClientFactory.CreateAmazonElasticLoadBalancingClient(awsAccessKey, awsSecretAccessKey, RegionEndpoint.USWest2);
|
Make sure you specify correct RegionEndPoint where your EC2 instances exist. Here I have used USWest2 region end point.