<commit_before>ROOT_DIR	:= $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PARENTDIR       := $(realpath ../)
AWS_REGION	:= us-west-2
STACK_NAME	:= mozdef-aws-nested
STACK_PARAMS	:= file://aws_parameters.json
# MozDef uses a nested CF stack, the mozdef-parent.yml will tie all child stacks together and load them from S3
# See also mozdef.infosec.mozilla.org bucket
S3_BUCKET_NAME  := mozdef.infosec.allizom.org
S3_BUCKET_PATH	:= cf
S3_BUCKET_URI	:= s3://$(S3_BUCKET_NAME)/$(S3_BUCKET_PATH)
S3_STACK_URI	:= https://s3-$(AWS_REGION).amazonaws.com/$(S3_BUCKET_NAME)/$(S3_BUCKET_PATH)/mozdef-parent.yml

all:
	@echo 'Available make targets:'
	@grep '^[^#[:space:]\.PHONY.*].*:' Makefile
	@echo 'Run ./dmake <target> in order to run the Makefile targets in Docker'

# Note: This requires AWS access
.PHONY: packer-build
packer-build: ## Build the base AMI with packer
	cd packer && packer build packer.json

.PHONY: create-stack
create-stack: test ## Create everything you need for a fresh new stack!
	@export AWS_REGION=$(AWS_REGION)
	@echo "Make sure you have a param file ($(STACK_PARAMS)) with OIDCClientSecret set."
	aws cloudformation create-stack --stack-name $(STACK_NAME) --template-url $(S3_STACK_URI) \
	  --capabilities CAPABILITY_IAM \
	  --parameters $(STACK_PARAMS)

.PHONY: create-s3-bucket
create-s3-bucket:
	@export AWS_REGION=$(AWS_REGION)
	aws s3api create-bucket --bucket $(S3_BUCKET_NAME) --acl public-read --create-bucket-configuration LocationConstraint=$(AWS_REGION)

.PHONY: updated-nested-stack
update-stack: test ## Updates the nested stack on AWS
	@export AWS_REGION=$(AWS_REGION)
	aws cloudformation update-stack --stack-name $(STACK_NAME) --template-url $(S3_STACK_URI) \
	  --capabilities CAPABILITY_IAM \
	  --parameters $(STACK_PARAMS) \<commit_msg>Set Makefile output on create-stack to text<commit_after>ROOT_DIR	:= $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PARENTDIR       := $(realpath ../)
AWS_REGION	:= us-west-2
STACK_NAME	:= mozdef-aws-nested
STACK_PARAMS	:= file://aws_parameters.json
# MozDef uses a nested CF stack, the mozdef-parent.yml will tie all child stacks together and load them from S3
# See also mozdef.infosec.mozilla.org bucket
S3_BUCKET_NAME  := mozdef.infosec.allizom.org
S3_BUCKET_PATH	:= cf
S3_BUCKET_URI	:= s3://$(S3_BUCKET_NAME)/$(S3_BUCKET_PATH)
S3_STACK_URI	:= https://s3-$(AWS_REGION).amazonaws.com/$(S3_BUCKET_NAME)/$(S3_BUCKET_PATH)/mozdef-parent.yml

all:
	@echo 'Available make targets:'
	@grep '^[^#[:space:]\.PHONY.*].*:' Makefile
	@echo 'Run ./dmake <target> in order to run the Makefile targets in Docker'

# Note: This requires AWS access
.PHONY: packer-build
packer-build: ## Build the base AMI with packer
	cd packer && packer build packer.json

.PHONY: create-stack
create-stack: test ## Create everything you need for a fresh new stack!
	@export AWS_REGION=$(AWS_REGION)
	@echo "Make sure you have a param file ($(STACK_PARAMS)) with OIDCClientSecret set."
	aws cloudformation create-stack --stack-name $(STACK_NAME) --template-url $(S3_STACK_URI) \
	  --capabilities CAPABILITY_IAM \
	  --parameters $(STACK_PARAMS) \
	  --output text

.PHONY: create-s3-bucket
create-s3-bucket:
	@export AWS_REGION=$(AWS_REGION)
	aws s3api create-bucket --bucket $(S3_BUCKET_NAME) --acl public-read --create-bucket-configuration LocationConstraint=$(AWS_REGION)

.PHONY: updated-nested-stack
update-stack: test ## Updates the nested stack on AWS
	@export AWS_REGION=$(AWS_REGION)
	aws cloudformation update-stack --stack-name $(STACK_NAME) --template-url $(S3_STACK_URI) \
	  --capabilities CAPABILITY_IAM \
	  --parameters $(STACK_PARAMS) \
{'fraction_non_alphanumeric': 0.13344361731458507, 'fraction_numerical': 0.009925558312655087, 'mean_word_length': 4.749603803486529, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4402427', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1316, 'n_words': 328}