basti-app / basti

✨ Securely connect to RDS, Elasticache, and other AWS resources in VPCs with no idle cost
https://www.basti.app
MIT License
351 stars 18 forks source link

feat: resource tags as cli arguments #63

Closed BohdanPetryshyn closed 1 year ago

BohdanPetryshyn commented 1 year ago

Proposed Changes

This PR makes the basti init command tag all the created resources if instructed with any of the following CLI arguments:

  1. --tag - specifies a single tag as a name/value pair separated by an equal sign. Can be used multiple times
  2. --tags-file - specifies a JSON file that can contain multiple tags as key-value pairs of the root object.

If the --tag option is used multiple times with the same tag name, the latter usage will override the previous ones. The same applies to --tags-file. Tags specified with the --tag option will always override tags from files.

An example of a tags file:

{
  "any characters can be used here ++-@====": "value",
  "another-tag-here": "tag-value"
}

Example of the command usage:

basti init --tags-file test-tags.json --tags-file test-tags-2.json --tag "one more tag=value here"

Related Issue

50

Checklist

BohdanPetryshyn commented 1 year ago

Hey @DrFunk-n-stein! I covered all the resources Basti creates during the init command execution. However, I didn't manage to find a good example of an SCP that would enforce tags on all the resources in the AWS account. Is there a chance that you have an SCP definition to share so that I can test the solution?

BohdanPetryshyn commented 1 year ago

I published basti@1.4.0-alpha.1 so that you could test basti init --tag <tag=value> on some AWS accounts if you had a chance :)