Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform docker splunk deployment #124

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b20d8ff
First completed draft of splunk terraform file.
CSL-Answer Mar 15, 2023
afe2d74
Fixed source urls for modules
CSL-Answer Mar 16, 2023
46356d1
splunk config now successfully runs a splunk instance
CSL-Answer Mar 16, 2023
b9e07db
code style ammendments
CSL-Answer Mar 17, 2023
7fb54f5
moved splunk variables to local folder for the splunk terraform code,…
CSL-Answer Mar 17, 2023
05b9eb8
Added checkov skip comments to avoid the unneeded analysis errors
CSL-Answer Mar 20, 2023
5d3154d
Bump Microsoft.AspNetCore.Mvc.Testing from 7.0.3 to 7.0.4 (#125)
dependabot[bot] Mar 23, 2023
fe16d30
Bump Alba from 7.3.0 to 7.4.0 (#126)
dependabot[bot] Mar 23, 2023
0559494
Bump AWSSDK.CloudWatchLogs from 3.7.104.33 to 3.7.104.40 (#128)
dependabot[bot] Mar 23, 2023
4391999
successfully applied however, broke current splunk instance
CSL-Answer Mar 24, 2023
64facca
updated route 53 record code
CSL-Answer Mar 27, 2023
1b0f2bf
subnet mapping now configured for one subnet
CSL-Answer Mar 28, 2023
5f423d6
Added S3 bucket for splunk
CSL-Answer Mar 28, 2023
1cf066e
Added back certificate and reference. Ammended properties pointed out…
CSL-Answer Mar 28, 2023
da1b104
Added 8000 to ec2 sg. Added certificate validation
CSL-Answer Mar 31, 2023
326b58b
added eip sg to ec2 setup
CSL-Answer Mar 31, 2023
f70c276
Fixed s3 backend
bethcryer Apr 2, 2023
06ff32e
switched to ALB, still not workin :(
bethcryer Apr 3, 2023
bbd6a45
hi :)
bethcryer Apr 3, 2023
e4867a6
Merge branch 'terraform-docker-splunk-deployment' of https://github.c…
Apr 3, 2023
5373000
reverted indentation in bash script
Apr 3, 2023
81ac819
changed ports in security group
Apr 3, 2023
30015bc
removed docker provider
CSL-Answer Apr 5, 2023
572da90
s3 access logs and related config added
CSL-Answer Apr 5, 2023
5b8fcbc
enabled deletion protection for load balancer
CSL-Answer Apr 12, 2023
d2c53e7
Added skip for aws autoscaling EC2 launch template checkov check
CSL-Answer Apr 12, 2023
7a6f5d9
Skipped checkov check for S3 bucket event notifications
CSL-Answer Apr 12, 2023
a10a2ed
Skipped check for EC2 lanch templates for the aws_autoscaling_group r…
CSL-Answer Apr 13, 2023
a91ff96
Checkov check for KMS encryption on S3 buckets has been skipped. Will…
CSL-Answer Apr 13, 2023
c0d6e37
Added checkov skips for the elb_logs resource
CSL-Answer Apr 13, 2023
68d7a0d
Set associate public ip address to false for the splunk ec2 instance
CSL-Answer Apr 13, 2023
ec869d2
Load balancer for splunk is not using TLS 1.2
CSL-Answer Apr 13, 2023
fca116d
Added versioning for the elb logs s3 bucket
CSL-Answer Apr 13, 2023
33f9c62
updated ec2 instance set up to use the new version 2.1.0 for the ec2 …
CSL-Answer Apr 17, 2023
6936d3d
Successfully applies with ec2 update
CSL-Answer Apr 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions terraform/splunk/splunk.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Just putting everything in on file for now, will move around afterwards

# variables
variable "splunk_project_name" {
type = string
description = "Splunk Project Name"
default = "answerking-splunk-instance"
}

variable "splunk_project_owner" {
type = string
description = "Splunk Resource Owner"
default = "answerking"
}
bethcryer marked this conversation as resolved.
Show resolved Hide resolved

module "splunk_vpc_subnet" {
bethcryer marked this conversation as resolved.
Show resolved Hide resolved
source = "git::https://github.com/answerdigital/terraform-modules//Terraform_modules/vpc_subnets?ref=v1.0.0"
owner = var.splunk_project_owner
project_name = var.splunk_project_name
azs = ["eu-west-2a"]
bethcryer marked this conversation as resolved.
Show resolved Hide resolved
#enable_vpc_flow_logs = true
}

data "aws_ami" "amazon_linux_2" {
most_recent = true
owners = ["amazon"]

filter {
name = "name"
values = ["amzn2-ami-hvm-*-x86_64-ebs"]
}
}

resource "aws_security_group" "ec2_sg" {
name = "${var.splunk_project_name}-ec2_sg"
bethcryer marked this conversation as resolved.
Show resolved Hide resolved
description = "Security group for ec2_sg"
vpc_id = module.splunk_vpc_subnet.vpc_id

ingress {
bethcryer marked this conversation as resolved.
Show resolved Hide resolved
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}

tags = {
Name = "${var.splunk_project_name}-ec2-sg"
Owner = var.splunk_project_owner
}
}

module "ec2_instance_setup" {
source = "git::https://github.com/AnswerConsulting/AnswerKing-Infrastructure.git//Terraform_modules/ec2_instance?ref=v1.0.0"
project_name = "answerking-splunk-instance"
owner = "answerking"
bethcryer marked this conversation as resolved.
Show resolved Hide resolved
ami_id = data.aws_ami.amazon_linux_2.id
availability_zone = "eu-west-2a"
subnet_id = module.splunk_vpc_subnet.public_subnet_ids[0]
vpc_security_group_ids = [aws_security_group.ec2_sg.id]
needs_elastic_ip = true
user_data = <<EOF
#!/bin/bash -xe
#logs all user_data commands into a user-data.log file
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1

sudo yum update -y
sudo yum upgrade -y
sudo yum install docker -y
sudo systemctl enable docker.service
sudo systemctl start docker.service

sudo docker pull splunk/splunk:latest
sudo docker run -d -p 80:8000 -e "SPLUNK_START_ARGS=--accept-license" -e "SPLUNK_PASSWORD={password}" --name splunk splunk/splunk:latest
EOF
}
7 changes: 7 additions & 0 deletions terraform/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ provider "aws" {
skip_credentials_validation = true
}

provider "docker" {}
bethcryer marked this conversation as resolved.
Show resolved Hide resolved

terraform {
required_version = "~> 1.3"

Expand All @@ -16,5 +18,10 @@ terraform {
source = "hashicorp/random"
version = ">= 3.4.3"
}

docker = {
bethcryer marked this conversation as resolved.
Show resolved Hide resolved
source = "kreuzwerker/docker"
version = "~> 2.13.0"
}
}
}