This repo implements the Terraform provider for Sneller.
Run the following command to build the provider
$ go build -o terraform-provider-sneller
$ go install github.com/goreleaser/goreleaser@latest
$ make release
You will find the releases in the /dist
directory. You will need to rename the provider binary to terraform-provider-sneller
and move the binary into the appropriate subdirectory within the user plugins directory.
First, build and install the provider.
$ make install
Then, navigate to the test
directory.
$ cd test
Run the following command to initialize the workspace and apply the sample configuration (make sure you set SNELLER_TOKEN
).
$ export TF_VAR_SNELLER_TOKEN=<...>
$ terraform init && terraform apply
This will automatically:
- Create the IAM role that can be used by Sneller to access the S3 bucket.
- Create the Sneller source bucket (Sneller can only read).
- Create the Sneller cache bucket (Sneller can read/write).
- Assign the IAM role to the Sneller configuration for this region (default
us-east-1
). - Setup the S3 event notification that signals Sneller when new data arrives in the source bucket.
- Create a table definition (db:
test-db
, table:test-table
). - Upload a test JSON file.
When you need to debug a resource/data-source, then debugging the integration tests is typically the most straightforward option. Testing the provider requires some environment variables:
TF_ACC
should be set to1
to enable running the acceptance tests.SNELLER_TOKEN
should be set to the bearer token of your tenant.TENANT_ACCOUNT_ID
is optional and should be set to the AWS account identifier. If it's not set, then it defaults to the AWS account identifier of the AWS variables in the environment.SNELLER_API_ENDPOINT
is optional and defaults to the default API endpoint of the production environment. This can be changed when testing against another end-point.
The testing process is quite slow, due to the amount of API calls. Therefore, it's recommended to
set the time-out to 10m
.
You can use the following .vscode/settings.json
file in the root of the repository to enable the
settings for running unit tests from within Visual Studio Code:
{
"go.testEnvVars": {
"TF_ACC": "1",
"SNELLER_TOKEN": "SA0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
//"TENANT_ACCOUNT_ID": "093008718846",
//"SNELLER_API_ENDPOINT": "http://localhost:8080",
},
"go.testTimeout": "10m",
}
The examples
folder contain the Terraform samples for the documentation, but can also run
independent. Make sure to set the TF_VAR_sneller_token