public async Task <AssociateAddressResponse> AssociateAddressAsync(string instanceId, string publicIp) { var request = new AssociateAddressRequest(instanceId, publicIp); var response = await _cloudComputeClient.AssociateAddressAsync(request); return(response); }
/// <summary> /// Associate a public IP Address with an EC2 instance /// </summary> /// <param name="instanceId"></param> /// <param name="publicIpAddress"></param> public void AssociateIpAddress(string instanceId, string publicIpAddress) { var request = new AssociateAddressRequest { InstanceId = instanceId, PublicIp = publicIpAddress }; Client.AssociateAddress(request); }
/// <summary> /// This function associates an elastic IP to an EC2-Classic instance. /// </summary> /// <param name="InstanceId">The ID of the instance to be associated to the elastic IP</param> /// <param name="PublicId">The public ip ("Elastic IP" column in the AWS console)</param> public void AssociateElasticIpToClassicInstance(string InstanceId, string PublicId) { // Initializing request AssociateAddressRequest associateRequest = new AssociateAddressRequest(); associateRequest.InstanceId = InstanceId; associateRequest.PublicIp = PublicId; // Associating address & fetching response EC2client.AssociateAddress(associateRequest); }
/// <summary> /// Associates ElasticIP to Instance. /// </summary> /// <param name="instanceId">InstanceId</param> /// <param name="publicIpAddress">Elastic IP Address</param> public void SetElasticIpToInstance(String instanceId, String publicIpAddress) { if (!string.IsNullOrEmpty(instanceId) && !string.IsNullOrEmpty(publicIpAddress)) { AssociateAddressRequest request = new AssociateAddressRequest(); request.InstanceId = instanceId; request.PublicIp = publicIpAddress; _ec2.AssociateAddress(request); } }
/// <summary> /// Connect to an EC2 instance and associate a public IP address with it. /// </summary> protected override void AmazonExecute() { var request = new AssociateAddressRequest { InstanceId = this.InstanceId.Get(this.ActivityContext), PublicIp = this.PublicAddress.Get(this.ActivityContext) }; try { EC2Client.AssociateAddress(request); } catch (EndpointNotFoundException ex) { LogBuildMessage(ex.Message); } }
public void AssociateAddress(AssociateAddressRequest request) { Channel.AssociateAddress(request); }
/// <summary> /// Associate Address /// </summary> /// <param name="request">Associate Address request</param> /// <returns>Associate Address Response from the service</returns> /// <remarks> /// The AssociateAddress operation associates an elastic IP address with an /// instance. /// If the IP address is currently assigned to another instance, the IP address is /// assigned to the new instance. This is an idempotent operation. If you enter it /// more than once, Amazon EC2 does not return an error. /// /// </remarks> public AssociateAddressResponse AssociateAddress(AssociateAddressRequest request) { return(Invoke <AssociateAddressResponse>("AssociateAddressResponse.xml")); }
private void btnServerStart_Click(object sender, EventArgs e) { this.btnRefreshStatus.Enabled = false; this.btnServerStart.Enabled = false; this.btnServerStopAll.Enabled = false; //Stop any other ones running first... this.btnServerStopAll_Click(null, null); try { Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); string AMI = configuration.AppSettings.Settings["AMI"].Value; string IP = configuration.AppSettings.Settings["IPAddress"].Value; string type = configuration.AppSettings.Settings["InstanceType"].Value; string securityGroup = configuration.AppSettings.Settings["SecurityGroup"].Value; string urlToStartupPackage = "WZA_startupPackageURL=" + configuration.AppSettings.Settings["URLToStartupPackage"].Value; bool shouldUseStartupPackage = bool.Parse(configuration.AppSettings.Settings["ShouldUseStartupPackage"].Value); this.statusStripLbl.Text = "Starting a Wowza server - " + DateTime.Now.ToShortTimeString(); RunInstancesRequest req = new RunInstancesRequest(); req.EbsOptimized = false; req.ImageId = AMI; req.InstanceType = InstanceType.FindValue(type); req.MaxCount = 1; req.MinCount = 1; if (shouldUseStartupPackage) { byte[] encbuff = System.Text.Encoding.UTF8.GetBytes(urlToStartupPackage); req.UserData = Convert.ToBase64String(encbuff); } req.SecurityGroupIds = new List <string> { securityGroup }; RunInstancesResponse response = this.EC2.RunInstances(req); //wait AssociateAddressRequest addressReq = new AssociateAddressRequest(); Instance latestInstance = response.Reservation.Instances.OrderBy(o => o.LaunchTime).FirstOrDefault(); int giveUpCount = 0; while (giveUpCount < 20) { var statusRequest = new DescribeInstanceStatusRequest { InstanceIds = { latestInstance.InstanceId } }; var result = this.EC2.DescribeInstanceStatus(statusRequest); if (result.InstanceStatuses.Count > 0 && result.InstanceStatuses[0].InstanceState.Code == 16) { break; } this.GetStatus(false); giveUpCount++; int timeout = 0; while (timeout < 1000) { this.statusStripLbl.Text = "Waiting for the Wowza server to start- " + DateTime.Now.ToShortTimeString(); Application.DoEvents(); System.Threading.Thread.Sleep(100); timeout++; } } this.statusStripLbl.Text = "Associated the IP address " + IP + " to the new server - " + DateTime.Now.ToShortTimeString(); addressReq.InstanceId = latestInstance.InstanceId; addressReq.PublicIp = IP; AssociateAddressResponse addressResponse = this.EC2.AssociateAddress(addressReq); this.GetStatus(false); } catch (Exception ex) { this.statusStripLbl.Text = "Caught Exception: " + ex.Message; } this.btnRefreshStatus.Enabled = true; this.btnServerStart.Enabled = true; this.btnServerStopAll.Enabled = true; }