Skip to content

Update to Terraform Plugin Framework #39

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all format lint tidy test dep clean
.PHONY: all format lint tidy test dep clean docs

# -----------------------------------------------------------------------------
# CONSTANTS
Expand All @@ -9,6 +9,9 @@ version = `cat VERSION`
src_dir := terraform-provider-snowplow

build_dir = build
docs_dir = docs
examples_dir = examples
templates_dir = templates

coverage_dir = $(build_dir)/coverage
coverage_out = $(coverage_dir)/coverage.out
Expand All @@ -35,6 +38,15 @@ all:
GO111MODULE=on gox -osarch=darwin/amd64 -output=$(bin_darwin) ./$(src_dir)
GO111MODULE=on gox -osarch=windows/amd64 -output=$(bin_windows) ./$(src_dir)

docs:
tfplugindocs generate \
--rendered-provider-name Snowplow \
--provider-name snowplow \
--provider-dir ./$(src_dir) \
--rendered-website-dir ../$(docs_dir) \
--examples-dir ../$(examples_dir) \
--website-source-dir ../$(templates_dir) \

# -----------------------------------------------------------------------------
# FORMATTING
# -----------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ To format the golang code in the source directory:
host> make format
```

To update documentation with any changes:

```bash
host> make docs
```

**Note:** Always run `format` before submitting any code.

**Note:** The `make test` command also generates a code coverage file which can be found at `build/coverage/coverage.html`.
Expand Down
34 changes: 23 additions & 11 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
---
page_title: "Snowplow Provider"
subcategory: ""
description: |-
Terraform provider for emitting Snowplow events
---

# Snowplow Provider

Terraform provider for emitting Snowplow events

## Example Usage ##
## Example Usage

To actually start tracking Snowplow events from Terraform you will need to configure the `provider` and a `resource`:

```hcl
```terraform
# Minimal configuration
provider "snowplow" {
collector_uri = "com.acme.collector"
Expand All @@ -27,9 +34,9 @@ Now that the provider is configured we can track an event!

Note: All provider settings can also be configured directly in the resource.

#### How to track: `self_describing_event` ####
#### How to track: `self_describing_event`

```hcl
```terraform
locals {
tf_module_context = {
name = "aws_module"
Expand Down Expand Up @@ -62,11 +69,16 @@ resource "snowplow_track_self_describing_event" "module_action" {
}
```

## Argument Reference ##
<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `collector_uri` (String) URI of your Snowplow Collector
- `emitter_protocol` (String) Whether to use HTTP or HTTPS to send events
- `emitter_request_type` (String) Whether to use GET or POST requests to emit events
- `tracker_app_id` (String) Optional application ID
- `tracker_namespace` (String) Optional namespace
- `tracker_platform` (String) Optional platform


* `collector_uri` (Optional) URI of your Snowplow Collector (Default: "")
* `tracker_app_id` (Optional) Optional application ID (Default: "")
* `tracker_namespace` (Optional) Optional namespace (Default: "")
* `tracker_platform` (Optional) Optional platform (Default: srv)
* `emitter_request_type` (Optional) Whether to use GET or POST requests to emit events (Default: "POST")
* `emitter_protocol` (Optional) Whether to use HTTP or HTTPS to send events (Default: "HTTPS")
44 changes: 0 additions & 44 deletions docs/resources/snowplow_track_self_describing_event.md

This file was deleted.

64 changes: 64 additions & 0 deletions docs/resources/track_self_describing_event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
page_title: "snowplow_track_self_describing_event Resource - Snowplow"
subcategory: ""
description: |-
Emits an event to the configured collector upon creation, update, or deletion of the resource.
---

# snowplow_track_self_describing_event Resource

Emits an event to the configured collector upon creation, update, or deletion of the resource.

## Example Usage

```terraform
resource "snowplow_track_self_describing_event" "module_action" {
create_event = {
iglu_uri = "iglu:com.acme/lifecycle/jsonschema/1-0-0",
payload = "{\"actionType\":\"create\"}"
}

update_event = {
iglu_uri = "iglu:com.acme/lifecycle/jsonschema/1-0-0",
payload = "{\"actionType\":\"update\"}"
}

delete_event = {
iglu_uri = "iglu:com.acme/lifecycle/jsonschema/1-0-0",
payload = "{\"actionType\":\"delete\"}"
}

contexts = [
{
iglu_uri = "iglu:com.acme/module_context/jsonschema/1-0-0",
payload = "${jsonencode(local.tf_module_context)}",
},
]
}
```


<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `contexts` (List of Map of String)
- `create_event` (Map of String)
- `delete_event` (Map of String)
- `update_event` (Map of String)

### Optional

- `collector_uri` (String) URI of your Snowplow Collector
- `emitter_protocol` (String) Whether to use HTTP or HTTPS to send events
- `emitter_request_type` (String) Whether to use GET or POST requests to emit events
- `tracker_app_id` (String) Optional application ID
- `tracker_namespace` (String) Optional namespace
- `tracker_platform` (String) Optional platform

### Read-Only

- `id` (String) The ID of this resource.


14 changes: 14 additions & 0 deletions examples/example_1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Minimal configuration
provider "snowplow" {
collector_uri = "com.acme.collector"
}

# Optional extra configuration options
provider "snowplow" {
collector_uri = "com.acme.collector"
tracker_app_id = "terraform" # Default; ""
tracker_namespace = "terraform" # Default; ""
tracker_platform = "mob" # Default; srv (server)
emitter_request_type = "GET" # Default; POST
emitter_protocol = "HTTP" # Default; HTTPS
}
30 changes: 30 additions & 0 deletions examples/example_2.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
locals {
tf_module_context = {
name = "aws_module"
version = "1.1.2"
}
}

resource "snowplow_track_self_describing_event" "module_action" {
create_event = {
iglu_uri = "iglu:com.acme/lifecycle/jsonschema/1-0-0",
payload = "{\"actionType\":\"create\"}"
}

update_event = {
iglu_uri = "iglu:com.acme/lifecycle/jsonschema/1-0-0",
payload = "{\"actionType\":\"update\"}"
}

delete_event = {
iglu_uri = "iglu:com.acme/lifecycle/jsonschema/1-0-0",
payload = "{\"actionType\":\"delete\"}"
}

contexts = [
{
iglu_uri = "iglu:com.acme/module_context/jsonschema/1-0-0",
payload = "${jsonencode(local.tf_module_context)}",
},
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
resource "snowplow_track_self_describing_event" "module_action" {
create_event = {
iglu_uri = "iglu:com.acme/lifecycle/jsonschema/1-0-0",
payload = "{\"actionType\":\"create\"}"
}

update_event = {
iglu_uri = "iglu:com.acme/lifecycle/jsonschema/1-0-0",
payload = "{\"actionType\":\"update\"}"
}

delete_event = {
iglu_uri = "iglu:com.acme/lifecycle/jsonschema/1-0-0",
payload = "{\"actionType\":\"delete\"}"
}

contexts = [
{
iglu_uri = "iglu:com.acme/module_context/jsonschema/1-0-0",
payload = "${jsonencode(local.tf_module_context)}",
},
]
}
59 changes: 36 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,37 +1,48 @@
module github.com/snowplow-devops/terraform-provider-snowplow

go 1.20
go 1.22.0

toolchain go1.23.3

require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0
github.com/imdario/mergo v0.3.16
github.com/hashicorp/terraform-plugin-framework v1.13.0
github.com/hashicorp/terraform-plugin-go v0.25.0
github.com/hashicorp/terraform-plugin-testing v1.11.0
github.com/snowplow/snowplow-golang-tracker/v2 v2.4.1
github.com/stretchr/testify v1.8.4
github.com/twinj/uuid v1.0.0
)

require (
github.com/agext/levenshtein v1.2.3 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-memdb v1.3.4 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.5.2 // indirect
github.com/hashicorp/go-plugin v1.6.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
github.com/hashicorp/hc-install v0.9.0 // indirect
github.com/hashicorp/hcl/v2 v2.23.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.19.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.23.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
Expand All @@ -40,7 +51,7 @@ require (
github.com/mattn/go-sqlite3 v2.0.2+incompatible // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/myesui/uuid v1.0.0 // indirect
Expand All @@ -49,16 +60,18 @@ require (
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/tools/cmd/cover v0.1.0-deprecated // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.27.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/stretchr/testify.v1 v1.2.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading