-
Notifications
You must be signed in to change notification settings - Fork 9
Terraform docker splunk deployment #124
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
Open
CSL-Answer
wants to merge
35
commits into
develop
Choose a base branch
from
terraform-docker-splunk-deployment
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all 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 afe2d74
Fixed source urls for modules
CSL-Answer 46356d1
splunk config now successfully runs a splunk instance
CSL-Answer b9e07db
code style ammendments
CSL-Answer 7fb54f5
moved splunk variables to local folder for the splunk terraform code,…
CSL-Answer 05b9eb8
Added checkov skip comments to avoid the unneeded analysis errors
CSL-Answer 5d3154d
Bump Microsoft.AspNetCore.Mvc.Testing from 7.0.3 to 7.0.4 (#125)
dependabot[bot] fe16d30
Bump Alba from 7.3.0 to 7.4.0 (#126)
dependabot[bot] 0559494
Bump AWSSDK.CloudWatchLogs from 3.7.104.33 to 3.7.104.40 (#128)
dependabot[bot] 4391999
successfully applied however, broke current splunk instance
CSL-Answer 64facca
updated route 53 record code
CSL-Answer 1b0f2bf
subnet mapping now configured for one subnet
CSL-Answer 5f423d6
Added S3 bucket for splunk
CSL-Answer 1cf066e
Added back certificate and reference. Ammended properties pointed out…
CSL-Answer da1b104
Added 8000 to ec2 sg. Added certificate validation
CSL-Answer 326b58b
added eip sg to ec2 setup
CSL-Answer f70c276
Fixed s3 backend
bethcryer 06ff32e
switched to ALB, still not workin :(
bethcryer bbd6a45
hi :)
bethcryer e4867a6
Merge branch 'terraform-docker-splunk-deployment' of https://github.c…
5373000
reverted indentation in bash script
81ac819
changed ports in security group
30015bc
removed docker provider
CSL-Answer 572da90
s3 access logs and related config added
CSL-Answer 5b8fcbc
enabled deletion protection for load balancer
CSL-Answer d2c53e7
Added skip for aws autoscaling EC2 launch template checkov check
CSL-Answer 7a6f5d9
Skipped checkov check for S3 bucket event notifications
CSL-Answer a10a2ed
Skipped check for EC2 lanch templates for the aws_autoscaling_group r…
CSL-Answer a91ff96
Checkov check for KMS encryption on S3 buckets has been skipped. Will…
CSL-Answer c0d6e37
Added checkov skips for the elb_logs resource
CSL-Answer 68d7a0d
Set associate public ip address to false for the splunk ec2 instance
CSL-Answer ec869d2
Load balancer for splunk is not using TLS 1.2
CSL-Answer fca116d
Added versioning for the elb logs s3 bucket
CSL-Answer 33f9c62
updated ec2 instance set up to use the new version 2.1.0 for the ec2 …
CSL-Answer 6936d3d
Successfully applies with ec2 update
CSL-Answer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| terraform { | ||
| required_version = "~> 1.3" | ||
|
|
||
| required_providers { | ||
| tls = { | ||
| source = "hashicorp/tls" | ||
| version = ">= 4.0.4" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource "aws_iam_instance_profile" "instance_profile" { | ||
| name = "${var.project_name}-ec2-monitoring-and-setup" | ||
| role = aws_iam_role.instance_role.name | ||
| } | ||
|
|
||
| resource "aws_iam_role" "instance_role" { | ||
| name = "${var.project_name}-ec2-monitoring-and-setup" | ||
| assume_role_policy = <<-EOF | ||
| { | ||
| "Version": "2012-10-17", | ||
| "Statement": [ | ||
| { | ||
| "Action": ["sts:AssumeRole"], | ||
| "Effect": "Allow", | ||
| "Principal": { | ||
| "Service": ["ec2.amazonaws.com"] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| EOF | ||
| } | ||
|
|
||
| resource "aws_iam_role_policy_attachment" "instance_role" { | ||
| for_each = toset([ | ||
| "arn:aws:iam::aws:policy/service-role/AmazonEC2RoleforSSM", | ||
| "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy" | ||
| ]) | ||
| role = aws_iam_role.instance_role.name | ||
| policy_arn = each.value | ||
| } | ||
|
|
||
| resource "tls_private_key" "private_key" { | ||
| algorithm = "RSA" | ||
| rsa_bits = 4096 | ||
| } | ||
|
|
||
| resource "aws_key_pair" "key_pair" { | ||
| key_name = "${var.project_name}-key-pair" | ||
| public_key = tls_private_key.private_key.public_key_openssh | ||
| } | ||
|
|
||
| resource "aws_instance" "ec2" { | ||
| instance_type = var.ec2_instance_type | ||
| key_name = aws_key_pair.key_pair.key_name | ||
| ami = var.ami_id | ||
| metadata_options { | ||
| http_endpoint = "enabled" | ||
| http_tokens = "required" | ||
| } | ||
| root_block_device { | ||
| encrypted = true | ||
| } | ||
|
|
||
| availability_zone = var.availability_zone | ||
| subnet_id = var.subnet_id | ||
| vpc_security_group_ids = var.vpc_security_group_ids | ||
| associate_public_ip_address = var.associate_public_ip_address | ||
|
|
||
| iam_instance_profile = aws_iam_instance_profile.instance_profile.name | ||
|
|
||
| user_data = var.user_data | ||
| user_data_replace_on_change = var.user_data_replace_on_change | ||
|
|
||
| tags = { | ||
| Name = "${var.project_name}-ec2" | ||
| Owner = var.owner | ||
| } | ||
| } | ||
|
|
||
| resource "aws_eip" "public_elastic_ip" { | ||
| count = var.needs_elastic_ip == true ? 1 : 0 | ||
|
|
||
| instance = aws_instance.ec2.id | ||
| vpc = true | ||
|
|
||
| tags = { | ||
| Name = "${var.project_name}-public-elastic-ip" | ||
| Owner = var.owner | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| output "instance_public_ip_address" { | ||
| value = aws_instance.ec2.public_ip | ||
| description = "This outputs the public IP associated with the EC2 instance. Note that this ouput will be the same as the elastic IP if `needs_elastic_ip` is set to `true`. This output is of type `string`." | ||
| } | ||
|
|
||
| output "ec2_id" { | ||
| value = aws_instance.ec2.id | ||
| description = "This outputs the ID of the EC2 instance." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| MANDATORY VARIABLES | ||
| */ | ||
| variable "project_name" { | ||
| type = string | ||
| description = "This is used to label the resources of the module." | ||
| } | ||
|
|
||
| variable "owner" { | ||
| type = string | ||
| description = "This is used to specify the owner of the resources in this module." | ||
| } | ||
|
|
||
| variable "ami_id" { | ||
| type = string | ||
| description = "This is the id of the ami image used for the ec2 instance." | ||
| } | ||
|
|
||
| variable "availability_zone" { | ||
| type = string | ||
| description = "This is the availability zone you want the ec2 instance to be created in." | ||
| } | ||
|
|
||
| variable "subnet_id" { | ||
| type = string | ||
| description = "This is the id of the subnet you want the ec2 instance to be created in." | ||
| } | ||
|
|
||
| variable "vpc_security_group_ids" { | ||
| type = list(string) | ||
| description = "This is a list of ids that specifies the security groups you want your EC2 to be in. If you do not wish to specify a security group for your module then please set this value to an empty list" | ||
| } | ||
|
|
||
| /* | ||
| OPTIONAL VARIABLES | ||
| */ | ||
| variable "ec2_instance_type" { | ||
| type = string | ||
| default = "t2.micro" | ||
| description = "This is the type of EC2 instance you want." | ||
| } | ||
|
|
||
| variable "associate_public_ip_address" { | ||
| type = bool | ||
| default = true | ||
| description = "This is a boolean value indicating if a public IP address should be associated with the EC2 instance." | ||
| } | ||
|
|
||
| variable "user_data" { | ||
| type = string | ||
| default = "" | ||
| description = "This allows bash scripts and command line commands to be specified and run in the EC2 instance when launched. Do not pass gzip-compressed data via this argument." | ||
| } | ||
|
|
||
| variable "needs_elastic_ip" { | ||
| type = bool | ||
| default = false | ||
| description = "This is a boolean value indicating whether an elastic IP should be generated and associated with the EC2 instance." | ||
| } | ||
|
|
||
| variable "user_data_replace_on_change" { | ||
| type = bool | ||
| default = true | ||
| description = "This value indicates whether changes to the `user_data` value triggers a rebuild of the EC2 instance." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| terraform { | ||
| backend "s3" { | ||
| bucket = "answerking-splunk-terraform" | ||
| key = "answerking-splunk-terraform.tfstate" | ||
| region = "eu-west-2" | ||
| dynamodb_table = "answerking-splunk-terraform-state" | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| resource "aws_s3_bucket" "terraform_backend_bucket" { | ||
| bucket = "answerking-splunk-terraform" | ||
|
|
||
| tags = { | ||
| Name = "answerking-splunk-terraform" | ||
| } | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_acl" "terraform_backend_bucket_acl" { | ||
| bucket = aws_s3_bucket.terraform_backend_bucket.id | ||
| acl = "private" | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_public_access_block" "terraform_backend_bucket_public_access_block" { | ||
| bucket = aws_s3_bucket.terraform_backend_bucket.id | ||
|
|
||
| block_public_acls = true | ||
| block_public_policy = true | ||
| ignore_public_acls = true | ||
| restrict_public_buckets = true | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_versioning" "terraform_backend_bucket_versioning" { | ||
| bucket = aws_s3_bucket.terraform_backend_bucket.id | ||
| versioning_configuration { | ||
| status = "Enabled" | ||
| } | ||
| } | ||
|
|
||
| resource "aws_dynamodb_table" "terraform_backend_state" { | ||
| name = "answerking-splunk-terraform-state" | ||
| read_capacity = 20 | ||
| write_capacity = 20 | ||
| hash_key = "LockID" | ||
|
|
||
| attribute { | ||
| name = "LockID" | ||
| type = "S" | ||
| } | ||
| } | ||
| */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #aws provider here | ||
| provider "aws" { | ||
| region = "eu-west-2" | ||
| skip_credentials_validation = true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| 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" | ||
| } | ||
|
|
||
| variable "dns_base_domain_name" { | ||
| type = string | ||
| description = "DNS Base Domain Name" | ||
| default = "answerking.co.uk" | ||
| } | ||
|
|
||
| variable "dns_splunk_domain_name" { | ||
| type = string | ||
| description = "Splunk Domain Name" | ||
| default = "splunk.answerking.co.uk" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we keep all of this commented?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I think leave it so that it's obvious all this exists on AWS and we could delete the resources in future if we needed to