terraspace icon indicating copy to clipboard operation
terraspace copied to clipboard

Not Parsing config.tags From AzureRM Plugin Config File

Open biodrone opened this issue 2 years ago • 0 comments

Checklist

  • [x] Upgrade Terraspace: Are you using the latest version of Terraspace? This allows Terraspace to fix issues fast. There's an Upgrading Guide: https://terraspace.cloud/docs/misc/upgrading/
  • [x] Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.boltops.com
  • [x] Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.

My Environment

Software Version
Operating System WSL Ubuntu 22.04.01 LTS
Terraform 1.3.4
Terraspace 2.2.2
Ruby 3.1.2p20

Expected Behaviour

The below config added to config/plugins/azurerm.rb should result in the listed tags being created for each resource. I've tested this with a fresh project just to make nothing from my current one was causing issues and it seems to be reproducible off the bat.

Relevant docs page: https://terraspace.cloud/docs/plugins/azurerm/

TerraspacePluginAzurerm.configure do |config|
    config.auto_create = true
    config.resource_group.update_existing = true
    config.storage_account.allow_blob_public_access = false
    config.storage_account.is_versioning_enabled = true
    
    config.tags = {env: Terraspace.env, terraspace: true}
end

Current Behavior

Doesn't add any tags at all. Tested manually adding tags which works as expected but the point of this config is to not have to repeat the tag block for every resource... I've tried a bunch of different formats for the tags, which is how I can tell it is definitely reading the file (when I give it invalid syntax it break as expected) but it just doesn't seem to be adding tags for whatever reason.

Step-by-step reproduction instructions

  • start a new project with the azurerm plugin, configure creds etc
  • add the code above to the config/plugins/azurerm.rb file
  • run terraspace up demo -y and validate in the plan that no tags are showing
  • go to azure and also validate that the created resources do not have any tags either

Code Sample

See expected behavior above

Solution Suggestion

The tags need to be parsed and added to resources when created, as per the docs. I may alternatively just be doing something stupid and missing a compilation step before hand. If that's the case, I didn't see anything relevant anywhere in the docs so something should probably be added to clarify that extra step.

Happy to submit a PR if that documentation needs updating but I'm not fluent in Ruby so it's difficult to dig through and figure out why the tags might not be getting parsed.

biodrone avatar Nov 17 '22 16:11 biodrone