Skip to content

aws rds add-tags-to-resource does not records the tags

0

Hello I'm using the cli command aws rds add-tags-to-resource from a json file to import tags. The command does not report error, runs ok, but no tags are written.. The instance target is a Rds replica. Maybe I miss something?

aws rds add-tags-to-resource --resource-name arn:aws:rds:us-east-1:name:db:instance-ro- --tags file://tags.json

And the file is like:

"{ "Tags": [ { "Key": "domain-name", "Value": "some-domain" }, { "Key": "owner", "Value": "some-owner" }, .... ] } "

asked 2 years ago383 views

4 Answers
2

Hi,

You would need to use the parameter "cli-input-json" to input the json file to add the tag.

Below is sample command to add tag to the DB resource using the sample file - tags.json

aws rds add-tags-to-resource --resource-name arn:aws:rds:us-east-1:xxxxxxxxxxxx:db:mysampleDB --cli-input-json file://tags.json 
$cat tags.json 
{
  "Tags": [
    {
      "Key": "Environment",
      "Value": "Test"
    },
    {
      "Key": "Project",
      "Value": "Testing"
    }
  ]
}

Reference - https://docs.aws.amazon.com/cli/latest/reference/rds/add-tags-to-resource.html

AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

1

Hi,

Did you check the absence of tags by both AWS CLI and AWS console ?

Did you also try the so-called short-hand syntax document here: https://docs.aws.amazon.com/cli/latest/reference/rds/add-tags-to-resource.html

If they are really missing after all this trial, then, you should open a ticket to our Support via the AWS console of your account: you may well face a bug!

Best,

Didier

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

1

Hello.

Please change the contents of the "tags.json" file as follows.

[{ "Key": "domain-name", "Value": "some-domain" }, { "Key": "owner", "Value": "some-owner" }]

As described in the document below, the json for the "--tags" option is as follows.
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/rds/add-tags-to-resource.html

[
  {
    "Key": "string",
    "Value": "string"
  }
  ...
]
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

0

Works great ! The --cli-input-json parameter makes the difference. The wrong one I've used it comes from the ec2 command..

Thanks!

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.