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

Files into storage are also listed in state file #274

Closed
farreciado opened this issue Oct 26, 2022 · 4 comments
Closed

Files into storage are also listed in state file #274

farreciado opened this issue Oct 26, 2022 · 4 comments
Labels
question Further information is requested

Comments

@farreciado
Copy link

farreciado commented Oct 26, 2022

Hello, I ran the tool to get a RG (running in production) resources file, and got like 3000 entries. As there actually were like 20-30 resources in that RG...I checked what happened and found thousands of media files (such mp4) present in an storage. Is there a way to avoid listing the resources inside an storage? Are the files inside storage considered resources? Thanks for helping and congrats for the tool. BTW process took really long, I wish with paralellism the execution time lowers!

@farreciado farreciado changed the title Files into storage are also listed Files into storage are also listed in resources file (QUESTION) Oct 26, 2022
@farreciado farreciado changed the title Files into storage are also listed in resources file (QUESTION) Files into storage are also listed in state file (QUESTION) Oct 26, 2022
@magodo
Copy link
Collaborator

magodo commented Oct 27, 2022

@farreciado Assuming you are seeing thousands of azurerm_storage_blob, then yes they are also counted as valid resoruces in the RG. If you don't want to export them, you can modify the resource mapping file (named aztfyResourceMapping.json) to remove those entries and then run aztfy map [options] <path2mappingFile>.

The parallel import feature is implemeneted in #260 and will be available in the next release.

@magodo magodo added the question Further information is requested label Oct 27, 2022
@farreciado
Copy link
Author

Thanks for the comments. Editing files to make such a huge change (hundreds of entries) is something I wish to avoid due to human errors, but currently there's no other choice.

This is how entries look like (Names obfuscated). Why the MP4 video files are listed?

{
  "mode": "managed",
  "type": "azurerm_media_asset",
  "name": "res-1539",
  "provider": "provider[\"registry.terraform.io/hashicorp/azurerm\"]",
  "instances": [
    {
      "schema_version": 0,
      "attributes": {
        "alternate_id": "02myVideo.mp4",
        "container": "asset-9999999-1fdc-46af-ffff-b1cc32b32349",
        "description": "final asset",
        "id": "/subscriptions/SUBSCRIPTION_ID/resourceGroups/MYRG/providers/Microsoft.Media/mediaservices/PROJECT/assets/02myVideo.mp4",
        "media_services_account_name": "MYRG",
        "name": "02myVideo.mp4",
        "resource_group_name": "MYRG",
        "storage_account_name": "STORAGENAME",
        "timeouts": {
          "create": null,
          "delete": null,
          "read": null,
          "update": null
        }
      },
      "sensitive_attributes": [],
      "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxODAwMDAwMDAwMDAwLCJkZWxldGUiOjE4MDAwMDAwMDAwMDAsInJlYWQiOjMwMDAwMDAwMDAwMCwidXBkYXRlIjoxODAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIwIn0="
    }
  ]
},

@magodo
Copy link
Collaborator

magodo commented Oct 28, 2022

@farreciado That is because aztfy firstly recursively list all the Azure resources in the RG you've specified, where these assets are also listed. Then it maps these resources to the TF resource via its Azure resource id, and deduce the correct TF resource type, in this case it is azurerm_media_asset.

If you simply want to ignore the azurerm_media_asset resources, you can run following jq command:

cat aztfyResourceMapping.json | jq 'with_entries(select(.value.resource_type != "azurerm_media_asset"))'

@farreciado farreciado changed the title Files into storage are also listed in state file (QUESTION) Files into storage are also listed in state file Oct 28, 2022
@magodo
Copy link
Collaborator

magodo commented May 24, 2023

@farreciado Since we haven't get further response from you, I'll mark this issue as closed for now. Feel free to reopen it if the issue still remains.

@magodo magodo closed this as completed May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants