diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml
index 0577ed5..85f8ba9 100644
--- a/.github/workflows/linting.yml
+++ b/.github/workflows/linting.yml
@@ -24,4 +24,4 @@ jobs:
- name: Files lint
run: |
- make "lint-files"
+ make "lint"
diff --git a/.github/workflows/terraform-docs.yml b/.github/workflows/terraform-docs.yml
index d1357cf..a199afe 100644
--- a/.github/workflows/terraform-docs.yml
+++ b/.github/workflows/terraform-docs.yml
@@ -16,5 +16,5 @@ jobs:
- name: terraform-docs
run: |
- make terraform-docs
+ make gen
git diff --quiet || { echo "Build Changes"; git diff; git status; false; }
diff --git a/.gitignore b/.gitignore
index 1fef4ab..81fabd5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,5 @@
# .tfvars files
*.tfvars
+
+.idea
diff --git a/Makefile b/Makefile
index 5defbc2..7cabe19 100644
--- a/Makefile
+++ b/Makefile
@@ -2,95 +2,242 @@ ifneq (,)
.error This Makefile requires GNU Make.
endif
+.PHONY: help gen lint test _gen-main _gen-examples _gen-modules _lint-files _lint-fmt _lint-json _pull-tf _pull-tfdocs _pull-fl _pull-jl
+
+CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
+TF_EXAMPLES = $(sort $(dir $(wildcard $(CURRENT_DIR)examples/*/)))
+TF_MODULES = $(sort $(dir $(wildcard $(CURRENT_DIR)modules/*/)))
+
# -------------------------------------------------------------------------------------------------
-# Default configuration
+# Container versions
# -------------------------------------------------------------------------------------------------
-.PHONY: help lint lint-files terraform-docs terraform-fmt _pull-tf _pull-tfdocs
-CURRENT_DIR = $(PWD)
+TF_VERSION = 1.5.7
+TFDOCS_VERSION = 0.16.0-0.34
+FL_VERSION = latest-0.8
+JL_VERSION = 1.6.0-0.14
# -------------------------------------------------------------------------------------------------
-# Docker image versions
+# Enable linter (file-lint, terraform fmt, jsonlint)
# -------------------------------------------------------------------------------------------------
-TF_VERSION = 0.13.7
-FL_VERSION = 0.4
+LINT_FL_ENABLE = 1
+LINT_TF_ENABLE = 1
+LINT_JL_ENABLE = 1
-FL_IGNORE_PATHS = .git/,.github/,.idea/
+FL_IGNORE_PATHS = .git/,.github/,.terraform/,.idea
# -------------------------------------------------------------------------------------------------
-# Terraform-docs configuration
+# terraform-docs defines
# -------------------------------------------------------------------------------------------------
-TFDOCS_VERSION = 0.15.0-0.29
-
# Adjust your delimiter here or overwrite via make arguments
-TFDOCS_DELIM_START =
-TFDOCS_DELIM_CLOSE =
+DELIM_START =
+DELIM_CLOSE =
+# What arguments to append to terraform-docs command
+TFDOCS_ARGS = --sort=false
+
# -------------------------------------------------------------------------------------------------
-# Meta Targets
+# Default target
# -------------------------------------------------------------------------------------------------
-
help:
- @echo
- @echo "Meta targets"
- @echo "--------------------------------------------------------------------------------"
- @echo " help Show this help screen"
- @echo
- @echo "Read-only targets"
- @echo "--------------------------------------------------------------------------------"
- @echo " lint Lint basics as well as *.tf and *.tfvars files"
- @echo " lint-files Lint basics"
- @echo
- @echo "Writing targets"
- @echo "--------------------------------------------------------------------------------"
- @echo " terraform-docs Run terraform-docs against all README.md"
- @echo " terraform-fmt Run terraform-fmt against *.tf and *.tfvars files"
+ @echo "gen Generate terraform-docs output and replace in README.md's"
+ @echo "lint Static source code analysis"
+ @echo "test Integration tests"
# -------------------------------------------------------------------------------------------------
-# Read-only Targets
+# Standard targets
# -------------------------------------------------------------------------------------------------
+gen: _pull-tfdocs
+ @echo "################################################################################"
+ @echo "# Terraform-docs generate"
+ @echo "################################################################################"
+ @$(MAKE) --no-print-directory _gen-main
+ @$(MAKE) --no-print-directory _gen-examples
+ @$(MAKE) --no-print-directory _gen-modules
lint:
- @$(MAKE) --no-print-directory terraform-fmt _WRITE=false
- @$(MAKE) --no-print-directory lint-files
+ @if [ "$(LINT_FL_ENABLE)" = "1" ]; then \
+ $(MAKE) --no-print-directory _lint-files; \
+ fi
+ @if [ "$(LINT_TF_ENABLE)" = "1" ]; then \
+ $(MAKE) --no-print-directory _lint-fmt; \
+ fi
+ @if [ "$(LINT_JL_ENABLE)" = "1" ]; then \
+ $(MAKE) --no-print-directory _lint-json; \
+ fi
-lint-files:
- @echo "################################################################################"
- @echo "# file-lint"
- @echo "################################################################################"
- @docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-cr --text --ignore '$(FL_IGNORE_PATHS)' --path .
- @docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-crlf --text --ignore '$(FL_IGNORE_PATHS)' --path .
- @docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-trailing-single-newline --text --ignore '$(FL_IGNORE_PATHS)' --path .
- @docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-trailing-space --text --ignore '$(FL_IGNORE_PATHS)' --path .
- @docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-utf8 --text --ignore '$(FL_IGNORE_PATHS)' --path .
- @docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-utf8-bom --text --ignore '$(FL_IGNORE_PATHS)' --path .
+test: _pull-tf
+ @$(foreach example,\
+ $(TF_EXAMPLES),\
+ DOCKER_PATH="/t/examples/$(notdir $(patsubst %/,%,$(example)))"; \
+ echo "################################################################################"; \
+ echo "# examples/$$( basename $${DOCKER_PATH} )"; \
+ echo "################################################################################"; \
+ echo; \
+ echo "------------------------------------------------------------"; \
+ echo "# Terraform init"; \
+ echo "------------------------------------------------------------"; \
+ if docker run $$(tty -s && echo "-it" || echo) --rm --network host -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" hashicorp/terraform:$(TF_VERSION) \
+ init \
+ -lock=false \
+ -upgrade \
+ -reconfigure \
+ -input=false \
+ -get=true; \
+ then \
+ echo "OK"; \
+ else \
+ echo "Failed"; \
+ docker run $$(tty -s && echo "-it" || echo) --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" --entrypoint=rm hashicorp/terraform:$(TF_VERSION) -rf .terraform/ || true; \
+ exit 1; \
+ fi; \
+ echo; \
+ echo "------------------------------------------------------------"; \
+ echo "# Terraform validate"; \
+ echo "------------------------------------------------------------"; \
+ if docker run $$(tty -s && echo "-it" || echo) --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" hashicorp/terraform:$(TF_VERSION) \
+ validate \
+ $(ARGS) \
+ .; then \
+ echo "OK"; \
+ docker run $$(tty -s && echo "-it" || echo) --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" --entrypoint=rm hashicorp/terraform:$(TF_VERSION) -rf .terraform/ || true; \
+ else \
+ echo "Failed"; \
+ docker run $$(tty -s && echo "-it" || echo) --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" --entrypoint=rm hashicorp/terraform:$(TF_VERSION) -rf .terraform/ || true; \
+ exit 1; \
+ fi; \
+ echo; \
+ )
# -------------------------------------------------------------------------------------------------
-# Writing Targets
+# Helper Targets
# -------------------------------------------------------------------------------------------------
+_gen-main:
+ @echo "------------------------------------------------------------"
+ @echo "# Main module"
+ @echo "------------------------------------------------------------"
+ @if docker run $$(tty -s && echo "-it" || echo) --rm \
+ -v $(CURRENT_DIR):/data \
+ -e DELIM_START='' \
+ -e DELIM_CLOSE='' \
+ cytopia/terraform-docs:$(TFDOCS_VERSION) \
+ terraform-docs-replace --show header markdown tbl --indent 2 --sort README.md; then \
+ echo "OK"; \
+ else \
+ echo "Failed"; \
+ exit 1; \
+ fi
+ @if docker run $$(tty -s && echo "-it" || echo) --rm \
+ -v $(CURRENT_DIR):/data \
+ -e DELIM_START='' \
+ -e DELIM_CLOSE='' \
+ cytopia/terraform-docs:$(TFDOCS_VERSION) \
+ terraform-docs-replace --show providers markdown tbl --indent 2 --sort README.md; then \
+ echo "OK"; \
+ else \
+ echo "Failed"; \
+ exit 1; \
+ fi
+ @if docker run $$(tty -s && echo "-it" || echo) --rm \
+ -v $(CURRENT_DIR):/data \
+ -e DELIM_START='' \
+ -e DELIM_CLOSE='' \
+ cytopia/terraform-docs:$(TFDOCS_VERSION) \
+ terraform-docs-replace --show requirements markdown tbl --indent 2 --sort README.md; then \
+ echo "OK"; \
+ else \
+ echo "Failed"; \
+ exit 1; \
+ fi
+ @if docker run $$(tty -s && echo "-it" || echo) --rm \
+ -v $(CURRENT_DIR):/data \
+ -e DELIM_START='' \
+ -e DELIM_CLOSE='' \
+ cytopia/terraform-docs:$(TFDOCS_VERSION) \
+ terraform-docs-replace --show modules markdown tbl --indent 2 --sort README.md; then \
+ echo "OK"; \
+ else \
+ echo "Failed"; \
+ exit 1; \
+ fi
+ @if docker run $$(tty -s && echo "-it" || echo) --rm \
+ -v $(CURRENT_DIR):/data \
+ -e DELIM_START='' \
+ -e DELIM_CLOSE='' \
+ cytopia/terraform-docs:$(TFDOCS_VERSION) \
+ terraform-docs-replace --show inputs markdown doc --indent 2 $(TFDOCS_ARGS) README.md; then \
+ echo "OK"; \
+ else \
+ echo "Failed"; \
+ exit 1; \
+ fi
+ @if docker run $$(tty -s && echo "-it" || echo) --rm \
+ -v $(CURRENT_DIR):/data \
+ -e DELIM_START='' \
+ -e DELIM_CLOSE='' \
+ cytopia/terraform-docs:$(TFDOCS_VERSION) \
+ terraform-docs-replace --show outputs markdown tbl --indent 2 --sort README.md; then \
+ echo "OK"; \
+ else \
+ echo "Failed"; \
+ exit 1; \
+ fi
-terraform-docs: _pull-tfdocs
+_gen-examples:
+ @$(foreach example,\
+ $(TF_EXAMPLES),\
+ DOCKER_PATH="examples/$(notdir $(patsubst %/,%,$(example)))"; \
+ echo "------------------------------------------------------------"; \
+ echo "# $${DOCKER_PATH}"; \
+ echo "------------------------------------------------------------"; \
+ if docker run $$(tty -s && echo "-it" || echo) --rm \
+ -v $(CURRENT_DIR):/data \
+ -e DELIM_START='$(DELIM_START)' \
+ -e DELIM_CLOSE='$(DELIM_CLOSE)' \
+ cytopia/terraform-docs:$(TFDOCS_VERSION) \
+ terraform-docs-replace $(TFDOCS_ARGS) markdown $${DOCKER_PATH}/README.md; then \
+ echo "OK"; \
+ else \
+ echo "Failed"; \
+ exit 1; \
+ fi; \
+ )
+
+_gen-modules:
+ @$(foreach module,\
+ $(TF_MODULES),\
+ DOCKER_PATH="modules/$(notdir $(patsubst %/,%,$(module)))"; \
+ echo "------------------------------------------------------------"; \
+ echo "# $${DOCKER_PATH}"; \
+ echo "------------------------------------------------------------"; \
+ if docker run $$(tty -s && echo "-it" || echo) --rm \
+ -v $(CURRENT_DIR):/data \
+ -e DELIM_START='$(DELIM_START)' \
+ -e DELIM_CLOSE='$(DELIM_CLOSE)' \
+ cytopia/terraform-docs:$(TFDOCS_VERSION) \
+ terraform-docs-replace $(TFDOCS_ARGS) markdown $${DOCKER_PATH}/README.md; then \
+ echo "OK"; \
+ else \
+ echo "Failed"; \
+ exit 1; \
+ fi; \
+ )
+
+_lint-files: _pull-fl
+ @# Basic file linting
@echo "################################################################################"
- @echo "# Terraform-docs generate"
+ @echo "# File-lint"
@echo "################################################################################"
- @echo
- @if docker run --rm $$(tty -s && echo "-it" || echo) \
- -v "$(CURRENT_DIR):/data" \
- -e TFDOCS_DELIM_START='$(TFDOCS_DELIM_START)' \
- -e TFDOCS_DELIM_CLOSE='$(TFDOCS_DELIM_CLOSE)' \
- cytopia/terraform-docs:$(TFDOCS_VERSION) \
- terraform-docs-replace --sort-by required markdown README.md; then \
- echo "OK"; \
- else \
- echo "Failed"; \
- exit 1; \
- fi;
- @echo
+ @docker run $$(tty -s && echo "-it" || echo) --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-cr --text --ignore '$(FL_IGNORE_PATHS)' --path .
+ @docker run $$(tty -s && echo "-it" || echo) --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-crlf --text --ignore '$(FL_IGNORE_PATHS)' --path .
+ @docker run $$(tty -s && echo "-it" || echo) --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-trailing-single-newline --text --ignore '$(FL_IGNORE_PATHS)' --path .
+ @docker run $$(tty -s && echo "-it" || echo) --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-trailing-space --text --ignore '$(FL_IGNORE_PATHS)' --path .
+ @docker run $$(tty -s && echo "-it" || echo) --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-utf8 --text --ignore '$(FL_IGNORE_PATHS)' --path .
+ @docker run $$(tty -s && echo "-it" || echo) --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-utf8-bom --text --ignore '$(FL_IGNORE_PATHS)' --path .
-terraform-fmt: _WRITE=true
-terraform-fmt: _pull-tf
+_lint-fmt: _pull-tf
@# Lint all Terraform files
@echo "################################################################################"
@echo "# Terraform fmt"
@@ -99,13 +246,8 @@ terraform-fmt: _pull-tf
@echo "------------------------------------------------------------"
@echo "# *.tf files"
@echo "------------------------------------------------------------"
- @if docker run $$(tty -s && echo "-it" || echo) --rm \
- -v "$(PWD):/data" hashicorp/terraform:$(TF_VERSION) fmt \
- $$(test "$(_WRITE)" = "false" && echo "-check" || echo "-write=true") \
- -diff \
- -list=true \
- -recursive \
- /data; then \
+ @if docker run $$(tty -s && echo "-it" || echo) --rm -v "$(CURRENT_DIR):/t:ro" --workdir "/t" hashicorp/terraform:$(TF_VERSION) \
+ fmt -recursive -check=true -diff=true -write=false -list=true .; then \
echo "OK"; \
else \
echo "Failed"; \
@@ -115,14 +257,8 @@ terraform-fmt: _pull-tf
@echo "------------------------------------------------------------"
@echo "# *.tfvars files"
@echo "------------------------------------------------------------"
- @if docker run $$(tty -s && echo "-it" || echo) --rm --entrypoint=/bin/sh \
- -v "$(PWD):/data" hashicorp/terraform:$(TF_VERSION) \
- -c "find . -not \( -path './*/.terragrunt-cache/*' -o -path './*/.terraform/*' \) \
- -name '*.tfvars' -type f -print0 \
- | xargs -0 -n1 terraform fmt \
- $$(test '$(_WRITE)' = 'false' && echo '-check' || echo '-write=true') \
- -diff \
- -list=true"; then \
+ @if docker run $$(tty -s && echo "-it" || echo) --rm --entrypoint=/bin/sh -v "$(CURRENT_DIR):/t:ro" --workdir "/t" hashicorp/terraform:$(TF_VERSION) \
+ -c "find . -name '*.tfvars' -type f -print0 | xargs -0 -n1 terraform fmt -check=true -write=false -diff=true -list=true"; then \
echo "OK"; \
else \
echo "Failed"; \
@@ -130,14 +266,25 @@ terraform-fmt: _pull-tf
fi;
@echo
+_lint-json: _pull-jl
+ @# Lint all JSON files
+ @echo "################################################################################"
+ @echo "# Jsonlint"
+ @echo "################################################################################"
+ @if docker run $$(tty -s && echo "-it" || echo) --rm -v "$(CURRENT_DIR):/data:ro" cytopia/jsonlint:$(JL_VERSION) \
+ -t ' ' -i '*.terraform/*' '*.json'; then \
+ echo "OK"; \
+ else \
+ echo "Failed"; \
+ exit 1; \
+ fi;
+ @echo
-# -------------------------------------------------------------------------------------------------
-# Helper Targets
-# -------------------------------------------------------------------------------------------------
-
-# Ensure to always have the latest Terraform version
_pull-tf:
docker pull hashicorp/terraform:$(TF_VERSION)
_pull-tfdocs:
docker pull cytopia/terraform-docs:$(TFDOCS_VERSION)
+
+_pull-fl:
+ docker pull cytopia/file-lint:$(FL_VERSION)
diff --git a/README.md b/README.md
index c353a48..3445b83 100644
--- a/README.md
+++ b/README.md
@@ -1,54 +1,114 @@
# Terraform NewRelic integration
-
This module will create lambda for new relic log ingestion.
-
-## Requirements
-| Name | Version |
-|------|---------|
-| [terraform](#requirement\_terraform) | >= 0.13 |
-| [aws](#requirement\_aws) | >= 3.57 |
-| [random](#requirement\_random) | >= 3.1 |
+
+
+
+
+
## Providers
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | >= 3.57 |
-| [random](#provider\_random) | >= 3.1 |
+| [aws](#provider\_aws) | ~> 5.78 |
+| [random](#provider\_random) | ~> 3.6 |
+
+
+
## Modules
| Name | Source | Version |
|------|--------|---------|
| [lambda\_newrelic\_resource\_bucket](#module\_lambda\_newrelic\_resource\_bucket) | github.com/terraform-aws-modules/terraform-aws-s3-bucket | v4.1.2 |
-## Resources
+
+
+
+## Requirements
+
+| Name | Version |
+|------|---------|
+| [terraform](#requirement\_terraform) | ~> 1.5 |
+| [aws](#requirement\_aws) | ~> 5.78 |
+| [random](#requirement\_random) | ~> 3.6 |
+
+
+
+
+## Required Inputs
+
+No required inputs.
+
+## Optional Inputs
+
+The following input variables are optional (have default values):
+
+### [newrelic\_license\_key\_path](#input\_newrelic\_license\_key\_path)
+
+Description: n/a
+
+Type: `string`
+
+Default: `""`
+
+### [newrelic\_account\_number](#input\_newrelic\_account\_number)
+
+Description: n/a
+
+Type: `string`
+
+Default: `""`
+
+### [create\_license\_key\_stack](#input\_create\_license\_key\_stack)
+
+Description: n/a
+
+Type: `bool`
+
+Default: `true`
+
+### [create\_log\_ingestion\_stack](#input\_create\_log\_ingestion\_stack)
+
+Description: n/a
+
+Type: `bool`
+
+Default: `true`
+
+### [create\_lambda\_integration\_stack](#input\_create\_lambda\_integration\_stack)
+
+Description: n/a
+
+Type: `bool`
+
+Default: `true`
+
+### [region](#input\_region)
+
+Description: n/a
+
+Type: `string`
+
+Default: `"eu-central-1"`
+
+### [tags](#input\_tags)
+
+Description: Map of custom tags for the provisioned resources
-| Name | Type |
-|------|------|
-| [aws_cloudformation_stack.newrelic_lambda_integration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack) | resource |
-| [aws_cloudformation_stack.newrelic_license_key_secret](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack) | resource |
-| [aws_cloudformation_stack.newrelic_log_ingestion](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack) | resource |
-| [aws_s3_object.newrelic_log_ingestion_zip](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_object) | resource |
-| [random_string.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
-| [aws_ssm_parameter.newrelic_account_number](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
-| [aws_ssm_parameter.newrelic_license_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
+Type: `map(string)`
-## Inputs
+Default: `{}`
-| Name | Description | Type | Default | Required |
-|------|-------------|------|---------|:--------:|
-| [newrelic\_account\_number](#input\_newrelic\_account\_number) | n/a | `string` | `""` | no |
-| [newrelic\_license\_key\_path](#input\_newrelic\_license\_key\_path) | n/a | `string` | `""` | no |
-| [region](#input\_region) | n/a | `string` | `"eu-central-1"` | no |
-| [tags](#input\_tags) | Map of custom tags for the provisioned resources | `map(string)` | `{}` | no |
+
+
## Outputs
| Name | Description |
|------|-------------|
| [newrelic\_log\_ingestion\_lambda\_arn](#output\_newrelic\_log\_ingestion\_lambda\_arn) | n/a |
-
+
diff --git a/main.tf b/main.tf
index 46fe7d7..cecbff4 100644
--- a/main.tf
+++ b/main.tf
@@ -13,6 +13,7 @@ resource "random_string" "this" {
}
module "lambda_newrelic_resource_bucket" {
+ create_bucket = var.create_log_ingestion_stack
source = "github.com/terraform-aws-modules/terraform-aws-s3-bucket?ref=v4.1.2"
tags = var.tags
bucket_prefix = "lambda-newrelic-resource"
@@ -20,6 +21,7 @@ module "lambda_newrelic_resource_bucket" {
}
resource "aws_s3_object" "newrelic_log_ingestion_zip" {
+ count = var.create_log_ingestion_stack ? 1 : 0
bucket = module.lambda_newrelic_resource_bucket.s3_bucket_id
key = "newrelic-log-ingestion-2.3.5.zip"
source = "${path.module}/newrelic-log-ingestion.zip"
@@ -27,17 +29,28 @@ resource "aws_s3_object" "newrelic_log_ingestion_zip" {
}
resource "aws_cloudformation_stack" "newrelic_log_ingestion" {
+ count = var.create_log_ingestion_stack ? 1 : 0
name = "${local.name}-log-ingestion"
template_body = file("${path.module}/newrelic-log-ingestion.yaml")
capabilities = ["CAPABILITY_AUTO_EXPAND", "CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
parameters = {
Bucket = module.lambda_newrelic_resource_bucket.s3_bucket_id
- Key = aws_s3_object.newrelic_log_ingestion_zip.id
+ Key = aws_s3_object.newrelic_log_ingestion_zip[0].id
NewRelicLicenseKey = data.aws_ssm_parameter.newrelic_license_key.value
}
}
+output "newrelic_log_ingestion_lambda_arn" {
+ value = var.create_log_ingestion_stack ? lookup(aws_cloudformation_stack.newrelic_log_ingestion[0].outputs, "LambdaArn") : null
+}
+
+moved {
+ from = aws_cloudformation_stack.newrelic_license_key_secret
+ to = aws_cloudformation_stack.newrelic_license_key_secret[0]
+}
+
resource "aws_cloudformation_stack" "newrelic_license_key_secret" {
+ count = var.create_license_key_stack ? 1 : 0
name = "NewRelicLicenseKeySecret"
template_body = file("${path.module}/nr-license-key-secret.yaml")
capabilities = ["CAPABILITY_NAMED_IAM"]
@@ -47,11 +60,13 @@ resource "aws_cloudformation_stack" "newrelic_license_key_secret" {
}
}
-output "newrelic_log_ingestion_lambda_arn" {
- value = lookup(aws_cloudformation_stack.newrelic_log_ingestion.outputs, "LambdaArn")
+moved {
+ from = aws_cloudformation_stack.newrelic_lambda_integration
+ to = aws_cloudformation_stack.newrelic_lambda_integration[0]
}
resource "aws_cloudformation_stack" "newrelic_lambda_integration" {
+ count = var.create_lambda_integration_stack ? 1 : 0
name = "${local.name}-lambda-integration"
template_body = file("${path.module}/nr-lambda-integration-role.yaml")
capabilities = ["CAPABILITY_NAMED_IAM"]
diff --git a/variables.tf b/variables.tf
index 38f69e3..7520d36 100644
--- a/variables.tf
+++ b/variables.tf
@@ -8,6 +8,21 @@ variable "newrelic_account_number" {
default = ""
}
+variable "create_license_key_stack" {
+ type = bool
+ default = true
+}
+
+variable "create_log_ingestion_stack" {
+ type = bool
+ default = true
+}
+
+variable "create_lambda_integration_stack" {
+ type = bool
+ default = true
+}
+
variable "region" {
type = string
default = "eu-central-1"
diff --git a/versions.tf b/versions.tf
index 594f913..7d4ee2a 100644
--- a/versions.tf
+++ b/versions.tf
@@ -2,12 +2,12 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
- version = ">= 3.57"
+ version = "~> 5.78"
}
random = {
source = "hashicorp/random"
- version = ">= 3.1"
+ version = "~> 3.6"
}
}
- required_version = ">= 0.13"
+ required_version = "~> 1.5"
}