Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tfplan should use resource address for id field #702

Closed
xortim opened this issue Apr 27, 2021 · 1 comment · Fixed by #825
Closed

tfplan should use resource address for id field #702

xortim opened this issue Apr 27, 2021 · 1 comment · Fixed by #825
Assignees
Labels

Comments

@xortim
Copy link
Contributor

xortim commented Apr 27, 2021

  • terrascan version: 1.5.0
  • Operating System: macOS

Description

I'm attempting to identify which resources are in violation of policies. Being able to identify resources in the same or similar way as Terraform's own output and internal representation of these resources would be helpful. So instead of null_resource.this we would get module.example.null_resource.this. It would be helpful to have a better understanding of how the different resource representations within the plan file are merged by terrascan.

What I Did

./main.tf

resource "null_resource" "this" {
  provisioner "local-exec" {
    command = "echo 'Hello'"
  }
}

./example/main.tf

module "example" {
  source "../"
}

terrascan scan -i tfplan --config-only -o json

{
  "null_resource": [
    {
      "id": "null_resource.this",
      "name": "this",
      "source": "",
      "line": 0,
      "type": "null_resource",
      "config": {
        "triggers": null
      },
      "skip_rules": null
    }
  ]
}

In the plan file, these have the desired attribute under planned_values and resource_changes:

{
  "format_version": "0.1",
  "terraform_version": "0.14.10",
  "planned_values": {
    "root_module": {
      "child_modules": [
        {
          "resources": [
            {
              "address": "module.example.null_resource.this",
...
  "resource_changes": [
    {
      "address": "module.example.null_resource.this",
...
@kanchwala-yusuf
Copy link
Contributor

Hi @xortim ,
I have tried to fix this issue as part of #825, please let me know if this helps! You can try out the fix in the latest master or wait for a release.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants