erikvanbrakel / terraform-provider-sumologic

This project is done. It has been integrated into https://github.com/SumoLogic/sumologic-terraform-provider
MIT License
13 stars 9 forks source link

The provider is not saving its state #27

Closed shinitiandrei closed 7 years ago

shinitiandrei commented 7 years ago

Hi! @erikvanbrakel

I've been using your provider for a while now and everything is working really good! 😃 I just wanna ask you if you're planning to add the function that saves the state of Sumologic. For example, I just created a new Collector with a Polling Source and they're created successfully. However, any changes made in my terraform code, in sumologic resources, are not saved in the terraform.tfstate. So, whenever I run terraform plan it says that there are no changes in my code.

Another question, are you also planning to make a pull request to terraform to add this provider in a near future?

Thank you again!

erikvanbrakel commented 7 years ago

I'm not sure what you mean. I just tried this:

resource "sumologic_collector" "col" {
    name = "My-collector-1"
    category = ""
    description = "a"
}

resource "sumologic_http_source" "source" {
    name = "http"
    category = "source/category"
    collector_id = "${sumologic_collector.col.id}"
}

This creates the collector and source. When I change attributes, such as category on the http source, it correctly states that resources have to be modified: image

Could you provide an example template?

About getting this into the main terraform codebase... Probably, if there's a bit more demand. Gives me some time to polish as well ;-)

shinitiandrei commented 7 years ago

Yeap, you're right! Whenever I change my terraform code, it says what has changed. What I wonder is, for example, I delete my http_source within the Collector in Sumologic console (I go to the console and delete it manually), when I run "terraform plan" it doesn't compare with Sumologic and returns that everything hasn't changed. So apparently it just compares with its local saved state (terraform.tfstate). Is that correct?

Cool! it will probably have 😃, Terraform is being advertised really well here haha

shinitiandrei commented 7 years ago

Oh sorry @erikvanbrakel, let me rectify.... The resource "sumologic_collector" works perfect, it compares the state of your code with Sumologic's server and your local code. However, I tested both sumologic_http_source and sumologic_polling_source and they don't seem to compare with the server, only with your local file (terraform.trstate). I'm testing changes made in Sumo's server directly and after I'm running terraform plan. So sumologic_http_source just validates the name attribute with the server, but the rest is not compared with the Sumo's server. And sumologic_polling_source doesn't validate anything on the server-side.

I'm not really good with Golang but I'll do my best to make PR with the changes, as you seen quite busy with others features. 😛 Thanks again and sorry for my lack of testing !!

erikvanbrakel commented 7 years ago

I'm not very experienced writing Golang either, I just look at the terraform built-in providers and try to copy the style ;-)

I'm assuming this is a problem with the resourceSumologic*Read methods. Compare: https://github.com/erikvanbrakel/terraform-provider-sumologic/blob/master/provider/resource_sumologic_collector.go#L45 and https://github.com/erikvanbrakel/terraform-provider-sumologic/blob/master/provider/resource_sumologic_http_source.go#L95.

Only the attributes which are SET in these methods actually accurately show diffs, am I right? Solution would then be to set the other ones too.

shinitiandrei commented 7 years ago

Hi again @erikvanbrakel !

I'm cracking my head around this error: ./main.go:10: cannot use provider.Provider (type func() "github.com/erikvanbrakel/terraform-provider-sumologic/vendor/github.com/hashicorp/terraform/terraform".ResourceProvider) as type "github.com/hashicorp/terraform/plugin".ProviderFunc in field value

Just trying to run go build or go test and as your project seems flawless in your build records I think it might be something in my environment or a known error... Any ideas? :)

Thanks!

shinitiandrei commented 7 years ago

I've got it sorted out, I was developing outside GOPATH, which apparently golang doesn't allow me to do (found it here )...So I just moved my project within GOPATH/src/github.com/username and everything worked fine. I will be updating the documentation on how to develop locally and be adding the validations as well, and furthermore requesting you a PR 😄

erikvanbrakel commented 7 years ago

Cool! Didn't have time to check it out, glad you found it. I recall setting up was a pain initially, something they could improve on IMHO.

shinitiandrei commented 7 years ago

Changes made in PR https://github.com/erikvanbrakel/terraform-provider-sumologic/pull/29