protected override void ProcessRecord() { AmazonEC2 client = base.GetClient(); Amazon.EC2.Model.GetPasswordDataRequest request = new Amazon.EC2.Model.GetPasswordDataRequest(); request.InstanceId = this._InstanceId; Amazon.EC2.Model.GetPasswordDataResponse response = client.GetPasswordData(request); base.WriteObject(response.GetPasswordDataResult.PasswordData, true); }
public Tuple<string, string> WaitForPassword(string instanceId, string key) { var passwordRequest = new GetPasswordDataRequest { InstanceId = instanceId }; var response = _client.GetPasswordData(passwordRequest); if (string.IsNullOrWhiteSpace(response.PasswordData)) { Logger.Info("Password not ready, waiting 30 seconds..."); Thread.Sleep(30000); return WaitForPassword(instanceId, key); } return new Tuple<string, string>(instanceId, response.GetDecryptedPassword(key)); }
/// <summary> /// Initiates the asynchronous execution of the GetPasswordData operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetPasswordData operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<GetPasswordDataResponse> GetPasswordDataAsync(GetPasswordDataRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new GetPasswordDataRequestMarshaller(); var unmarshaller = GetPasswordDataResponseUnmarshaller.Instance; return InvokeAsync<GetPasswordDataRequest,GetPasswordDataResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Retrieves the encrypted administrator password for an instance running Windows. /// /// /// <para> /// The Windows password is generated at boot if the <code>EC2Config</code> service plugin, /// <code>Ec2SetPassword</code>, is enabled. This usually only happens the first time /// an AMI is launched, and then <code>Ec2SetPassword</code> is automatically disabled. /// The password is not generated for rebundled AMIs unless <code>Ec2SetPassword</code> /// is enabled before bundling. /// </para> /// /// <para> /// The password is encrypted using the key pair that you specified when you launched /// the instance. You must provide the corresponding key pair file. /// </para> /// /// <para> /// Password generation and encryption takes a few moments. We recommend that you wait /// up to 15 minutes after launching an instance before trying to retrieve the generated /// password. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the GetPasswordData service method.</param> /// /// <returns>The response from the GetPasswordData service method, as returned by EC2.</returns> public GetPasswordDataResponse GetPasswordData(GetPasswordDataRequest request) { var marshaller = new GetPasswordDataRequestMarshaller(); var unmarshaller = GetPasswordDataResponseUnmarshaller.Instance; return Invoke<GetPasswordDataRequest,GetPasswordDataResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the GetPasswordData operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetPasswordData operation on AmazonEC2Client.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetPasswordData /// operation.</returns> public IAsyncResult BeginGetPasswordData(GetPasswordDataRequest request, AsyncCallback callback, object state) { var marshaller = new GetPasswordDataRequestMarshaller(); var unmarshaller = GetPasswordDataResponseUnmarshaller.Instance; return BeginInvoke<GetPasswordDataRequest>(request, marshaller, unmarshaller, callback, state); }
IAsyncResult invokeGetPasswordData(GetPasswordDataRequest getPasswordDataRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new GetPasswordDataRequestMarshaller().Marshall(getPasswordDataRequest); var unmarshaller = GetPasswordDataResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// Initiates the asynchronous execution of the GetPasswordData operation. /// <seealso cref="Amazon.EC2.IAmazonEC2.GetPasswordData"/> /// </summary> /// /// <param name="getPasswordDataRequest">Container for the necessary parameters to execute the GetPasswordData operation on AmazonEC2.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetPasswordData /// operation.</returns> public IAsyncResult BeginGetPasswordData(GetPasswordDataRequest getPasswordDataRequest, AsyncCallback callback, object state) { return invokeGetPasswordData(getPasswordDataRequest, callback, state, false); }
/// <summary> /// <para>Retrieves the encrypted administrator password for an instance running Windows.</para> <para>The Windows password is only generated /// the first time an AMI is launched. It is not generated for rebundled AMIs or after the password is changed on an instance.</para> <para>The /// password is encrypted using the key pair that you specified when you launched the instance. You must provide the corresponding key pair /// file.</para> <para>Password generation and encryption takes a few moments. We recommend that you wait up to 15 minutes after launching an /// instance before trying to retrieve the generated password.</para> /// </summary> /// /// <param name="getPasswordDataRequest">Container for the necessary parameters to execute the GetPasswordData service method on /// AmazonEC2.</param> /// /// <returns>The response from the GetPasswordData service method, as returned by AmazonEC2.</returns> /// public GetPasswordDataResponse GetPasswordData(GetPasswordDataRequest getPasswordDataRequest) { IAsyncResult asyncResult = invokeGetPasswordData(getPasswordDataRequest, null, null, true); return EndGetPasswordData(asyncResult); }
/// <summary> /// <para>Retrieves the encrypted administrator password for an instance running Windows.</para> <para>The Windows password is only generated /// the first time an AMI is launched. It is not generated for rebundled AMIs or after the password is changed on an instance.</para> <para>The /// password is encrypted using the key pair that you specified when you launched the instance. You must provide the corresponding key pair /// file.</para> <para>Password generation and encryption takes a few moments. We recommend that you wait up to 15 minutes after launching an /// instance before trying to retrieve the generated password.</para> /// </summary> /// /// <param name="getPasswordDataRequest">Container for the necessary parameters to execute the GetPasswordData service method on /// AmazonEC2.</param> /// /// <returns>The response from the GetPasswordData service method, as returned by AmazonEC2.</returns> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public Task<GetPasswordDataResponse> GetPasswordDataAsync(GetPasswordDataRequest getPasswordDataRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new GetPasswordDataRequestMarshaller(); var unmarshaller = GetPasswordDataResponseUnmarshaller.GetInstance(); return Invoke<IRequest, GetPasswordDataRequest, GetPasswordDataResponse>(getPasswordDataRequest, marshaller, unmarshaller, signer, cancellationToken); }
internal GetPasswordDataResponse GetPasswordData(GetPasswordDataRequest request) { var task = GetPasswordDataAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// Initiates the asynchronous execution of the GetPasswordData operation. /// <seealso cref="Amazon.EC2.IAmazonEC2.GetPasswordData"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetPasswordData operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public async Task<GetPasswordDataResponse> GetPasswordDataAsync(GetPasswordDataRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new GetPasswordDataRequestMarshaller(); var unmarshaller = GetPasswordDataResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, GetPasswordDataRequest, GetPasswordDataResponse>(request, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
/// <summary> /// <para> Retrieves the encrypted administrator password for the instances running Windows. </para> <para><b>NOTE:</b> The Windows password is /// only generated the first time an AMI is launched. It is not generated for rebundled AMIs or after the password is changed on an instance. /// The password is encrypted using the key pair that you provided. </para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetPasswordData service method on /// AmazonEC2.</param> /// /// <returns>The response from the GetPasswordData service method, as returned by AmazonEC2.</returns> public GetPasswordDataResponse GetPasswordData(GetPasswordDataRequest request) { var task = GetPasswordDataAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
private Amazon.EC2.Model.GetPasswordDataResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.GetPasswordDataRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon EC2", "GetPasswordData"); try { #if DESKTOP return(client.GetPasswordData(request)); #elif CORECLR return(client.GetPasswordDataAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }