Container for the parameters to the UpdateEnvironment operation.

Updates the environment description, deploys a new application version, updates the configuration settings to an entirely new configuration template, or updates select configuration option values in the running environment.

Attempting to update both the release and configuration is not allowed and AWS Elastic Beanstalk returns an InvalidParameterCombination error.

When updating the configuration settings to a new template or individual settings, a draft configuration is created and DescribeConfigurationSettings for this environment returns two setting descriptions with different DeploymentStatus values.

Inheritance: AmazonElasticBeanstalkRequest
示例#1
0
    private void ChangeConfiguration(string minSize)
    {
        using (var client = Amazon.AWSClientFactory.CreateAmazonElasticBeanstalkClient(GetConf()))
        {
            Amazon.ElasticBeanstalk.Model.UpdateEnvironmentRequest req = new Amazon.ElasticBeanstalk.Model.UpdateEnvironmentRequest();
            req.EnvironmentName = "vielgi2-env";
            req.OptionSettings.Add(new Amazon.ElasticBeanstalk.Model.ConfigurationOptionSetting { Namespace = Options.Where(x => x.Name == "MinSize").Single().Namespace, OptionName = "MinSize", Value = minSize });

            var response = client.UpdateEnvironment(req);
        }
    }
 /// <summary>
 /// Initiates the asynchronous execution of the UpdateEnvironment operation.
 /// <seealso cref="Amazon.ElasticBeanstalk.AmazonElasticBeanstalk.UpdateEnvironment"/>
 /// </summary>
 /// 
 /// <param name="updateEnvironmentRequest">Container for the necessary parameters to execute the UpdateEnvironment operation on
 ///          AmazonElasticBeanstalk.</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 EndUpdateEnvironment
 ///         operation.</returns>
 public IAsyncResult BeginUpdateEnvironment(UpdateEnvironmentRequest updateEnvironmentRequest, AsyncCallback callback, object state)
 {
     return invokeUpdateEnvironment(updateEnvironmentRequest, callback, state, false);
 }
 IAsyncResult invokeUpdateEnvironment(UpdateEnvironmentRequest updateEnvironmentRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new UpdateEnvironmentRequestMarshaller().Marshall(updateEnvironmentRequest);
     var unmarshaller = UpdateEnvironmentResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
 /// <summary>
 /// <para> Updates the environment description, deploys a new application version, updates the configuration settings to an entirely new
 /// configuration template, or updates select configuration option values in the running environment. </para> <para> Attempting to update both
 /// the release and configuration is not allowed and AWS Elastic Beanstalk returns an <c>InvalidParameterCombination</c> error. </para> <para>
 /// When updating the configuration settings to a new template or individual settings, a draft configuration is created and
 /// DescribeConfigurationSettings for this environment returns two setting descriptions with different <c>DeploymentStatus</c> values. </para>
 /// </summary>
 /// 
 /// <param name="updateEnvironmentRequest">Container for the necessary parameters to execute the UpdateEnvironment service method on
 ///          AmazonElasticBeanstalk.</param>
 /// 
 /// <returns>The response from the UpdateEnvironment service method, as returned by AmazonElasticBeanstalk.</returns>
 /// 
 public UpdateEnvironmentResponse UpdateEnvironment(UpdateEnvironmentRequest updateEnvironmentRequest)
 {
     IAsyncResult asyncResult = invokeUpdateEnvironment(updateEnvironmentRequest, null, null, true);
     return EndUpdateEnvironment(asyncResult);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateEnvironment operation.
        /// <seealso cref="Amazon.ElasticBeanstalk.IAmazonElasticBeanstalk"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the UpdateEnvironment 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<UpdateEnvironmentResponse> UpdateEnvironmentAsync(UpdateEnvironmentRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new UpdateEnvironmentRequestMarshaller();
            var unmarshaller = UpdateEnvironmentResponseUnmarshaller.Instance;

            return InvokeAsync<UpdateEnvironmentRequest,UpdateEnvironmentResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        internal UpdateEnvironmentResponse UpdateEnvironment(UpdateEnvironmentRequest request)
        {
            var marshaller = new UpdateEnvironmentRequestMarshaller();
            var unmarshaller = UpdateEnvironmentResponseUnmarshaller.Instance;

            return Invoke<UpdateEnvironmentRequest,UpdateEnvironmentResponse>(request, marshaller, unmarshaller);
        }
  /// <summary>
  /// <para> Updates the environment description, deploys a new application version, updates the configuration settings to an entirely new
  /// configuration template, or updates select configuration option values in the running environment. </para> <para> Attempting to update both
  /// the release and configuration is not allowed and AWS Elastic Beanstalk returns an <c>InvalidParameterCombination</c> error. </para> <para>
  /// When updating the configuration settings to a new template or individual settings, a draft configuration is created and
  /// DescribeConfigurationSettings for this environment returns two setting descriptions with different <c>DeploymentStatus</c> values. </para>
  /// </summary>
  /// 
  /// <param name="updateEnvironmentRequest">Container for the necessary parameters to execute the UpdateEnvironment service method on
  ///           AmazonElasticBeanstalk.</param>
  /// 
  /// <returns>The response from the UpdateEnvironment service method, as returned by AmazonElasticBeanstalk.</returns>
  /// 
 public UpdateEnvironmentResponse UpdateEnvironment(UpdateEnvironmentRequest updateEnvironmentRequest) 
 {           
     IRequest<UpdateEnvironmentRequest> request = new UpdateEnvironmentRequestMarshaller().Marshall(updateEnvironmentRequest);
     UpdateEnvironmentResponse response = Invoke<UpdateEnvironmentRequest, UpdateEnvironmentResponse> (request, this.signer, UpdateEnvironmentResponseUnmarshaller.GetInstance());
     return response;
 }
 private Amazon.ElasticBeanstalk.Model.UpdateEnvironmentResponse CallAWSServiceOperation(IAmazonElasticBeanstalk client, Amazon.ElasticBeanstalk.Model.UpdateEnvironmentRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Elastic Beanstalk", "UpdateEnvironment");
     try
     {
         #if DESKTOP
         return(client.UpdateEnvironment(request));
         #elif CORECLR
         return(client.UpdateEnvironmentAsync(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;
     }
 }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.ElasticBeanstalk.Model.UpdateEnvironmentRequest();

            if (cmdletContext.ApplicationName != null)
            {
                request.ApplicationName = cmdletContext.ApplicationName;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.EnvironmentId != null)
            {
                request.EnvironmentId = cmdletContext.EnvironmentId;
            }
            if (cmdletContext.EnvironmentName != null)
            {
                request.EnvironmentName = cmdletContext.EnvironmentName;
            }
            if (cmdletContext.GroupName != null)
            {
                request.GroupName = cmdletContext.GroupName;
            }
            if (cmdletContext.OptionSetting != null)
            {
                request.OptionSettings = cmdletContext.OptionSetting;
            }
            if (cmdletContext.OptionsToRemove != null)
            {
                request.OptionsToRemove = cmdletContext.OptionsToRemove;
            }
            if (cmdletContext.PlatformArn != null)
            {
                request.PlatformArn = cmdletContext.PlatformArn;
            }
            if (cmdletContext.SolutionStackName != null)
            {
                request.SolutionStackName = cmdletContext.SolutionStackName;
            }
            if (cmdletContext.TemplateName != null)
            {
                request.TemplateName = cmdletContext.TemplateName;
            }

            // populate Tier
            var requestTierIsNull = true;

            request.Tier = new Amazon.ElasticBeanstalk.Model.EnvironmentTier();
            System.String requestTier_tier_Name = null;
            if (cmdletContext.Tier_Name != null)
            {
                requestTier_tier_Name = cmdletContext.Tier_Name;
            }
            if (requestTier_tier_Name != null)
            {
                request.Tier.Name = requestTier_tier_Name;
                requestTierIsNull = false;
            }
            System.String requestTier_tier_Type = null;
            if (cmdletContext.Tier_Type != null)
            {
                requestTier_tier_Type = cmdletContext.Tier_Type;
            }
            if (requestTier_tier_Type != null)
            {
                request.Tier.Type = requestTier_tier_Type;
                requestTierIsNull = false;
            }
            System.String requestTier_tier_Version = null;
            if (cmdletContext.Tier_Version != null)
            {
                requestTier_tier_Version = cmdletContext.Tier_Version;
            }
            if (requestTier_tier_Version != null)
            {
                request.Tier.Version = requestTier_tier_Version;
                requestTierIsNull    = false;
            }
            // determine if request.Tier should be set to null
            if (requestTierIsNull)
            {
                request.Tier = null;
            }
            if (cmdletContext.VersionLabel != null)
            {
                request.VersionLabel = cmdletContext.VersionLabel;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
        /// <summary>
        /// <para> Updates the environment description, deploys a new application version, updates the configuration settings to an entirely new
        /// configuration template, or updates select configuration option values in the running environment. </para> <para> Attempting to update both
        /// the release and configuration is not allowed and AWS Elastic Beanstalk returns an <c>InvalidParameterCombination</c> error. </para> <para>
        /// When updating the configuration settings to a new template or individual settings, a draft configuration is created and
        /// DescribeConfigurationSettings for this environment returns two setting descriptions with different <c>DeploymentStatus</c> values. </para>
        /// </summary>
        /// 
        /// <param name="updateEnvironmentRequest">Container for the necessary parameters to execute the UpdateEnvironment service method on
        /// AmazonElasticBeanstalk.</param>
        /// 
        /// <returns>The response from the UpdateEnvironment service method, as returned by AmazonElasticBeanstalk.</returns>
        /// 
        /// <exception cref="T:Amazon.ElasticBeanstalk.Model.InsufficientPrivilegesException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<UpdateEnvironmentResponse> UpdateEnvironmentAsync(UpdateEnvironmentRequest updateEnvironmentRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new UpdateEnvironmentRequestMarshaller();
            var unmarshaller = UpdateEnvironmentResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, UpdateEnvironmentRequest, UpdateEnvironmentResponse>(updateEnvironmentRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
		internal UpdateEnvironmentResponse UpdateEnvironment(UpdateEnvironmentRequest request)
        {
            var task = UpdateEnvironmentAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
        private async Task UpdateEnvironmentInternalAsync(Environment environment, List<ConfigurationOptionSetting> baseConfigurationOptionSettings)
        {
            using (var ebClient = new AmazonElasticBeanstalkClient(creds, configurationProvider.RegionEndpoint))
            {
                loggerProvider.GetLogger().Debug("Existing environment - updating...");
                var targetEnvironment = await GetEnvironmentDescription(environment, ebClient);

                if (targetEnvironment == null)
                {
                    var msg = "Error state: On environment update, next environment is null";
                    loggerProvider.GetLogger().Error(msg);
                    throw new ElasticBeanstalkDeployerException(msg);
                }

                loggerProvider.GetLogger().Debug("Updating environment.");
                var optionSettings = baseConfigurationOptionSettings;

                loggerProvider.GetLogger().Debug($"Updating environment: global option settings count - {optionSettings.Count}");
                var optionSettingsApp = GetAppSpecificUpdateConfigurationOptionSettings();
                optionSettings = InjectAppSpecificOptionSettings(optionSettings, optionSettingsApp);
                loggerProvider.GetLogger().Debug($"Updating environment: total option settings count - {optionSettings.Count}");

                var updateEnvironmentRequest = new UpdateEnvironmentRequest
                {
                    VersionLabel = configurationProvider.Version,
                    EnvironmentId = targetEnvironment.EnvironmentId,
                    OptionSettings = optionSettings
                };
                loggerProvider.GetLogger()
                    .Debug("Updating environment: {@updateEnvironmentRequest}", updateEnvironmentRequest);
                updateEnvironmentRequest.OptionSettings.ForEach(option => loggerProvider.GetLogger().Debug($"Updating environment option setting: namespace={option.Namespace} option name={option.OptionName}"));


                int tryCount = 0;
                bool isSuccessful = false;
                while (!isSuccessful)
                {
                    try
                    {
                        var updateEnvironmentResponse = await ebClient.UpdateEnvironmentAsync(updateEnvironmentRequest);
                        isSuccessful = true;
                        loggerProvider.GetLogger()
                            .Debug("Updated environment: {@updateEnvironmentResponse}", updateEnvironmentResponse);
                    }
                    catch (Exception ex)
                    {
                        loggerProvider.GetLogger().Debug($"Failed update with exception: {ex.Message}");
                        if (tryCount >= 5)
                        {
                            throw;
                        }
                        tryCount++;
                        await Task.Delay(TIME_BETWEEN_STATUS_CHECKS_IN_MILLISECONDS);
                    }
                }

                await WaitForEnvironmentCompletionAsync(targetEnvironment.EnvironmentId);
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateEnvironment operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the UpdateEnvironment operation on AmazonElasticBeanstalkClient.</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 EndUpdateEnvironment
        ///         operation.</returns>
        public IAsyncResult BeginUpdateEnvironment(UpdateEnvironmentRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new UpdateEnvironmentRequestMarshaller();
            var unmarshaller = UpdateEnvironmentResponseUnmarshaller.Instance;

            return BeginInvoke<UpdateEnvironmentRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
        IAsyncResult invokeUpdateEnvironment(UpdateEnvironmentRequest request, AsyncCallback callback, object state, bool synchronized)
        {
            var marshaller = new UpdateEnvironmentRequestMarshaller();
            var unmarshaller = UpdateEnvironmentResponseUnmarshaller.Instance;

            return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer);
        }
        /// <summary>
        /// <para> Updates the environment description, deploys a new application version, updates the configuration settings to an entirely new
        /// configuration template, or updates select configuration option values in the running environment. </para> <para> Attempting to update both
        /// the release and configuration is not allowed and AWS Elastic Beanstalk returns an <c>InvalidParameterCombination</c> error. </para> <para>
        /// When updating the configuration settings to a new template or individual settings, a draft configuration is created and
        /// DescribeConfigurationSettings for this environment returns two setting descriptions with different <c>DeploymentStatus</c> values. </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the UpdateEnvironment service method on
        /// AmazonElasticBeanstalk.</param>
        /// 
        /// <returns>The response from the UpdateEnvironment service method, as returned by AmazonElasticBeanstalk.</returns>
        /// 
        /// <exception cref="T:Amazon.ElasticBeanstalk.Model.InsufficientPrivilegesException" />
		public UpdateEnvironmentResponse UpdateEnvironment(UpdateEnvironmentRequest request)
        {
            var task = UpdateEnvironmentAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
        /// <summary>
        /// <para> Updates the environment description, deploys a new application version, updates the configuration settings to an entirely new
        /// configuration template, or updates select configuration option values in the running environment. </para> <para> Attempting to update both
        /// the release and configuration is not allowed and AWS Elastic Beanstalk returns an <c>InvalidParameterCombination</c> error. </para> <para>
        /// When updating the configuration settings to a new template or individual settings, a draft configuration is created and
        /// DescribeConfigurationSettings for this environment returns two setting descriptions with different <c>DeploymentStatus</c> values. </para>
        /// </summary>
        /// 
        /// <param name="updateEnvironmentRequest">Container for the necessary parameters to execute the UpdateEnvironment service method on
        /// AmazonElasticBeanstalk.</param>
        /// 
        /// <returns>The response from the UpdateEnvironment service method, as returned by AmazonElasticBeanstalk.</returns>
        /// 
        /// <exception cref="T:Amazon.ElasticBeanstalk.Model.InsufficientPrivilegesException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public async Task<UpdateEnvironmentResponse> UpdateEnvironmentAsync(UpdateEnvironmentRequest updateEnvironmentRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new UpdateEnvironmentRequestMarshaller();
            var unmarshaller = UpdateEnvironmentResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, UpdateEnvironmentRequest, UpdateEnvironmentResponse>(updateEnvironmentRequest, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }