Skip to content

lacework/terraform-provider-lacework

Repository files navigation

Terraform Provider for Lacework

IaC
Codefresh build status

Requirements

  • Terraform 0.15.x
  • Go 1.18 (to build the provider plugin)

Building The Provider

Clone repository to: $GOPATH/src/github.com/lacework/terraform-provider-lacework

mkdir -p $GOPATH/src/github.com/lacework; cd $GOPATH/src/github.com/lacework
git clone [email protected]:lacework/terraform-provider-lacework

Enter the provider directory, prepare and build the provider

cd $GOPATH/src/github.com/lacework/terraform-provider-lacework
make prepare
make build

Note: For contributions created from forks, the repository should still be cloned under the $GOPATH/src/github.com/lacework/terraform-provider-lacework directory to allow the provided make commands to properly run, build, and test this project.

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (version 1.18+ is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin to your $PATH.

To install the provider, run make install. This will build the provider, create the $HOME/.terraformrc and put the provider binary in the $HOME/.terraform.d/plugins directory.

make install

From here, you can cd into any folder that contains Terraform code and run terraform init, use one of the examples in the examples/ folder.

cd examples/data_source_lacework_api_token
terraform init
terraform apply

In order run the providers' unit tests, run the command make test:

make test

In order to run the full suite of integration tests, run make integration-test.

Note: Integration tests create real resources so you need to have a Lacework environment.

LW_ACCOUNT="<YOUR_ACCOUNT>" \
  LW_API_KEY="<YOUR_API_KEY>" \
  LW_API_SECRET="<YOUR_API_SECRET>" \
  make integration-test

Running Specific Integration Tests (RegEx)

When working on new tests or existing tests, you can use a regex to run only specific integration tests. For example, to run only the tests related to the resource lacework_policy use the regex TestPolicy:

make integration-test regex=TestPolicy

Uninstall Developer Environment

If you are doing development of the Lacework provider and you try to use the provider we release to the Terraform Registry, you won't be able to use it and you will see an error message similar to:

│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider lacework/lacework: no available releases match the given constraints

To fix this issue you need to uninstall the local provider (your developer environment) with the command:

make uninstall