aztfmod / aztfmod/rover

Rover import

Open
#352 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
176
Forks
147
PR merge metrics
No merged PRs in 30d

Description

Hello,

I have some existing ad groups that were created manually by a collegue and I want to import them into my tfstate.

I did this command

```
➜ caf git:(master) ✗ rover -lz /tf/caf/landingzones/caf_solution/ \
-tfstate_subscription_id xxx \
-tfstate caf_identity.tfstate \
-env test \
-level level2 \
-a import 'module.solution.module.azuread_groups["imported_group"].azuread_group.group' 'group_id_in_azure'
```

but it gives me this error :
```
Terraform import return code: 1
Terraform returned errors:

│ Error: Invalid provider configuration

│ on /tf/caf/landingzones/caf_solution/main.tf line 87:
│ 87: provider "azurerm" {

│ The configuration for
│ provider["registry.terraform.io/hashicorp/azurerm"].vhub depends on values
│ that cannot be determined until apply.


│ Error: Invalid count argument

│ on /home/vscode/.terraform.cache/prodinfra/rover_jobs/20231018080421583089290/modules/solution/locals.tf line 2, in resource "random_string" "prefix":
│ 2: count = try(var.global_settings.prefix, null) == null ? 1 : 0

│ The "count" value depends on resource attributes that cannot be determined
│ until apply, so Terraform cannot predict how many instances will be
│ created. To work around this, use the -target argument to first apply only
│ the resources that the count depends on.
```

Should I use custom terraform like this :
`import.tf`
```
import {
id = “i-abcd1234”
to = module.solution.module.azuread_groups["imported_group"].azuread_group.group
}
```

maybe could you provide a guidance to import resources with rover + Azure Terraform SRE ?

Regards

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the shown rover import command, then inspect landingzones/caf_solution/main.tf around the azurerm provider and the referenced modules/solution/locals.tf count expression. Compare this failure with the proposed import.tf configuration and existing Rover import documentation or tests. Done means the supported import workflow and the cause of these Terraform planning errors are established and documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, shell, terraform
Domain
cloud, devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.