Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli-Meitner committed Nov 8, 2022
0 parents commit 4e9a930
Show file tree
Hide file tree
Showing 21 changed files with 1,577 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Local .terraform directories
**/.terraform/*
**/environment.json
# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
60 changes: 60 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
- artifacts: checksum
args:
# if you are using this in a GitHub action or some other automated pipeline, you
# need to pass the batch flag to indicate its not interactive.
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"
release:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 toluna-terraform

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
TEST?=$$(go list ./... | grep -v 'vendor')
HOSTNAME=toluna.com
NAMESPACE=edu
NAME=toluna
BINARY=terraform-provider-${NAME}
VERSION=0.2
OS_ARCH=darwin_amd64

default: install

build:
go build -o ${BINARY}

release:
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64

install: build
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}

test:
go test -i $(TEST) || exit 1
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4

testacc:
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Adding custom validations to Terraform [Terraform module](https://registry.terraform.io/modules/toluna-terraform/validations/latest)

### Description
This module supports adding custom validations not supported by out of the box Terraform validations upon plan.
This is achieved by running a bash script containing custom functions , that can be call wit h different arguments,
the arguments should include the -a|--action flag which calls the function (action = function name) and any other flags required by the specific function.


## Usage

```hcl
#The following example validates there are no duplicate environments under two different data layers:
module "validate" {
source = "toluna-terraform/validations/custom"
version = "~>0.0.1" // Change to the required version.
arguments = "-a validate_duplicate_env -f ${path.module}/some_json_file.json"
}
#The following example validates you cannot enter a negative value as an index number or an index higher then maximum possible ciders in a json file:
module "validate" {
source = "toluna-terraform/validations/custom"
version = "~>0.0.1" // Change to the required version.
arguments = "-a validate_min_max_env -f ${path.module}/some_json_file.json -m 15"
}
#The following example validates you cannot enter a duplicate index number in a json file:
module "validate" {
source = "toluna-terraform/validations/custom"
version = "~>0.0.1" // Change to the required version.
arguments = "-a validate_duplicate_index -f ${path.module}/some_json_file.json"
}
```

## Toggles
#### Validate arguments:
```yaml
arguments = command line arguments to pass to the validation script I.E. -a funcation name to run -f some file to validate
```

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |


## Providers

| Name | Version |
|------|---------|
| <a name="assert"></a> [assert](https://github.com/bwoznicki/terraform-provider-assert) | >= 0.0.1 |


## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="validate"></a> [validate](#module\validate) | ../../ | |

## Resources

No Resources.

## Inputs

No inputs.

## Outputs

No outputs.
92 changes: 92 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "toluna Provider"
subcategory: ""
description: |-
---

# toluna Provider
The Toluna provider provides resources to allow custom action on terraform resources

## Example Usage

```terraform
terraform {
required_providers {
toluna = {
source = "toluna-terraform/toluna"
version = ">=0.0.9"
}
}
}
provider "aws" {
region = "us-east-1"
profile = "my-profile"
}
provider "toluna" {
}
resource "toluna_invoke_lambda" "example" {
region = "us-east-1"
aws_profile = "my-profile"
function_name = "my_lambda"
payload = jsonencode({"name": "example pay load"})
}
resource "toluna_start_codebuild" "example" {
region = "us-east-1"
aws_profile = "my-profile"
project_name = "my_project"
environment_variables {
name = "my-variable"
value = "FOO"
type = "PLAINTEXT"
}
environment_variables {
name = "my-secret-variable"
value = "BAR"
type = "PARAMETER_STORE"
}
environment_variables {
name = "my-other-secret-variable"
value = "BAR"
type = "SECRETS_MANAGER"
}
}
data "toluna_validate_configuration" "example" {
rule_set {
key_name = "key"
rule ="unique"
value = "nil"
}
rule_set {
key_name = "$..env_index"
rule ="odd"
value = "nil"
}
rule_set {
key_name = "$..env_index"
rule =">"
value = "6"
}
rule_set {
key_name = "$..env_index"
rule ="<"
value = "21"
}
rule_set {
key_name = "key"
rule ="~="
value = "example"
}
json_config = data.consul_keys.appjson.var
}
```

58 changes: 58 additions & 0 deletions docs/resources/invoke_lambda.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "toluna_invoke_lambda Resource - terraform-provider-toluna"
subcategory: ""
description: |-
---

# toluna_invoke_lambda (Resource)





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

### Required

- `function_name` (String)
- `payload` (String)
- `region` (String)

### Optional

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


## Example Usage

```terraform
terraform {
required_providers {
toluna = {
source = "toluna-terraform/toluna"
version = ">=0.0.9"
}
}
}
provider "aws" {
region = "us-east-1"
profile = "my-profile"
}
provider "toluna" {
}
resource "toluna_invoke_lambda" "example" {
region = "us-east-1"
aws_profile = "my-profile"
function_name = "my_lambda"
payload = jsonencode({"name": "example pay load"})
}
```
Loading

0 comments on commit 4e9a930

Please sign in to comment.