Terraform provider to configure Sonatype Nexus using it's API.
Implemented and tested with Sonatype Nexus 3.29.0-02
.
provider "nexus" {
insecure = true
password = "admin123"
url = "https://127.0.0.1:8080"
username = "admin"
}
There is a makefile to build the provider.
make
To build and install provider on macOS into ~/.terraform.d/plugins/darwin_amd64
, you can run
make darwin-build-install
In this case provider will be available to use with your terraform codebase (in terraform init stage).
For testing start a local Docker containers using make
make start-services
This will start a Docker and MinIO containers and expose ports 8081 and 9000.
Now start the tests
NEXUS_URL="http://127.0.0.1:8081" NEXUS_USERNAME="admin" NEXUS_PASSWORD="admin123" AWS_ACCESS_KEY_ID="minioadmin" AWS_SECRET_ACCESS_KEY="minioadmin" AWS_ENDPOINT="http://minio:9000" make testacc
or without S3 tests:
SKIP_S3_TESTS=1 NEXUS_URL="http://127.0.0.1:8081" NEXUS_USERNAME="admin" NEXUS_PASSWORD="admin123" make testacc
NOTE: To test Blobstore type S3 following environment variables must be set, otherwise tests will fail:
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
,AWS_DEFAULT_REGION
the AWS region of the S3 bucket to use, defaults toeu-central-1
,AWS_BUCKET_NAME
the name of S3 bucket to use, defaults toterraform-provider-nexus-s3-test
.
Optionally you can set AWS_ENDPOINT
to point an alternative S3 endpoint.
To debug tests
Set env variable TF_LOG=DEBUG
to see additional output.
Use printState()
function to discover terraform state (and resource props) during test.
Debug configurations are also available for VS Code.
To generate the terraform documentation from go files, you can run
make docs