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

Rover import #352

Open
gevraud opened this issue Oct 19, 2023 · 1 comment
Open

Rover import #352

gevraud opened this issue Oct 19, 2023 · 1 comment

Comments

@gevraud
Copy link

gevraud commented Oct 19, 2023

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

@kamaltejaaol
Copy link

This should be your rover command

rover -lz /tf/caf/landingzones/caf_launchpad
-launchpad
-var-folder /tf/caf/configuration/test_tenant/level0/launchpad
-level level0
-env Dev
-a import 'module.launchpad.module.resource_groups["security"].azurerm_resource_group.rg' "/subscriptions/128251bd-17c1-476c-XXXXXXXXXXXX/resourceGroups/rg-XXXXXX-security-001"

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

No branches or pull requests

2 participants