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

Unable to import GCE Instance #156

Closed
Red-Five opened this issue Jul 30, 2019 · 7 comments
Closed

Unable to import GCE Instance #156

Red-Five opened this issue Jul 30, 2019 · 7 comments
Labels
bug Something isn't working GCP

Comments

@Red-Five
Copy link

Unable to import instances.
Using latest code base (cloned July 29th)

Is it necessary to specify zone or just region ?
I see some examples using --zone however that no longer appears to be a valid flag.
(I am able to import networks, firewalls ok, so the basic setup seems OK)

Test command
terraformer plan google --resources=instances --projects=deploy-247818 --regions=us-central1

redfivegcp@dev:~/tfimport$ cat generated/google/deploy-247818/terraformer/us-central1/plan.json
{
"Version": "v0.7.6",
"Provider": "google",
"Options": {
"Resources": [
"instances"
],
"PathPattern": "{output}/{provider}/deploy-247818/{service}/us-central1/",
"PathOutput": "generated",
"State": "local",
"Bucket": "",
"Profile": "",
"Zone": "",
"Regions": [
"us-central1"
],
"Projects": [
"deploy-247818"
],
"Connect": true,
"Filter": []
},
"Args": [
"us-central1",
"deploy-247818"
],
"ImportedResource": {
"instances": null
}
}

@sergeylanzman
Copy link
Collaborator

I checked Test command in my project and it's working.
You see in log payload your instances?
You have instance in this region?

@Red-Five
Copy link
Author

Red-Five commented Jul 31, 2019

@sergeylanzman Thanks. (Possibly user setup or permissions error on my end.)
I have a VM in us-central1-a
Where can I check the logs? Is there a debug flag I can turn on?

I tried find . -name *.log but didn't find anything that looked applicable to my command run
I also ran terraformer plan google --help though don't see a debug flag.

In case terraform/provider versions are relevant:
Terraform v0.12.5

  • provider.google v2.11.0

@sergeylanzman
Copy link
Collaborator

it's stdout
look like

terraformer plan google --resources=instances --projects=project1 --regions=europe-west1
2019/07/31 20:47:56 google importing project project1 region europe-west1
2019/07/31 20:47:58 google importing... instances
2019/07/31 20:48:01 Refreshing state... google_compute_instance.gke-c20-28-pool-bef8611e-js5x

@rommi4
Copy link

rommi4 commented Aug 6, 2019

same issue here

both terraform 0.11.14 / 0.12.6 with terraformer v0.7.7 (and below) don't import GCE instances:
terraformer plan generates this json:

{
	"Version": "v0.7.7",
	"Provider": "google",
	"Options": {
		"Resources": [
			"instances"
		],
		"PathPattern": "{output}/{provider}/myproj/{service}/europe-west4/",
		"PathOutput": "generated",
		"State": "local",
		"Bucket": "",
		"Profile": "",
		"Zone": "",
		"Regions": [
			"europe-west4"
		],
		"Projects": [
			"myproj"
		],
		"Connect": true,
		"Filter": []
	},
	"Args": [
		"europe-west4",
		"myproj"
	],
	"ImportedResource": {
		"instances": null
	}
}

but there are instances in that project in Region (europe-west4) or Zone (europe-west4-b):

gcloud compute instances list --project myproj
NAME                ZONE               MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP     STATUS
--------------      asia-southeast1-b  n1-standard-2               -----------  -----------     RUNNING
--------------      europe-west3-b     n1-standard-2               -----------  -----------     TERMINATED
alfa                europe-west4-b     n1-standard-2               -----------  -----------     RUNNING
fr-localization-01  europe-west4-b     n1-standard-2               -----------  -----------     RUNNING

@Red-Five
Copy link
Author

Red-Five commented Aug 6, 2019

@sergeylanzman It seems other people are able to re-create the issue. Are Waze SRE team able to assign someone to this issue?

@rommi4
Copy link

rommi4 commented Aug 7, 2019

I suppose that it is because of behavior stated in issue #160 : terraformer gets instances from one zone inside region. In my example it iterates through europe-west4 c->b->a

   GET https://www.googleapis.com/compute/v1/projects/myproj/zones/europe-west4-c/instances?alt=json&prettyPrint=false HTTP/2.0
       ← 200 application/json 137b 472ms
   GET https://www.googleapis.com/compute/v1/projects/myproj/zones/europe-west4-b/instances?alt=json&prettyPrint=false HTTP/2.0
       ← 200 application/json 1k 490ms
>> GET https://www.googleapis.com/compute/v1/projects/myproj/zones/europe-west4-a/instances?alt=json&prettyPrint=false HTTP/2.0
       ← 200 application/json 137b 471ms

and last zone (a) doesn't have any instances - so nothing is imported

@sergeylanzman sergeylanzman added bug Something isn't working GCP labels Aug 7, 2019
@sergeylanzman
Copy link
Collaborator

Thank you for report! fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GCP
Projects
None yet
Development

No branches or pull requests

3 participants