PaloAltoNetworks / terraform-provider-prismacloudcompute

Terraform provider for Prisma Cloud Compute
https://registry.terraform.io/providers/PaloAltoNetworks/prismacloudcompute/latest
Mozilla Public License 2.0
24 stars 28 forks source link

Make Command Errors #21

Closed afdsioh234 closed 3 years ago

afdsioh234 commented 3 years ago

when I try to run the make command, I get the below errors - (I am running an amazon ec2 instance, not sure if I need to change the OS command or something along those lines, or change the makefile)

[ec2-user@ip-172-24-50-236 terraform-provider-prismacloudcompute]$ make install OS_ARCH=darwin_amd64 VERSION=0.0.2-test1 go build -o terraform-provider-prismacloudcompute prismacloudcompute/data_source_policies_compliance_host.go:7:2: no required modu le provides package github.com/paloaltonetworks/prisma-cloud-compute-go/policy/p olicyComplianceHost; to add it: go get github.com/paloaltonetworks/prisma-cloud-compute-go/policy/policy ComplianceHost prismacloudcompute/data_source_policies_runtime_host.go:7:2: no required module provides package github.com/paloaltonetworks/prisma-cloud-compute-go/policy/poli cyRuntimeHost; to add it: go get github.com/paloaltonetworks/prisma-cloud-compute-go/policy/policy RuntimeHost prismacloudcompute/data_source_policies_vulnerability_host.go:7:2: no required m odule provides package github.com/paloaltonetworks/prisma-cloud-compute-go/polic y/policyVulnerabilityHost; to add it: go get github.com/paloaltonetworks/prisma-cloud-compute-go/policy/policy VulnerabilityHost make: *** [build] Error 1

wfg commented 3 years ago

@afdsioh234 yes, if you're running on a Linux instance, you'll have to change the OS_ARCH:

make install OS_ARCH=linux_amd64 VERSION=0.0.1
afdsioh234 commented 3 years ago

I used the linux OS in there, I get this below error, do you know a way to resolve it? Thanks for all of your help!!

[ec2-user@ip-172-24-50-236 terraform-provider-prismacloudcompute]$ make install OS_ARCH=linux_amd64 VERSION=0.0.1 go build -o terraform-provider-prismacloudcompute prismacloudcompute/data_source_policies_compliance_host.go:7:2: no required module provides package github.com/paloaltonetworks/prisma-cloud-compute-go/policy/policyComplianceHost; to add it: go get github.com/paloaltonetworks/prisma-cloud-compute-go/policy/policyComplianceHost prismacloudcompute/data_source_policies_runtime_host.go:7:2: no required module provides package github.com/paloaltonetworks/prisma-cloud-compute-go/policy/policyRuntimeHost; to add it: go get github.com/paloaltonetworks/prisma-cloud-compute-go/policy/policyRuntimeHost prismacloudcompute/data_source_policies_vulnerability_host.go:7:2: no required module provides package github.com/paloaltonetworks/prisma-cloud-compute-go/policy/policyVulnerabilityHost; to add it: go get github.com/paloaltonetworks/prisma-cloud-compute-go/policy/policyVulnerabilityHost make: *** [build] Error 1

wfg commented 3 years ago

Try running git pull and rerun make install.

afdsioh234 commented 3 years ago

I tried it again and got the same result, oddly enough I tried it on Windows and got the same behavior, most install successfully except for those last few packages

wfg commented 3 years ago

Try the git pull and make install again on the EC2 instance. My latest commit should have fixed this.

afdsioh234 commented 3 years ago

Yeah, no longer receiving the errors on the make file anymore. Although when I try to initialize terraform, I'm getting the error - $ terraform init

Initializing the backend...

Initializing provider plugins...

Error: Invalid provider registry host

The host "paloaltonetworks.com" given in in provider source address "paloaltonetworks.com/prismacloud/prismacloudcompute" does not offer a Terraform provider registry.

wfg commented 3 years ago

Apologies--I've been changing things while you've been trying to do this.

Run the following in the repository's root directory:

make clean && make install OS_ARCH=linux_amd64 VERSION=0.0.1

You can make sure the binary is in the correct place by running this:

ls ~/.terraform.d/plugins/paloaltonetworks.com/prismacloud/prismacloudcompute/0.0.1/linux_amd64

If you see terraform-provider-prismacloudcompute in the ls output, you should be good to go.

afdsioh234 commented 3 years ago

Woot!! My terraform init worked on my linux test machine :) Now onto the next issue :) I grabbed the sample file and tried to do a terraform plan, I got the below error message -

[ec2-user@ip-172-24-50-236 terraform-provider-prismacloudcompute]$ terraform plan Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage.


Error: Post "/api/v1/authenticate": unsupported protocol scheme ""

on main.tf line 11, in provider "prismacloudcompute": 11: provider "prismacloudcompute" {

[ec2-user@ip-172-24-50-236 terraform-provider-prismacloudcompute]$

wfg commented 3 years ago

Can you share your sanitized creds.json and provider block in main.tf? It's this block:

provider "prismacloudcompute" {
  config_file = "creds.json"
}
afdsioh234 commented 3 years ago

sure, it is

This points to the local provider built according to the README.md.

terraform { required_providers { prismacloudcompute = { source = "paloaltonetworks.com/prismacloud/prismacloudcompute" version = "0.0.1" } } }

provider "prismacloudcompute" { config_file = "creds.json" }

And my creds.json File -

{ "url": "https://myurl.us-east-2.elb.amazonaws.com:8083", "username": "myusername", "password": "mypassword", "skip_ssl_cert_verification": true }

wfg commented 3 years ago

Your creds file's keys didn't get updated for some reason. See the key names in the latest example: https://github.com/PaloAltoNetworks/terraform-provider-prismacloudcompute/blob/9dc40182a03233410013228d9a9a094cb37b0617/examples/creds.json#L1-L6

afdsioh234 commented 3 years ago

When I do the terraform init, I started noticing the unauthenticated message - - Installed paloaltonetworks.com/prismacloud/prismacloudcompute v0.0.1 (unauthenticated)

Is there a specific directory the creds.json file must be in (its just in the same directory as the main.tf file), does it communicate over 8083? I opened up 8083 on my SG on my cluster to this ec2 host, but didn't seem to resolve it. Thanks!

wfg commented 3 years ago

The (unauthenticated) is because the provider is installed locally, not from the Terraform registry. It's unrelated to the authentication to your Console.

creds.json being in the same directory is fine and expected.

It communicates with whatever port you have specified in console_url. In your case, that'll be 8083.