Skip to content
Snippets Groups Projects
Commit 32e3dae2 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 8127d03a
Branches
Tags
3 merge requests!1316Issue #3310263: Release 4.5.0,!1260Issue #3307397: Release 4.4.0,!1100Issue #3291878: Fix the error with updating the VPC name
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\aws_cloud\Form\Vpc; namespace Drupal\aws_cloud\Form\Vpc;
use Drupal\aws_cloud\Form\Ec2\AwsCloudContentForm; use Drupal\aws_cloud\Form\Ec2\AwsCloudContentForm;
use Drupal\aws_cloud\Service\AwsServiceInterface;
use Drupal\cloud\Traits\CloudContentEntityTrait; use Drupal\cloud\Traits\CloudContentEntityTrait;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
...@@ -132,7 +133,16 @@ class VpcEditForm extends AwsCloudContentForm { ...@@ -132,7 +133,16 @@ class VpcEditForm extends AwsCloudContentForm {
// Update tags. // Update tags.
$tag_map = []; $tag_map = [];
foreach ($entity->getTags() ?: [] as $tag) { 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); $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