该错误是由于在 CloudFormation 模板中使用了相同的标签键名。为避免此错误,应确保在资源标记中使用唯一的键名。以下是一个示例,其中使用了相同的键名'Environment”:
Resources:
NeptuneCluster:
Type: 'AWS::Neptune::DBCluster'
Properties:
DBClusterIdentifier: my-neptune-cluster
MasterUsername: admin
MasterUserPassword: password
# Duplicate tag key causing the error below
Tags:
- Key: Environment
Value: Dev
- Key: Environment
Value: Prod
为了解决此问题,需要更改标签键名使其不同:
Resources:
NeptuneCluster:
Type: 'AWS::Neptune::DBCluster'
Properties:
DBClusterIdentifier: my-neptune-cluster
MasterUsername: admin
MasterUserPassword: password
# Unique tag key names
Tags:
- Key: Environment
Value: Dev
- Key: EnvironmentType
Value: Prod
'Environment”更改为'EnvironmentType”,使每个标签键名都是唯一的,这样就可以避免报错了。