Skip to content
Snippets Groups Projects

Issue #3291878: Fix the error with updating the VPC name

All threads resolved!
Compare and
2 files
+ 30
1
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -3,6 +3,7 @@
namespace Drupal\aws_cloud\Form\Vpc;
use Drupal\aws_cloud\Form\Ec2\AwsCloudContentForm;
use Drupal\aws_cloud\Service\AwsServiceInterface;
use Drupal\cloud\Traits\CloudContentEntityTrait;
use Drupal\Core\Form\FormStateInterface;
@@ -132,7 +133,16 @@ class VpcEditForm extends AwsCloudContentForm {
// Update tags.
$tag_map = [];
foreach ($entity->getTags() ?: [] as $tag) {
$tag_map[$tag['item_key']] = $tag['item_value'];
// If the tag name contains the prefix
// which is reserved for AWS, it will not be saved.
if (!str_contains($tag['item_key'], AwsServiceInterface::AWS_RESOURCE_TAG_PREFIX)) {
$tag_map[$tag['item_key']] = $tag['item_value'];
}
else {
$this->messenger()->addWarning($this->t('The tag @tag_name is preserved as it is because it contains the prefix <em>aws:</em>, which is reserved by AWS.', [
'@tag_name' => $tag['item_key'],
]));
}
}
$this->setTagsInAws($entity->getVpcId(), $tag_map);
Loading