ansible-collections / ansible-collections/community.general

Terraform: better diff on check mode (show the hostname)

Open
#8,564 2 comments 0 reactions 0 assignees View on GitHub
feature module plugins
Dominant language
Python
Stars
1.1k
Forks
1.8k
Avg merge
19h 40m
Merged PRs (30d)
141

Description

### Summary

Hey,
thank you for this nice project, I think it is very useful.

From #7896 the terraform module now display a nice diff for the check mode,
it is nice, but if you compare to the terraform plan output you can see we are dropping the hostname of the element:
```
...
Terraform will perform the following actions:

# module.containers.proxmox_virtual_environment_container.container["hidden_hostname_1"] will be updated in-place
~ resource "proxmox_virtual_environment_container" "container" {
id = "104"
tags = [
"ct",
"pp",
]
# (7 unchanged attributes hidden)

~ cpu {
~ cores = 4 -> 3
# (2 unchanged attributes hidden)
}

~ memory {
~ swap = 8192 -> 1024
# (1 unchanged attribute hidden)
}

# (5 unchanged blocks hidden)
}

Plan: 0 to add, 1 to change, 0 to destroy.
```

And this is the output, when running throught the terraform module in check_mode:
```
...
TASK [Apply Terraform plan] ****************************************************************************************************************************************************************
--- before
+++ after
@@ -7,7 +7,7 @@
"cpu": [
{
"architecture": "amd64",
- "cores": 4,
+ "cores": 3,
"units": 1024
}
],
@@ -60,7 +60,7 @@
"memory": [
{
"dedicated": 50144,
- "swap": 8192
+ "swap": 1024
}
],
"mount_point": [],

changed: [localhost]
```

So it would be nice addition to get the hidden_hostname_1 as we can get from terraform command itself,
would you be interested for a patch around this ?

### Issue Type

Feature Idea

### Component Name

terraform

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Start with the Terraform module's check-mode output and the code that builds its diff, then compare that context with the hostname shown by Terraform plan. The change is complete when the relevant hostname, such as hidden_hostname_1, appears in the check-mode diff output alongside the existing changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, terraform
Domain
devops
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.