forked from ansible-lockdown/RHEL9-CIS
Merge branch 'workflow_update' into updates
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
commit
d7be86e31c
8 changed files with 76 additions and 456 deletions
48
.github/workflows/github_networks.tf
vendored
48
.github/workflows/github_networks.tf
vendored
|
|
@ -1,11 +1,53 @@
|
|||
resource "aws_vpc" "Main" {
|
||||
cidr_block = var.main_vpc_cidr
|
||||
tags = var.instance_tags
|
||||
cidr_block = var.main_vpc_cidr
|
||||
instance_tenancy = "default"
|
||||
tags = {
|
||||
Environment = "${var.environment}"
|
||||
Name = "${var.namespace}-VPC"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_internet_gateway" "IGW" {
|
||||
vpc_id = aws_vpc.Main.id
|
||||
tags = {
|
||||
Name = "${var.namespace}-IGW"
|
||||
Environment = "${var.environment}"
|
||||
Name = "${var.namespace}-IGW"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_subnet" "publicsubnets" {
|
||||
vpc_id = aws_vpc.Main.id
|
||||
cidr_block = var.public_subnets
|
||||
availability_zone = var.availability_zone
|
||||
tags = {
|
||||
Environment = "${var.environment}"
|
||||
Name = "${var.namespace}-pubsub"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_subnet" "Main" {
|
||||
vpc_id = aws_vpc.Main.id
|
||||
cidr_block = var.private_subnets
|
||||
availability_zone = var.availability_zone
|
||||
tags = {
|
||||
Environment = "${var.environment}"
|
||||
Name = "${var.namespace}-prvsub"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_route_table" "PublicRT" {
|
||||
vpc_id = aws_vpc.Main.id
|
||||
route {
|
||||
cidr_block = "0.0.0.0/0"
|
||||
gateway_id = aws_internet_gateway.IGW.id
|
||||
}
|
||||
tags = {
|
||||
Environment = "${var.environment}"
|
||||
Name = "${var.namespace}-publicRT"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "rt_associate_public" {
|
||||
subnet_id = aws_subnet.Main.id
|
||||
route_table_id = aws_route_table.PublicRT.id
|
||||
}
|
||||
|
|
|
|||
3
.github/workflows/github_vars.tfvars
vendored
3
.github/workflows/github_vars.tfvars
vendored
|
|
@ -3,7 +3,8 @@
|
|||
// Declared in variables.tf
|
||||
//
|
||||
|
||||
namespace = "github_actions"
|
||||
namespace = "github_actions"
|
||||
environment = "lockdown_github_repo_workflow"
|
||||
|
||||
// Matching pair name found in AWS for keypairs PEM key
|
||||
ami_key_pair_name = "github_actions"
|
||||
|
|
|
|||
17
.github/workflows/linux_benchmark_testing.yml
vendored
17
.github/workflows/linux_benchmark_testing.yml
vendored
|
|
@ -73,7 +73,7 @@ jobs:
|
|||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
run: terraform apply -var-file "OS.tfvars" -var-file "github_vars.tfvars" --auto-approve -input=false
|
||||
run: terraform apply -var-file "github_vars.tfvars" -var-file "OS.tfvars" --auto-approve -input=false
|
||||
|
||||
## Debug Section
|
||||
- name: DEBUG - Show Ansible hostfile
|
||||
|
|
@ -81,18 +81,9 @@ jobs:
|
|||
working-directory: .github/workflows
|
||||
run: cat hosts.yml
|
||||
|
||||
# Centos 7 images take a while to come up insert sleep or playbook fails
|
||||
# Aws deployments taking a while to come up insert sleep or playbook fails
|
||||
|
||||
- name: Check if test os is rhel7
|
||||
working-directory: .github/workflows
|
||||
id: test_os
|
||||
run: >-
|
||||
echo "::set-output name=RHEL7::$(
|
||||
grep -c RHEL7 OS.tfvars
|
||||
)"
|
||||
|
||||
- name: if RHEL7 - Sleep for 60 seconds
|
||||
#if: steps.test_os.outputs.RHEL7 >= 1
|
||||
- name: Sleep for 60 seconds
|
||||
run: sleep 60s
|
||||
shell: bash
|
||||
|
||||
|
|
@ -117,4 +108,4 @@ jobs:
|
|||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
run: terraform destroy -var-file "OS.tfvars" -var-file "github_vars.tfvars" --auto-approve -input=false
|
||||
run: terraform destroy -var-file "github_vars.tfvars" -var-file "OS.tfvars" --auto-approve -input=false
|
||||
|
|
|
|||
13
.github/workflows/main.tf
vendored
13
.github/workflows/main.tf
vendored
|
|
@ -5,9 +5,6 @@ provider "aws" {
|
|||
|
||||
// Create a security group with access to port 22 and port 80 open to serve HTTP traffic
|
||||
|
||||
data "aws_vpc" "default" {
|
||||
default = true
|
||||
}
|
||||
|
||||
resource "random_id" "server" {
|
||||
keepers = {
|
||||
|
|
@ -19,8 +16,8 @@ resource "random_id" "server" {
|
|||
}
|
||||
|
||||
resource "aws_security_group" "github_actions" {
|
||||
name = "${var.namespace}-${random_id.server.hex}"
|
||||
vpc_id = data.aws_vpc.default.id
|
||||
name = "${var.namespace}-${random_id.server.hex}-SG"
|
||||
vpc_id = aws_vpc.Main.id
|
||||
|
||||
ingress {
|
||||
from_port = 22
|
||||
|
|
@ -43,7 +40,8 @@ resource "aws_security_group" "github_actions" {
|
|||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
tags = {
|
||||
Name = "${var.namespace}-SG"
|
||||
Environment = "${var.environment}"
|
||||
Name = "${var.namespace}-SG"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -51,11 +49,13 @@ resource "aws_security_group" "github_actions" {
|
|||
|
||||
resource "aws_instance" "testing_vm" {
|
||||
ami = var.ami_id
|
||||
availability_zone = var.availability_zone
|
||||
associate_public_ip_address = true
|
||||
key_name = var.ami_key_pair_name # This is the key as known in the ec2 key_pairs
|
||||
instance_type = var.instance_type
|
||||
tags = var.instance_tags
|
||||
vpc_security_group_ids = [aws_security_group.github_actions.id]
|
||||
subnet_id = aws_subnet.Main.id
|
||||
root_block_device {
|
||||
delete_on_termination = true
|
||||
}
|
||||
|
|
@ -80,3 +80,4 @@ resource "local_file" "inventory" {
|
|||
audit_git_version: devel
|
||||
EOF
|
||||
}
|
||||
|
||||
|
|
|
|||
9
.github/workflows/terraform.tfvars
vendored
9
.github/workflows/terraform.tfvars
vendored
|
|
@ -1,5 +1,6 @@
|
|||
// vars should be loaded by OSname.tfvars
|
||||
aws_region = "us-east-1"
|
||||
ami_os = var.ami_os
|
||||
ami_username = var.ami_username
|
||||
instance_tags = var.instance_tags
|
||||
availability_zone = "us-east-1b"
|
||||
aws_region = "us-east-1"
|
||||
ami_os = var.ami_os
|
||||
ami_username = var.ami_username
|
||||
instance_tags = var.instance_tags
|
||||
|
|
|
|||
11
.github/workflows/variables.tf
vendored
11
.github/workflows/variables.tf
vendored
|
|
@ -6,6 +6,12 @@ variable "aws_region" {
|
|||
type = string
|
||||
}
|
||||
|
||||
variable "availability_zone" {
|
||||
description = "List of availability zone in the region"
|
||||
default = "us-east-1b"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "instance_type" {
|
||||
description = "EC2 Instance Type"
|
||||
default = "t3.micro"
|
||||
|
|
@ -52,6 +58,11 @@ variable "namespace" {
|
|||
type = string
|
||||
}
|
||||
|
||||
variable "environment" {
|
||||
description = "Env Name used across all tags"
|
||||
type = string
|
||||
}
|
||||
|
||||
// taken from github_vars.tfvars &
|
||||
|
||||
variable "main_vpc_cidr" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue