Skip to content
Snippets Groups Projects
Commit 9b1daabc authored by Takumaru Sekine's avatar Takumaru Sekine Committed by Yas Naoi
Browse files

Issue #3291878 by sekinet, yas, kumikoono, baldwinlouie: Fix the error with updating the VPC name

parent 80a97f9a
Branches
Tags
3 merge requests!1759Issue #3356778: Release 5.1.1,!1679Issue #3349074: Fix the OpenStack Project create and edit form in SPA that "Member" cannot be saved due to a validation error,!1607Issue #3343582: Add the function to preview OpenStack stack in the SPA
......@@ -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);
......
<?php
namespace Drupal\aws_cloud\Service;
/**
* Aws Service interface.
*/
interface AwsServiceInterface {
/**
* Resource tag prefix for AWS.
*
* @var string
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html
*/
public const AWS_RESOURCE_TAG_PREFIX = 'aws:';
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment