aztfexport icon indicating copy to clipboard operation
aztfexport copied to clipboard

Documentation on -m/--batch option.

Open bourbonfgiles opened this issue 2 years ago • 2 comments

Hello,

I have a populated .aztfyResourceMapping.json file, how do I structure the command to use this file in batch mode?

Do I include the resource group and use --batch? i.e aztfy rg 'rg_name' --batch ".aztfyResourceMapping.json Or do I use -m i.e aztfy rg 'rg_name' --m ".aztfyResourceMapping.json" Or do I exclude i.e aztfy ".aztfyResourceMapping.json"

None of these options are working for me and I would prefer to use the non interactive mode as I had to cull a few items in the mapping.

Thanks.

bourbonfgiles avatar Aug 03 '22 13:08 bourbonfgiles

I've also tried aztfy rg --batch --resource-mapping ".aztfyResourceMapping.json" 'rg_name' to no success.

bourbonfgiles avatar Aug 03 '22 15:08 bourbonfgiles

@bourbonfgiles The aztfy will remove everything (by default) in the output directory. The .aztfyResourceMapping.json is generated at the output directory, and will be removed at the next run. The correct way of using that file is copy it to another place and then run in either interactive/noninteractive mode:

  • Interactively: aztfy rg 'rg_name' -m ".aztfyResourceMapping.json
  • Non-interactively: aztfy rg 'rg_name' --batch -m ".aztfyResourceMapping.json

magodo avatar Aug 04 '22 00:08 magodo

@magodo not sure if this might just be my own issue, but currently facing issues with running -m/-b together. Here: image

stemaMSFT avatar Aug 24 '22 22:08 stemaMSFT

@stemaMSFT Could you please try aztfy rg --batch -m ".aztfyResourceMapping.json" stema-aztfy-demo?

magodo avatar Aug 25 '22 00:08 magodo

When the file's in there, it says it can't write because the directory's not empty, and when the file isn't in there, it says it can't find the mapping file: image

stemaMSFT avatar Aug 26 '22 01:08 stemaMSFT

Yes, you would have to put the mapping file to other folder rather than the output directory.

magodo avatar Aug 26 '22 01:08 magodo

I realized we can run the command by adding --append, but this feels like it may be unintuitive given the error simply says "the directory is not empty." Any direction to point them towards the append flag if they want their HCL/state to exist in the same directory would help, such as "Error: the output directory " " is not empty. Use --append to write to the directory anyway, or to write to existing state." Thoughts?

stemaMSFT avatar Aug 26 '22 16:08 stemaMSFT

The output directory might be an existing TF workspace, that users forgot to add the --append option. It might also be a non-TF related directory. I think reading through the readme helps more.

magodo avatar Aug 27 '22 01:08 magodo

:wave:

Since we've not heard back here I'm going to close this issue for the moment. Feel free to reopen if still have questions.

magodo avatar Sep 28 '22 03:09 magodo