diff --git a/modules/cloud_service_providers/aws_cloud/aws_cloud.module b/modules/cloud_service_providers/aws_cloud/aws_cloud.module index d6fa66c0fd1b9cd745e25e3155b310687b41470e..8eff7421018ff25a69edc1b24a47cf9627f92a39 100644 --- a/modules/cloud_service_providers/aws_cloud/aws_cloud.module +++ b/modules/cloud_service_providers/aws_cloud/aws_cloud.module @@ -2548,6 +2548,7 @@ function aws_cloud_server_template_field_orders($include_name = TRUE) { */ function aws_cloud_form_cloud_config_aws_cloud_edit_form_alter(array &$form, FormStateInterface $form_state, $form_id) { $form['#validate'][] = 'aws_cloud_form_cloud_config_aws_cloud_credentials_validate'; + $form['#validate'][] = 'aws_cloud_form_cloud_config_aws_cloud_check_iam_permissions_validate'; aws_cloud_form_cloud_config_aws_cloud_form_common_alter($form, $form_state, $form_id); // Location fieldset is unnecessary for edit form. @@ -2971,7 +2972,10 @@ function aws_cloud_form_cloud_config_aws_cloud_check_iam_permissions_validate(ar return; } - $regions_selected = array_values(array_filter($form_state->getValue('regions'))); + $regions_selected = $form_state->getFormObject()->getEntity()->isNew() + ? array_values(array_filter($form_state->getValue('regions'))) + : [$form_state->getValue('field_region')[0]['value']]; + $account = \Drupal::currentUser(); foreach ($regions_selected ?: [] as $region) {